PageSourceSearch

https://www.nissen.co.jp/res/efs/member/member.js?202609221606

js nissen.co.jp collected 2026-10-01 12:10:16 UTC 9,674 bytes, 378 lines download raw bytes

1/**
2 * 住所検索モジュール
3 */
4var addressSearchModule = (function($){
5	
6	/** 住所検索 */
7	var search = function(args) {
8		$.ajax({
9			url: "/member/address-search",
10			data: {"zipCode": $(args.zipCodeField).val()},
11			type: "GET",
12			dataType: "json",
13			cache: false,
14			success: show(args)
15		})
16	}
17	
18	function show(args) {
19		
20		return function(json) {
21			if(json.error) {
22				var errList = json.error;
23				if(errList.length > 0) {
24					var msg = "<li class='error' name='#zipCode#'>"+ errList[0].errorMessage;
25					msg = msg.replace(/#zipCode#/g, $(args.zipCodeField).attr("id"));
26					$(args.errorField).html(msg);
27					return;
28				}
29			}
30			if(json.data) {
31				$(args.errorField).html("");
32				var addList = json.data;
33				var tag;
34				if(addList.length == 1) {
35					// 住所が特定できる場合
36					tag = createDisplayLabel(addList[0]) + createHiddenTag(addList[0]);
37				}
38				else {
39					// 候補が複数ある場合
40
41					var prevSelectedValue = $('[name=' + args.nameAttr +']').val();
42
43					tag = "住所を選択してください。<br>";
44					for(var i=0, max=addList.length; i<max; i++) {
45						var checked = prevSelectedValue ? (prevSelectedValue == addList[i].joinValue) : (i == 0);
46						tag += createRadioButton(addList[i], checked);
47						tag += createDisplayLabel(addList[i]);
48						tag += "<br>";
49					}
50				}
51				tag = tag.replace(/#userSelectAddress#/g, args.nameAttr);
52				$(args.resultField).html(tag);
53			}
54		}
55		
56	}
57	
58	/** ラベル生成 */
59	var createDisplayLabel = function(address) {
60		var tag = '<label for="address_#value#" >#prefecture#&nbsp;#citytown#</label>';
61		tag = tag.replace(/#value#/g, address.joinValue)
62			.replace(/#prefecture#/g, address.state)
63			.replace(/#citytown#/g, address.city + address.town);
64		return tag;
65	}
66	
67	/** hiddenタグ生成 */
68	var createHiddenTag = function(address) {
69		var tag = "<input type='hidden' name='#userSelectAddress#' value='#value#'>";
70		tag = tag.replace(/#value#/g, address.joinValue);
71		return tag;
72	}
73	
74	/** ラジオボタン生成 */
75	var createRadioButton = function(address,checked) {
76		var tag = "<input type='radio' name='#userSelectAddress#' id='address_#value#' value='#value#' #checked#>";
77		tag = tag.replace(/#value#/g, address.joinValue); 
78		if(checked) {
79			tag = tag.replace(/#checked#/g, "checked='checked'");
80		}
81		else {
82			tag = tag.replace(/#checked#/g, "");
83		}
84		return tag;
85	}
86	
87	// 前回検索時の郵便番号、タイマーIDを記憶しておくためのオブジェクト
88	// (キーは、$(args.zipCodeField).selector)
89	var previousObj = {};
90	var timerIdObj = {};
91
92	/**
93	 * 郵便番号フィールドの監視を開始する。
94	 * @param {Object} args 検索結果情報
95	 *   {
96	 *     zipCodeField: 郵便番号フィールド(jQueryオブジェクト or セレクタ),
97	 *     resultField: 検索結果を表示するフィールド(jQueryオブジェクト or セレクタ),
98	 *     errorField: 検索エラーを表示するフィールド(jQueryオブジェクト or セレクタ),
99	 *     nameAttr: 検索結果を設定する要素名
100	 *   }
101	 * @returns {number} タイマーID
102	 */
103	var startTimer = function(args) {
104		var $zipCodeField = $(args.zipCodeField)
105		var key = $zipCodeField.selector;
106		previousObj[key] = "";
107
108		return timerIdObj[key] = setInterval(function() {
109			var zipCode = $zipCodeField.val();
110			if (zipCode.length == 7) {
111				if(zipCode != previousObj[key]) {
112					previousObj[key] = zipCode;
113					search(args);
114				}
115			}
116			else {
117				previousObj[key] = "";
118				$(args.resultField).html("");
119			}
120		}, 500);
121	}
122
123	/**
124	 * 郵便番号フィールドの監視を終了する。
125	 * @param {number} timerId タイマーID。
126	 *        対象の郵便番号フィールドが $("#zipCode") の場合は省略可能。
127	 */
128	var stopTimer = function(timerId) {
129		if (timerId == null) {
130			timerId = timerIdObj['#zipCode']
131		}
132		clearInterval(timerId);
133	}
134	
135	return {
136		search:search,
137		start:startTimer,
138		stop:stopTimer
139	}
140	
141})(jQuery);
142
143/**
144 * 画像認証モジュール
145 */
146var captchaModule = (function($){
147
148	var reload = function() {
149		var d = new Date();
150		var rand = Math.ceil(Math.random() * (10000 * (Math.random() * 10000000)))
151			+ d.getFullYear().toString()
152			+ (d.getMonth() + 1).toString() 
153			+ d.getDate().toString() 
154			+ d.getHours().toString()
155			+ d.getMinutes().toString()
156			+ d.getSeconds().toString();
157		$('#captcha').attr('src', '/cImg?' + rand);
158	}
159	
160	return {
161		reload:reload
162	}
163	
164})(jQuery);
165
166/**
167 * 購読メール一覧モジュール
168 */
169var incomingMailModule = (function($){
170	
171	var main = function() {
172		subscribe();
173		unsubscribe();
174	}
175	
176	var getMailMagazineIdList = function(obj) {
177		var arr = [];
178		for(var i = 0, max = obj.length; i < max; i++) {
179			// もともと選ばれていた値と変っているものだけを抽出する
180			if (obj[i].value != obj[i].getAttribute('data-pre-value')) {
181				arr.push(obj[i].name);
182			}
183		}
184		return arr;
185	}
186	
187	var subscribe = function() {
188		var list = getMailMagazineIdList($("input:radio[value='1']:checked"));
189		$("input:hidden[name='subscribe']").val(list);
190	}
191	
192	var unsubscribe = function() {
193		var list = getMailMagazineIdList($("input:radio[value='0']:checked"));;
194		$("input:hidden[name='unsubscribe']").val(list);
195	}
196	
197	return {
198		check:main
199	}
200	
201})(jQuery);
202
203/**
204 * 外部ID連携モジュール
205 */
206var externalIdConnectModule = (function($) {
207	/**
208	 * IdPのログインボタン押下時の処理。
209	 * Ajaxで認可URLを取得し、別ウィンドウで開く。
210	 */
211	var authorize = function(idpCode, reauth) {
212		
213		// ポップアップブロック回避のため、先にウィンドウを開いておく
214		var anotherWindow = window.open('about:blank', 'idp-auth');
215
216		var next = $('[name=loginForm] [name=next]').val() || '';
217		if (next === 'undefined') {
218			next = '';
219		}
220
221		$.ajax({
222			url: '/member/external-id-connect',
223			data: {
224				op: 'authorize',
225				idpCode: idpCode,
226				reauth: reauth,
227				next: next
228			}
229		}).done(function(data) {
230			if (data.statusCode != '200') {
231				// 業務エラー画面遷移
232				anotherWindow.close();
233				window.focus();
234				moveTo('/err/business');
235				return;
236			}
237			
238			var url = data.data;
239			
240			if (url === '/') {
241				// ログイン済み→トップページ遷移
242				anotherWindow.close();
243				window.focus();
244				moveTo('/');
245				
246			} else {
247				// IdP認可画面を別ウィンドウで開く
248				 anotherWindow.location.href = url;
249			}
250		}).fail(function() {
251			anotherWindow.close();
252			window.focus();
253			moveTo('/err/business');
254		});
255	};
256	
257	var onCallbackAuthorization = function() {
258		var error = $('#authorization-result-error').val();
259		var redirectTo = $('#authorization-result-redirect-to').val();
260		var param = null;
261		
262		if (error === 'true') {
263			redirectTo = '/member/external-id-connect';
264			param = {
265			    op: 'error',
266			    commonError: $('#authorization-result-message').val()
267			};
268		}
269
270		if (window.opener) {
271			moveTo(redirectTo, param, window.opener);
272		}
273
274		// IEで確認を出さないで閉じる
275		window.open('about:blank', '_self').close();
276	};
277
278	var onAmazonLogin = function() {
279		var error = $('#authorization-result-error').val();
280		var redirectTo = $('#authorization-result-redirect-to').val();
281		var param = null;
282
283		if (error === 'true') {
284			redirectTo = '/member/external-id-connect';
285			param = {
286			    op: 'error',
287			    commonError: $('#authorization-result-message').val()
288			};
289		}
290		moveTo(redirectTo, param, window);
291	};
292
293	/**
294	 * 画面遷移
295	 */
296	function moveTo(url, param, w) {
297		w = w || window;
298		var $ = w.jQuery;
299		
300		if (url.indexOf('?') > 0) {
301			if (url.match(/^(https?:)?\/\//)) {
302				w.location.href = url;
303			} else {
304				w.location.href = '//' + w.location.host + url;
305			}
306			
307		} else {
308			var $form = $('<form />')
309			  .attr('action', url)
310			  .attr('method', param ? 'POST' : 'GET');
311
312			if (param) {
313				$.each(param, function(k, v) {
314					$('<input />')
315						.attr({
316							type: 'hidden',
317							name: k,
318							value: v
319						})
320						.appendTo($form);
321				});
322			}
323
324			$form
325			  .appendTo('body', w)
326			  .trigger('submit')
327			  .remove();
328		}
329	}
330	
331	return {
332		authorize: authorize,
333		onCallbackAuthorization: onCallbackAuthorization,
334		onAmazonLogin: onAmazonLogin
335	};
336})(jQuery);
337
338$(function(){
339	$("#address-search").click(function(){
340		addressSearchModule.search($("#zipCode").val());
341	})
342	function searchAddressByZipCode() {
343		var args = {
344				zipCodeField : $("#zipCode"),
345				resultField  : $("#address-search-result"),
346				errorField   : $("#address-search-error"),
347				nameAttr     : "userSelectAddress"
348		};
349		addressSearchModule.start(args);
350	}
351	$("#zipCode").focus(searchAddressByZipCode);
352	// 初期表示時に郵便番号が設定されている場合は検索を行う(外部ID連携対応)
353	if ($("#zipCode").val()) {
354		searchAddressByZipCode();
355	}
356	$("#zipCode").blur(function(){
357		addressSearchModule.stop();
358	})
359	$(document).ready(function(){
360		captchaModule.reload();
361	})
362	$("#captcha").click(function(){
363		captchaModule.reload();
364	})
365	$("#kakutei").click(function(){
366		incomingMailModule.check();
367	})
368	$("form").submit(function(){
369		$(this).find(":submit").attr("disabled","disabled");
370	});
371	// formがdisabledの状態ではサブミットボタンに設定されたname属性の値が送信されないので、
372	// 汎用フォーム、汎用アンケートでは解除する
373	$("form.general_form, form.survey_form").submit(function(){
374		$(this).find(":submit").removeAttr("disabled");
375	});	
376	// 初期表示時に利用規約の同意チェックを解除する
377	$("[name=termOfServiceForm] [name=agreed]").prop("checked", false);
378});

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.