PageSourceSearch

https://www.goldwin.co.jp/adss/js/adss/app.js?1.1

js goldwin.co.jp collected 2026-09-24 08:31:22 UTC 16,654 bytes, 496 lines download raw bytes

1var ADSS = ADSS || {};
2ADSS.EcApp = ADSS.EcApp || {};
3ADSS.EcApp.SimpleCart = ADSS.EcApp.SimpleCart || {};
4(function() {
5	ADSS.EcApp.validateElem = function($elem) {
6		var rule = JSON.parse($elem.attr('data-verify-as'));
7		var val = $elem.val();
8		if (!rule.allowempty) {
9			if (val === '' || val === null || val === undefined) {
10			}
11		}
12	};
13	ADSS.EcApp.validateForm = function($form) {
14		$form.find('[data-verify-as]').each(function(elem) {
15			ADSS.EcApp.validateElem($(elem));
16		});
17	};
18	ADSS.EcApp.SimpleCart.add = function(slpId, num, solrId, limit) {
19		num = num || 1;
20		if (solrId) {
21			limit = limit || 10;
22			ADSS.CartAddItem.setBeforeCartAddItem(solrId, limit);
23		}
24		var formId = 'cartFormForSlpId_' + slpId; if ($('#' + formId).size()) { return; }
25		$('<form method="post" id="' + formId + '"></form>').attr('action', ADSS.Config.appBaseUrl + 'cart/add')
26			.append('<input type="hidden" name="slpId" value="' + slpId + '" />')
27			.append('<input type="hidden" name="num" value="' + num + '" />')
28			.appendTo($('body:first'))
29			.submit();
30	};
31	ADSS.EcApp.SimpleCart.update = function(ctdId, num) {
32		num = num || 0;
33		var formId = 'cartFormForCtdId_' + ctdId; if ($('#' + formId).size()) { return; }
34		$('<form method="post" id="' + formId + '"></form>').attr('action', ADSS.Config.appBaseUrl + 'cart/update')
35			.append('<input type="hidden" name="ctdId" value="' + ctdId + '" />')
36			.append('<input type="hidden" name="num" value="' + num + '" />')
37			.appendTo($('body:first'))
38			.submit();
39	};
40	ADSS.EcApp.SimpleCart.addMultiple = function($form, limit) {
41		if ($form.find("input[type=checkbox][name=slpId]:checked").length < 1) {
42			alert('商品が選択されていません');
43			return;
44		}
45		limit = limit || 10;
46
47		if ($form.data('processing')) e.preventDefault();
48		$form.data('processing', true);
49		var addMultipleRequest = [];
50		var solrId;
51		$form.find('input[type="checkbox"][name="slpId"]:checked').each(function() {
52			var slpId = $(this).val();
53			solrId = $(this).attr("data-pvwid");
54			var addObj = {
55				'slpId' : $(this).val(),
56				'num'   : $form.find('input[name="num-' + slpId + '"]').val() || 1
57			};
58			addMultipleRequest.push(addObj);
59		});
60		if (solrId) {
61			ADSS.CartAddItem.setMultipleBeforeCartAddItem($form, limit);
62		}
63		ADSS.Util.postAsJSON($form, addMultipleRequest);
64	};
65	ADSS.EcApp.SimpleCart.updateMultiple = function(shippingPlanDate,ctdId, num) {
66		num = num || 0;
67		var formId = 'cartFormForCtdId_' + shippingPlanDate + '_'+ ctdId; if ($('#' + formId).size()) { return; }
68		$('<form method="post" id="' + formId + '"></form>').attr('action', ADSS.Config.appBaseUrl + 'cartMultiple/update')
69			.append('<input type="hidden" name="shippingPlanDate" value="' + shippingPlanDate + '" />')
70			.append('<input type="hidden" name="ctdId" value="' + ctdId + '" />')
71			.append('<input type="hidden" name="num" value="' + num + '" />')
72			.appendTo($('body:first'))
73			.submit();
74	};
75	ADSS.EcApp.SimpleCart.changeNoveltyMultiple = function(obj, campaignId, seqNo, shippingPlanDate) {
76		var recordId = obj.options[obj.selectedIndex].value;
77		recordId = recordId || 0;
78        $('<form method="post"></form>').attr('action', ADSS.Config.appBaseUrl + 'cartMultiple/selectNoveltyNew')
79            .append('<input type="hidden" name="selectedCampaignId" value="' + campaignId + '" />')
80            .append('<input type="hidden" name="selectedGroupSeqNo" value="' + seqNo + '" />')
81            .append('<input type="hidden" name="shippingPlanDate" value="' + shippingPlanDate + '" />')
82            .append('<input type="hidden" name="selectedRecordId" value="' + recordId + '" />')
83            .appendTo($('body:first'))
84            .submit();
85	};
86
87	ADSS.EcApp.addressSearch = function($zipElem, $stateOrRegionElem, $addressLine1Elem, $addressLine2Elem) {
88		var $searchDeferred = $.Deferred();
89		if ($zipElem.data('finding')) return;
90		$zipElem.data('finding', true);
91		var dict = ADSS.Util.getDictionary();
92		var zip = $zipElem.val();
93		var $deferred = $.Deferred();
94		if (zip === '') {
95			$deferred.reject('input_your_zip');
96		} else if (zip.length < 3) {
97			$deferred.reject('short_your_zip');
98		} else {
99			ADSS.EcApp.getAddress(zip).done(function(data){
100				var responseLength = data.response.numFound;
101				if (responseLength < 1) {
102					$deferred.reject('check_your_zip');
103				} else if (responseLength == 1) {
104					var result = data.response.docs[0];
105					$zipElem.val(result.jpc_post_code);
106					$stateOrRegionElem.val(result.jpc_address_1).keyup();
107					var addressText = result.jpc_address_2 + result.jpc_address_3 + result.jpc_address_4;
108					addressText = addressText.replace(/undefined/g, '');
109					$addressLine1Elem.val(addressText).keyup();
110					$deferred.resolve();
111				} else {
112					var $table = $('<ol></ol>');
113					var trTemplate = _.template('<li style="list-style: none;"><input type="radio" id="address_{{= data.id }}" name="address" data-zip="{{- data.jpc_post_code }}" data-stateorregion="{{- data.jpc_address_1 }}" data-addressline1="{{- data.jpc_address_2 }}" data-addressline2="{{- data.jpc_address_3 }}" data-addressline3="{{- data.jpc_address_4 }}" /><label for="address_{{= data.id }}">{{- data.jpc_address_1 }} {{- data.jpc_address_2 }} {{- data.jpc_address_3 }} {{- data.jpc_address_4 }} </label></li>');
114					_.each(data.response.docs, function(doc) {
115						$(trTemplate(doc)).appendTo($table);
116					});
117					$table.find('input:first').prop('checked', true);
118					var buttons = {};
119					buttons[dict.select] = function($event) {
120						var $dialog = $(this);
121						var $selected = $dialog.find(':checked');
122						$zipElem.val($selected.data('zip'));
123						$stateOrRegionElem.val($selected.data('stateorregion')).keyup();
124						var addressText = $selected.data('addressline1') + $selected.data('addressline2') + $selected.data('addressline3');
125						addressText = addressText.replace(/undefined/g, '');
126						$addressLine1Elem.val(addressText).keyup();
127						$dialog.dialog('close');
128						$deferred.resolve();
129					}
130					var baseWidth = ADSS.Util.getBaseWidth();
131					var dialogWidth = 480 > baseWidth ? baseWidth - 40 : 480;
132					var windowOuterWidth = window.outerWidth;
133					$table.dialog({
134						title: dict.address + dict.search,
135						buttons: buttons,
136						width: dialogWidth,
137						maxHeight: 300,
138						close: function() {
139							var $dialog = $(this);
140							$deferred.reject();
141							$dialog.dialog('destroy');
142						}
143					});
144				}
145			}).fail(function(error){
146				$deferred.reject(error);
147			});
148		}
149
150		$deferred.done(function() {
151			$zipElem.data('finding', false);
152			$searchDeferred.resolve();
153		});
154		$deferred.fail(function(error){
155			var cleanup = true;
156			$zipElem.data('finding', false);
157			if (error) {
158				$stateOrRegionElem.val('');
159				$addressLine1Elem.val('');
160				$addressLine2Elem.val('');
161				ADSS.Util.showMessageDialog('error', dict.address + dict.search, dict[error]);
162			} else {
163				cleanup = false;
164			}
165			$searchDeferred.reject(cleanup);
166		});
167
168		return $searchDeferred.promise();
169	};
170	ADSS.EcApp.confirmAddress = function($zipElem, $stateOrRegionElem, $addressLine1Elem) {
171		var $confirmDeferred = $.Deferred();
172		if ($zipElem.data('finding')) return;
173		$zipElem.data('finding', true);
174		var dict = ADSS.Util.getDictionary();
175		var zip = $zipElem.val();
176		var $deferred = $.Deferred();
177
178		if (zip === '') {
179			$deferred.reject('input_your_zip');
180		} else if (zip.length < 3) {
181			$deferred.reject('short_your_zip');
182		} else {
183			ADSS.EcApp.getAddress(zip).done(function(data){
184				var responseLength = data.response.numFound;
185				if (responseLength < 1) {
186					error = 'check_your_zip';
187				}
188
189				/*
190				 * 郵便番号から取得できる住所と入力住所に差異がある場合に、
191				 * 情報を破棄し再入力を促す処理.
192				 * 既存から引き継いだ情報の整合性が低すぎるため外しておく.
193				 */
194				// 一致チェック
195				// var confirm = false;
196				// _.each(data.response.docs, function(doc) {
197				// var confAddress = doc.jpc_address_2 + doc.jpc_address_3 +
198				// doc.jpc_address_4;
199				// confAddress = confAddress.replace(/undefined/g, '');
200				//
201				// if (doc.jpc_address_1 === $stateOrRegionElem.val()
202				// && confAddress === $addressLine1Elem.val()) {
203				// confirm = true;
204				// }
205				// });
206				// // 一致する住所が存在すればOK
207				// confirm ? $deferred.resolve() :
208				// $deferred.reject('illegal_address');
209				$deferred.resolve();
210			}).fail(function(error){
211				$deferred.reject(error);
212			});
213		}
214		// 一致判定実施後の処理
215		$deferred.done(function() {
216			$zipElem.data('finding', false);
217			$confirmDeferred.resolve();
218		});
219		$deferred.fail(function(error){
220			$zipElem.data('finding', false);
221			ADSS.Util.showMessageDialog('error', dict.address + dict.search, dict[error]);
222			$confirmDeferred.reject();
223		});
224
225		return $confirmDeferred.promise();
226	};
227	ADSS.EcApp.getAddress = function (zip) {
228
229		var $deferred = $.Deferred();
230		$.ajax({
231			type: 'GET',
232			url: '/zse/select?wt=json&q=' + zip + '*&sort=id+asc&rows=2000',
233			contentType: 'application/json',
234			async: true
235		}).done(function(data, status, xhr) {
236			$deferred.resolve(data);
237		}).fail(function(xhr, status, error) {
238			$deferred.reject('fatal_error');
239		});
240
241		return $deferred.promise();
242	}
243	ADSS.EcApp.directAdRequest = function($form) {
244		if ($form.data('processing')) e.preventDefault();
245		$form.data('processing', true);
246		var email = $form.find('#email').val();
247		var myShop = [];
248		var dmFlag = null;
249		var newNoticeFlag = null;
250		if ($form.find('#dmFlag')[0]) {
251			if ($form.find('#dmFlag').prop("checked")) {
252				dmFlag = '1';
253			} else {
254				dmFlag = '0';
255			}
256		}
257		if ($form.find('#newNoticeFlag')[0]) {
258			if ($form.find('#newNoticeFlag').prop("checked")) {
259				newNoticeFlag = '1';
260			} else {
261				newNoticeFlag = '0';
262			}
263		}
264		if ($("[name^='myShop']")[0]) {
265			$("[name^='myShop']").each(function(i, elem) {
266				myShop.push($(this).val());
267			});
268		} else {
269			myShop = undefined;
270		}
271		var directAdRequests = [];
272
273		$form.find('input[type="checkbox"]').each(function() {
274			if ($(this).attr("id").indexOf("dmFlag") != -1) {
275				return true;	// continue
276			}
277			if ($(this).attr("id").indexOf("newNoticeFlag") != -1) {
278				return true;	// continue
279			}
280			var $this = $(this);
281			directAdRequests.push({
282				directAdMethodId: $this.val(),
283				email: email,
284				myShops: myShop,
285				dmFlag: dmFlag,
286				newNoticeFlag: newNoticeFlag,
287				requestThis: $this.prop('checked')
288			});
289		});
290		ADSS.Util.postAsJSON($form, directAdRequests);
291	};
292	/* ajax as directAdRequest */
293	ADSS.EcApp.ajaxDirectAdRequest = function($elems) {
294		var defer = $.Deferred();
295		if ($elems.data('processing')) return false;
296		$elems.data('processing', true);
297		$('#loading').show();
298		var email = $elems.find('input[type="email"]').val();
299		var myShop = [];
300		if ($("[name^='myShop']")[0]) {
301			$("[name^='myShop']").each(function(i, elem) {
302				myShop.push($(this).val());
303			});
304		} else {
305			myShop = undefined;
306		}
307		var directAdRequests = [];
308		$elems.find('input[type="checkbox"]').each(function() {
309			// クロコレ add start morisada
310			if ($(this).attr("id").indexOf("dmFlag") > 0) {
311				return true;	// continue
312			}
313			// クロコレ add end morisada
314			var $this = $(this);
315			directAdRequests.push({
316				directAdMethodId: $this.val(),
317				email: email,
318				myShops: myShop,
319				requestThis: $this.prop('checked')
320			});
321		});
322		var data = {'data' : JSON.stringify(directAdRequests)};
323		var url  = document.location.protocol + "//" + document.domain + "/ap/api/mag/entry";
324		jQuery.ajax({
325			'data' : data,
326			'url'  : url,
327			'type' : 'post',
328			'dataType' : 'json',
329			'xhrFields' : { withCredentials: true },
330			'crossDomain' : true,
331			'success' : defer.resolve,
332			'error' : defer.reject
333		}).done(function(data) {
334			if (data.success) {
335				$elems.find('.globalErrorSlot').hide();
336				$elems.find('.errorSlot').hide();
337			} else {
338				$elems.find('.globalErrorSlot .errorText').text(data.globalMessage).parent().show();
339				$elems.find('.errorSlot .errorText').text(data.message).parent().show();
340			}
341		}).fail(function(data){
342			console.log(data);
343		}).always(function(data){
344			$elems.data('processing', false);
345			$('#loading').hide();
346		});
347		return defer.promise();
348	};
349	ADSS.EcApp.restockMailRequest = function($form) {
350		if ($form.data('processing')) e.preventDefault();
351		$form.data('processing', true);
352		var email = $form.find('#email').val();
353		var restockMailRequest = {
354			email: email,
355			directAdRequests: []
356		};
357		$form.find('input[type="checkbox"]').each(function() {
358			var $this = $(this);
359			restockMailRequest.directAdRequests.push({
360				directAdMethodId: $this.val(),
361				email: email,
362				requestThis: $this.prop('checked')
363			});
364		});
365		var $variationSelect = $form.find('#variationSelect');
366		if ($variationSelect.size()) {
367			var action = $form.attr('action');
368			actionWithPrvId = action + '&v=' + $variationSelect.val();
369			$form.attr('action', actionWithPrvId);
370		}
371		ADSS.Util.postAsJSON($form, restockMailRequest);
372	};
373	/* same as restockMailRequest */
374	ADSS.EcApp.orderStartMailRequest = function($form) {
375		if ($form.data('processing')) e.preventDefault();
376		$form.data('processing', true);
377		var email = $form.find('#email').val();
378		var restockMailRequest = {
379			email: email,
380			directAdRequests: []
381		};
382		$form.find('input[type="checkbox"]').each(function() {
383			var $this = $(this);
384			restockMailRequest.directAdRequests.push({
385				directAdMethodId: $this.val(),
386				email: email,
387				requestThis: $this.prop('checked')
388			});
389		});
390		var $variationSelect = $form.find('#variationSelect');
391		if ($variationSelect.size()) {
392			var action = $form.attr('action');
393			actionWithPrvId = action + '&v=' + $variationSelect.val();
394			$form.attr('action', actionWithPrvId);
395		}
396		ADSS.Util.postAsJSON($form, restockMailRequest);
397	};
398
399	ADSS.EcApp.submitWithDirectAdRequest = function($form, $checkboxes) {
400		if ($form.data('processing')) e.preventDefault();
401		$form.data('processing', true);
402		var directAdRequests = [];
403		var myShop = [];
404		if ($("[name^='myShop']")[0]) {
405			$("[name^='myShop']").each(function(i, elem) {
406				myShop.push($(this).val());
407			});
408		} else {
409			myShop = undefined;
410		}
411		$checkboxes.each(function() {
412			var $this = $(this);
413			directAdRequests.push({
414				directAdMethodId: $this.val(),
415				myShops: myShop,
416				requestThis: $this.prop('checked')
417			});
418		});
419		$form.find('input[name^="myStoreIds"]').each(function() {
420			var $this = $(this);
421			if ($this.val() != "1") {
422				return true;	// continue
423			}
424			var nameArray = $this.attr("name").split(".");
425			var directAdMethodId = nameArray[1];
426			var shopId = nameArray[2];
427			directAdRequests.push({
428				directAdMethodId: directAdMethodId,
429				shopId: shopId,
430				myShops: myShop,
431				requestThis: true
432			});
433		});
434		if (directAdRequests.length > 0) {
435			$form = $form.append('<input type="hidden" name="data" value="' + _.escape(JSON.stringify(directAdRequests)) + '" />')
436		}
437		$form.submit();
438	};
439	
440		ADSS.EcApp.submitWithDirectAdRequestAndNewNoticeFlag = function($form, $checkboxes, newNoticeFlag) {
441		if ($form.data('processing')) e.preventDefault();
442		$form.data('processing', true);
443		var directAdRequests = [];
444		var myShop = [];
445		var newNoticeFlagVlue = null;
446		if ($("[name^='myShop']")[0]) {
447			$("[name^='myShop']").each(function(i, elem) {
448				myShop.push($(this).val());
449			});
450		} else {
451			myShop = undefined;
452		}
453		if (newNoticeFlag.prop("checked")) {
454			newNoticeFlagVlue = '1';
455		} else {
456			newNoticeFlagVlue = '0';
457		}
458		$checkboxes.each(function() {
459			var $this = $(this);
460			directAdRequests.push({
461				directAdMethodId: $this.val(),
462				myShops: myShop,
463				requestThis: $this.prop('checked')
464			});
465		});
466		$form.find('input[name^="myStoreIds"]').each(function() {
467			var $this = $(this);
468			if ($this.val() != "1") {
469				return true;	// continue
470			}
471			var nameArray = $this.attr("name").split(".");
472			var directAdMethodId = nameArray[1];
473			var shopId = nameArray[2];
474			directAdRequests.push({
475				directAdMethodId: directAdMethodId,
476				shopId: shopId,
477				myShops: myShop,
478				requestThis: true
479			});
480		});
481		if (directAdRequests.length > 0) {
482			$form = $form.append('<input type="hidden" name="data" value="' + _.escape(JSON.stringify(directAdRequests)) + '" />')
483		}
484		$form = $form.append('<input type="hidden" name="newNoticeFlag" value="' + newNoticeFlagVlue + '"/>')
485		$form.submit();
486	};
487
488})();
489
490$(function() {
491	$('a[href^="javascript:"][href*=".submit()"]').on('click', function(e) {
492		var $a = $(this);
493		if ($a.data('processing')) e.preventDefault();
494		$a.data('processing', true);
495	});
496});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.