PageSourceSearch

https://www.regal.co.jp/cms/js/smz_ma.js

js regal.co.jp collected 2026-10-02 02:27:52 UTC 33,299 bytes, 1,062 lines download raw bytes

1/*
2  SiteMiraiZの外部サイトへ計測タグを貼る
3  <script src="//www.example.com/cms/js/smz_ma.js" charset="UTF-8" defer></script>
4  <script>__smz_ma={'hostname':'www.example.com','top_url':'/'};</script>
5	hostname : SiteMiraiZサイトのホスト名(必須)
6	top_url  : SiteMiraiZサイトのトップページの相対URL(必須)
7	is_internal : 内部サイトか(デフォルト:false)
8	bgcolor  : 転送待ちの背景色(デフォルト:#fff)
9 */
10(function() {
11	"use strict";
12	// 必須設定
13	const TRANSFER_PARAMETER = '___smz_tr';
14	const COOKIE_KEY = '__smz_ma';
15	const SESSION_COOKIE_KEY = '__smz_session';
16	const COOKIE_VALUE_LENGTH = 32;
17	const EXTERNAL_KEY = '__smz_external';
18	const OVERLAY_ID = '___smz_overlay';
19	const OVERLAY_BACKGROUND_COLOR = (__smz_ma.bgcolor ? __smz_ma.bgcolor : '#000'); 
20	const HAS_SESSION = hasCookieItem(SESSION_COOKIE_KEY);
21	const CONTENT_ID = '__smz_content';
22	const CONTENT_CLOSE_ID = '__smz_content_close';
23	const CONTENT_BACK_DARK_ID = '__smz_fade_layer';
24	const SCRIPT_START_DATETIME = new Date();
25	
26	// 状態取得
27	let isPreview = false;
28
29	// bodyのcssのoverflow保存用
30	let bodyOriginalOverflow = "";
31	
32	// クローズ状態取得(ブラウザバックで2回表示される対策)
33	let isClose = false;
34	
35	// メインメソッド
36	main();
37	
38	// メインメソッド(本体)
39	function main() {
40		
41		// 起動前チェック
42		if (!validateOptions()) return;
43		
44		// イベント登録
45        if (document.readyState == 'loading' || document.readyState == 'interactive') {
46            document.addEventListener('DOMContentLoaded', initializePageTransition);
47            document.addEventListener('DOMContentLoaded', initializeExternalForm);
48        } else {
49            initializePageTransition();
50            initializeExternalForm();
51        }
52
53		// 転送読み込み表示
54		showOverlay();
55
56		// プレビュー用パラメータ取得
57		const hashParameters = getHashParameters();
58		isPreview = (hashParameters && hashParameters.attend_hash);
59		
60		// クッキー取得/生成
61		const cookieValue = getCookieKey(hashParameters);
62		
63		// 転送設定があれば転送
64		if (transfer(cookieValue)) return;
65		
66		// 外部ならばMAリクエスト送信
67		if (isExternal()) {
68			// アクセス送信
69			loadAccessImage(cookieValue);
70			// リンクにクッキーパラメータ付与
71			attachCookieParameter(cookieValue);
72		}
73		
74		// 接客コンテンツを取得
75		loadAttendContent(cookieValue, hashParameters);
76		if (isPreview) {
77			// プレビュー表示
78			showAttendPreviewToast(cookieValue);
79		}
80		
81	}
82	
83	function validateOptions() {
84		if (typeof __smz_ma === 'undefined' || !__smz_ma) {
85			console.warn('SiteMiraiZ計測タグ(__smz_ma)を定義してください。')
86			return false;
87		}
88		if (!__smz_ma.hostname) {
89			console.warn('SiteMiraiZ計測タグにホスト名(hostname)を定義してください。')
90			return false;
91		}
92		if (!__smz_ma.top_url) {
93			console.warn('SiteMiraiZ計測タグにトップページの相対URL(top_url)を定義してください。')
94			return false;
95		}
96		return true;
97	}
98	
99	function isExternal() {
100		if (__smz_ma.is_internal) return false;
101		if (document.location.hostname === __smz_ma.hostname) return false;
102		if (document.location.hostname.indexOf(__smz_ma.top_url) === 0) return false;
103		return true;
104	}
105	
106	// ハッシュからクエリパラメータを取得(プレビュー用)
107	function getHashParameters() {
108		const hashParameters = new Object;
109		if (!document.location.hash) {
110			return hashParameters;
111		}
112		const pairs = location.hash.substring(1).split('&');
113		for(let i = 0; i < pairs.length; i++) {
114			const keyValue = pairs[i].split('=');
115			if (keyValue.length < 2) {
116				hashParameters[keyValue[0]] = true;
117			} else {
118				hashParameters[keyValue[0]] = keyValue[1];
119			}
120		}
121		return hashParameters;
122	}
123	
124	// クッキー生成・更新
125	function getCookieKey(hashParameters) {
126		
127		// 有効期限
128		const expired = new Date();
129		expired.setYear(expired.getFullYear() + 2);
130		
131		let cookieValue;
132		if (hashParameters && hashParameters[COOKIE_KEY]) {
133			// プレビューCookie
134			cookieValue = hashParameters[COOKIE_KEY];
135			return cookieValue;
136		}
137		if (!cookieValue) {
138			// Cookieから値を取得
139			cookieValue = getCookieItem(COOKIE_KEY);
140		}
141		if (!cookieValue) {
142			// 値を生成
143			cookieValue = '';
144			while (cookieValue.length < COOKIE_VALUE_LENGTH) {
145				cookieValue += Math.random().toString(36).substring(2);
146			}
147			cookieValue = cookieValue.substring(0, COOKIE_VALUE_LENGTH);
148		}
149		// Cookieに値を保存
150		setCookieItem(COOKIE_KEY, cookieValue, expired, '/', document.location.hostname, false);
151		
152		if (!HAS_SESSION) {
153			setCookieItem(SESSION_COOKIE_KEY, 1, null, '/', document.location.hostname, false);
154		}
155		
156		return cookieValue;
157	}
158	
159	// アクセス送信
160	function loadAccessImage(cookieValue) {
161		let link = '//' + __smz_ma.hostname + __smz_ma.top_url + 'ma.png';
162		link += '?' + COOKIE_KEY + '=' + cookieValue;
163		if (isExternal()) link += "&" + EXTERNAL_KEY + "=1";
164		if (!HAS_SESSION) link += "&" + SESSION_COOKIE_KEY + "=1";
165		link += '&url=' + encodeURIComponent( document.location.href );
166		link += '&referer=' + encodeURIComponent( document.referrer );
167		link += '&title=' + encodeURIComponent( document.title );
168		const image = new Image();
169		image.onerror = hideOverlay;
170		image.src = link;
171	}
172	
173	function loadAttendContent(cookieValue, hashParameters) {
174		let link = '//' + __smz_ma.hostname + __smz_ma.top_url + 'attend.json';
175		link += '?' + COOKIE_KEY + '=' + cookieValue;
176		if (isExternal()) link += "&" + EXTERNAL_KEY + "=1";
177		link += '&url=' + encodeURIComponent(
178			document.location.protocol + '//' + document.location.hostname
179			 + document.location.pathname + document.location.search
180		);
181		if (hashParameters && hashParameters.attend_hash) {
182			link += '&attend_hash=' + hashParameters.attend_hash;
183		}
184		link += '&__t=' + (new Date()).getTime().toString();
185		
186		const request = new XMLHttpRequest();
187		request.addEventListener('load', showAttendContent);
188		request.open('GET', link);
189		request.responseType = 'json';
190		request.send();
191	}
192	
193	// テンプレート設定
194	function showAttendContent() {
195		if (!this.response) return;
196
197		let json;
198		if (typeof(this.response) == 'object') {
199			json = this.response;
200		} else {
201			json = JSON.parse(this.response);
202		}
203		if (json.length == 0) return;
204		
205		const content = json[0];
206		if (!content) return;
207		if (!content.content_type) return;
208		switch(content.content_type) {
209			case 'insert' :
210				showAttendContentInsert(content);
211				break;
212			case 'popup' :
213				showAttendContentPopup(content);
214				break;
215		}
216	}
217	
218	function showAttendContentInsert(content) {
219		if (!content.target_selector) {
220			content.target_selector = 'body';
221			content.position = 'child-last';
222		}
223		const target = document.querySelector(content.target_selector);
224		if (!target) return;
225		
226		const node = document.createElement('div');
227		node.id = CONTENT_ID;
228		node.innerHTML += content.html;
229		if (!isPreview) {
230			node.addEventListener('click', clickNode);
231			function clickNode() {
232				sendAttendReact(getCookieItem(COOKIE_KEY), content.attend_hash, 'click');
233				node.removeEventListener('click', clickNode);
234			}
235		}
236		node.insertBefore(getCloseButton(content), node.firstChild);
237		
238		switch(content.position) {
239			case 'before' : // 基準要素の前
240				target.parentElement.insertBefore(node, target);
241				break;
242			case 'after' : // 基準要素の後
243				if (target.nextElementSibling) {
244					target.parentElement.insertBefore(node, target.nextElementSibling);
245				} else {
246					target.parentElement.appendChild(node);
247				}
248				break;
249			case 'child-first' : // 基準要素の子(最初)
250				target.insertBefore(node, target.firstChild);
251				break;
252			case 'child-last' : // 基準要素の子(最後)
253				target.appendChild(node);
254				break;
255		}
256		
257		let contentWidth;
258		if (content.width) {
259			if (content.width.match(/^\d+(px|%)$/)) {
260				contentWidth = content.width;
261			} else if (content.width.match(/^\d+$/)) {
262				contentWidth = content.width + 'px';
263			}
264		}
265		
266		// 表示位置
267		const styles = [];
268		styles.push('position: relative;');
269		if (contentWidth) {
270			styles.push('width: ' + contentWidth + ' !important;');
271		}
272		const styleText = '#' + CONTENT_ID + ' {' + styles.join('') + '}';
273		const styleElement = document.createElement('style');
274		styleElement.appendChild(
275			document.createTextNode(styleText)
276		);
277		document.head.appendChild(styleElement);
278		
279		if (!isPreview) {
280			sendAttendReact(getCookieItem(COOKIE_KEY), content.attend_hash, 'view');
281		}
282	}
283	
284	function showAttendContentPopup(content) {
285
286		if (bodyOriginalOverflow==""){
287			bodyOriginalOverflow = document.body.style.getPropertyValue('overflow');
288		}
289
290		const node = document.createElement('div');
291		node.id = CONTENT_ID;
292		node.innerHTML = content.html;
293		node.style.setProperty('display', 'none');
294		if (!isPreview) {
295			node.addEventListener('click', clickNode);
296			function clickNode() {
297				sendAttendReact(getCookieItem(COOKIE_KEY), content.attend_hash, 'click');
298				node.removeEventListener('click', clickNode);
299			}
300		}
301		document.body.appendChild(node);
302		
303		// 待機時間
304		if (content.start || content.start === 0) {
305			setShowScroll();
306		} else {
307			setTimeout(showNode, getWaitMilliseconds(SCRIPT_START_DATETIME));
308		}
309		
310		function setShowScroll() {
311			if (!content.target_selector) {
312				content.target_selector = 'body';
313			}
314			const target = document.querySelector(content.target_selector);
315			if (!target) return;
316			
317			if (content.start.indexOf('%') > 0) {
318				content.startPercentage = parseFloat(content.start.substring(0, content.start.indexOf('%')));
319			} else if (content.start.indexOf('px') > 0) {
320				content.startPixel = parseInt(content.start.substring(0, content.start.indexOf('px')));
321			} else if (content.start.match(/^\d+$/)) {
322				content.startPixel = content.start;
323			}
324			
325			// スクロールイベント処理
326			let targetOffsetHeight;
327			let targetRectY;
328			if (content.target_selector == 'body') {
329				targetOffsetHeight = getPageHeight();
330				targetRectY = 0;
331			} else {
332				const targetRect = target.getBoundingClientRect();
333				targetRectY = window.pageYOffset + (!targetRect.y ? targetRect.top : targetRect.y); // IE11対応
334				targetOffsetHeight = target.offsetHeight;
335			}
336			pageScroll();
337			document.addEventListener('scroll', pageScroll);
338			function pageScroll() {
339				const scrollPositionY = window.pageYOffset + window.innerHeight;
340				if (content.startPercentage || content.startPercentage === 0) {
341					const viewPercentage = parseInt((scrollPositionY - targetRectY) / targetOffsetHeight * 100);
342					if (viewPercentage < content.startPercentage) return;
343				}
344				if (content.startPixel || content.startPixel === 0) {
345					const viewPixel = (scrollPositionY - targetRectY);
346					if (viewPixel < content.startPixel) return;
347				}
348				document.removeEventListener('scroll', pageScroll);
349				setTimeout(showNode, getWaitMilliseconds(new Date()));
350			}
351            
352		}
353		
354		function showNode() {
355			
356			// 一度閉じている場合は再表示しない(ブラウザバック・更新対策)
357			if (isClose) return;
358
359			// 表示エフェクト
360			switch(content.show_effect) {
361				case 'immediate':
362					break;
363				case 'fade-in':
364					showEffectFadeIn();
365					break;
366				case 'back-dark':
367					showEffectBackDark();
368					break;
369			}
370			
371			// 閉じるボタン追加
372			node.insertBefore(getCloseButton(content), node.firstChild);
373
374			// 表示位置
375			const styles = [];
376			styles.push('display: block;');
377			styles.push('position: fixed;');
378			if (content.width) {
379				styles.push('width: ' + content.width + ' !important;');
380			}
381			let paddingPx;
382			if (content.width.indexOf('%') == content.width.length - 1) {
383				paddingPx = '0px';
384			} else {
385				paddingPx = '20px';
386			}
387			styles.push('bottom: ' + paddingPx + ';');
388			switch(content.position) {
389				case 'center-bottom' : // 中央下
390					styles.push('left: 50%;');
391					styles.push('transform: translateX(-50%);');
392					break;
393				case 'right-bottom' : // 右下
394					styles.push('right: ' + paddingPx + ';');
395					break;
396				case 'left-bottom' : // 左下
397					styles.push('left: ' + paddingPx + ';');
398					break;
399			}
400			const styleText = '#' + CONTENT_ID + ' {' + styles.join('') + '}';
401			const styleElement = document.createElement('style');
402			styleElement.appendChild(
403				document.createTextNode(styleText)
404			);
405			document.head.appendChild(styleElement);
406
407			// 暗くする背景を表示する
408			let backDiv = document.querySelector("#" + CONTENT_BACK_DARK_ID);
409			if (backDiv) {
410				document.body.style.setProperty('overflow', 'hidden');
411				backDiv.style.setProperty('display', 'block');
412			}
413
414			// コンテンツを表示する
415			node.style.setProperty('display', 'block');
416			if (!isPreview) {
417				sendAttendReact(getCookieItem(COOKIE_KEY), content.attend_hash, 'view');
418			}
419				
420			// 表示継続時間
421			const showMilliseconds = (content.show_second ? content.show_second * 1000 : 0);
422			if (showMilliseconds) {
423				setTimeout(hideNode, showMilliseconds);
424			}
425		}
426		
427		function showEffectFadeIn() {
428			// 読み込みアニメーション
429			const keyframes = '@keyframes fade-in {' + [
430				'0% { opacity : 0 }',
431				'100% { opacity : 2 }'
432			].join('') + '}';
433			const keyframeStyle = document.createElement('style');
434			keyframeStyle.appendChild(
435				document.createTextNode(keyframes)
436			);
437			document.head.appendChild(keyframeStyle);
438			node.style.setProperty('animation', 'fade-in 2s');
439		}
440		
441		function showEffectBackDark() {
442
443			let backDiv = document.querySelector("#" + CONTENT_BACK_DARK_ID);
444			if (!backDiv) {
445				const fadeStyleText = "#" + CONTENT_BACK_DARK_ID + " { position:absolute;  top:0px;  left:0px;  width:100%;  height:" + getPageHeight() + "px;  background-color:#000000;  opacity:0.5;  z-index:100000; }";
446				const fadeStyle = document.createElement('style');
447				fadeStyle.appendChild(
448					document.createTextNode(fadeStyleText)
449				);
450
451				const fadeDiv = document.createElement('div');
452				fadeDiv.setAttribute("id", CONTENT_BACK_DARK_ID);
453
454				document.body.appendChild(fadeStyle);
455				document.body.appendChild(fadeDiv);
456
457				//backDiv = fadeDiv;
458			}
459
460			//backDiv.style.setProperty('display', 'block');
461			node.style.setProperty('z-index', '100001');
462		}
463		
464		function hideNode() {
465
466			document.body.style.setProperty('overflow', bodyOriginalOverflow);
467			const target = document.querySelector("#" + CONTENT_BACK_DARK_ID);
468			if (target) {
469				target.style.setProperty('display', 'none');
470			}
471
472			node.style.setProperty('display', 'none');
473		}
474		
475		function getWaitMilliseconds(startDateTime) {
476			// 待機時間の設定があるか
477			const waitMilliseconds = (content.wait_second ? content.wait_second * 1000 : 0);
478			if (!waitMilliseconds) return 0;
479			
480			// 待機時間・経過時間を比較
481			const currentDateTime = new Date();
482			const elapsedMiliseconds = currentDateTime - startDateTime;
483			if (waitMilliseconds < elapsedMiliseconds) return 0;
484			return (waitMilliseconds - elapsedMiliseconds);
485		}
486
487		function getPageHeight() {
488			return Math.max(
489				document.body.scrollHeight, document.documentElement.scrollHeight,
490				document.body.offsetHeight, document.documentElement.offsetHeight,
491				document.body.clientHeight, document.documentElement.clientHeight
492			);
493		}
494
495	}
496	
497	function getCloseButton(content) {
498		// CSS
499		const styles = [
500			'float: right;',
501			'position: absolute;',
502			'right: 0px;',
503			'top: 0px;',
504			'width: 30px;',
505			'height: 30px;',
506			'line-height: 30px;',
507			'background-color: black;',
508			'color: white;',
509			'font-size: 20px;',
510			'font-weight: bold;',
511			'text-align: center;',
512			'cursor: pointer;'
513		];
514		const styleText = '#' + CONTENT_CLOSE_ID + ' {' + styles.join('') + '}';
515		const styleElement = document.createElement('style');
516		styleElement.appendChild(
517			document.createTextNode(styleText)
518		);
519		document.head.appendChild(styleElement);
520		
521		// ボタン
522		const button = document.createElement('span');
523		button.id = CONTENT_CLOSE_ID;
524		button.textContent = '×';
525		button.addEventListener('click', function(e) {
526			clickCloseHandler(e);
527			return;
528		});
529
530		const backDarkContent = document.querySelector("#" + CONTENT_BACK_DARK_ID);
531		if (backDarkContent) {
532			backDarkContent.addEventListener('click', function(e) {
533				clickCloseHandler(e);
534				return;
535			});
536		}
537
538
539		function clickCloseHandler(e) {
540			e.preventDefault();
541			e.stopPropagation();
542
543			isClose = true;
544
545			if (!isPreview) {
546				sendAttendReact(getCookieItem(COOKIE_KEY), content.attend_hash, 'close');
547			}
548			const attendContent = document.getElementById(CONTENT_ID);
549			if (!attendContent) return;
550			attendContent.style.setProperty('display', 'none');
551
552			document.body.style.setProperty('overflow', bodyOriginalOverflow);
553			const target = document.querySelector("#" + CONTENT_BACK_DARK_ID);
554			if (target) {
555				target.style.setProperty('display', 'none');
556			}
557
558			return;
559		}
560
561		return button;
562	}		
563	
564	function sendAttendReact(cookieValue, attendHash, action) {
565		
566		const url = '//' + __smz_ma.hostname + __smz_ma.top_url + 'attend_react';
567		const data = new FormData();
568		data.append(COOKIE_KEY, cookieValue);
569		if (isExternal()) { data.append(EXTERNAL_KEY, "1"); }
570		data.append('attend_hash', attendHash);
571		data.append('action', action);
572		data.append('__t', (new Date()).getTime().toString());
573		
574		if (navigator && navigator.sendBeacon) {
575			navigator.sendBeacon(url, data);
576			return;
577		} else {
578			const request = new XMLHttpRequest();
579			request.open('POST', url);
580			request.responseType = 'json';
581			request.send(data);
582		}
583	}	
584	
585	function showAttendPreviewToast(cookieValue) {
586		
587		const TOAST_ID = '__smz_ma_preview';
588		
589		// CSS
590		const styles = [
591			'position: fixed;',
592			'top: 10px;',
593			'right: 10px;',
594			'line-height: 40px;',
595			'padding: 5px 15px;',
596			'background-color: #1E96C8;',
597			'color: #fff;',
598			'opacity: 0.5;',
599			'z-index: 100000;'
600		];
601		const styleText = '#' + TOAST_ID + ' {' + styles.join('') + '}';
602		const styleElement = document.createElement('style');
603		styleElement.appendChild(document.createTextNode(styleText));
604		styleElement.appendChild(document.createTextNode('#' + TOAST_ID + ':hover { opacity : 1; }'));
605		document.head.appendChild(styleElement);		
606		
607		const toast = document.createElement('div');
608		toast.id = TOAST_ID
609		toast.textContent = '接客プレビュー中';
610		document.body.appendChild(toast);
611		
612		toast.appendChild(getLogoutButton());
613		
614		function getLogoutButton() {
615			
616			const TOAST_LOGOUT_ID = '__smz_ma_preview_logout';
617			
618			// CSS
619			const styles = [
620				'height: 30px;',
621				'line-height: 30px;',
622				'background-color: #777;',
623				'color: white;',
624				'text-align: center;',
625				'cursor: pointer;',
626				'padding: 3px 10px;',
627				'margin-left: 10px;',
628				'border-radius: 5px;'
629			];
630			const styleText = '#' + TOAST_LOGOUT_ID + ' {' + styles.join('') + '}';
631			const styleElement = document.createElement('style');
632			styleElement.appendChild(
633				document.createTextNode(styleText)
634			);
635			document.head.appendChild(styleElement);
636			
637			// ボタン
638			const button = document.createElement('span');
639			button.id = TOAST_LOGOUT_ID;
640			button.textContent = '終了';
641			button.addEventListener('click', function(e) {
642				e.preventDefault();
643				e.stopPropagation();
644				
645				let link = '//' + __smz_ma.hostname + __smz_ma.top_url + 'attend_preview_end';
646				link += '?' + COOKIE_KEY + '=' + cookieValue;
647				if (isExternal()) link += "&" + EXTERNAL_KEY + "=1";
648				link += '&__t=' + (new Date()).getTime().toString();
649				
650				const request = new XMLHttpRequest();
651				request.addEventListener('load', function(e) {
652					const newUrl = document.location.protocol + '//'
653								+ document.location.hostname 
654								+ document.location.pathname 
655								+ document.location.search;
656					const newWindow = window.open(newUrl, window.name + '_logout' + (new Date()).getTime().toString());
657					window.close();
658					newWindow.focus();
659				});
660				request.addEventListener('error', function(e) {});
661				request.open('GET', link);
662				request.responseType = 'json';
663				request.send();
664				return;
665			});
666			return button;
667		}
668	}
669	
670	// リンクにクッキーパラメータ付与
671	function attachCookieParameter(cookieValue) {
672		const topDirs = __smz_ma.top_url.split('/');
673		const anchors = document.querySelectorAll('a');
674		for (let i = 0; i < anchors.length; i++) {
675			const anchor = anchors[i];
676			const href = anchor.href;
677			if (href.indexOf('/') === -1) continue;
678			const parts = href.split('/');
679			if (__smz_ma.hostname != parts[2]) continue;
680			
681			let anchorIndex = 3;
682			let isMatch = true;
683			for (let topDirIndex = 1; topDirIndex < topDirs.length; topDirIndex++) {
684				if (!topDirs[topDirIndex] || topDirs[topDirIndex] == parts[anchorIndex]) {
685					anchorIndex++;
686					continue;
687				}
688				isMatch = false;
689				break;
690			}
691			if (!isMatch) continue;
692			
693			anchor.href = anchor.href 
694						+ (anchor.href.indexOf('?') === -1 ? '?' : '&')
695						+ COOKIE_KEY + '=' + cookieValue;
696		}
697	}
698	
699	function transfer(cookieValue) {
700		if (document.location.search.indexOf('?' + TRANSFER_PARAMETER + '=') === -1 && 
701			document.location.search.indexOf('&' + TRANSFER_PARAMETER + '=') === -1 ) return false;
702		const regex = new RegExp('(\\?|&)' + TRANSFER_PARAMETER + '=([^\\?&=]*)(&|$)');
703		const match = document.location.search.match(regex);
704		if (!match || match.length < 3) {
705			hideOverlay();
706			return true;
707		}
708		let transferUrl = decodeURIComponent(match[2]);
709		const urlRegex = new RegExp('https?://' + __smz_ma.hostname + __smz_ma.top_url + '.*');
710		if (!transferUrl.match(urlRegex)) {
711			hideOverlay();
712			return false;
713		}
714		document.location.href = transferUrl
715								+ (transferUrl.indexOf('?') === -1 ? '?' : '&')
716								+ COOKIE_KEY + '=' + cookieValue;
717		return true;
718	}
719
720	function showOverlay() {
721		
722		// URLチェックのみで即表示
723		if (document.location.search.indexOf('?' + TRANSFER_PARAMETER + '=') === -1 && 
724			document.location.search.indexOf('&' + TRANSFER_PARAMETER + '=') === -1 ) return;
725
726		// 網掛け
727		const overlay = document.createElement('div');
728		overlay.id = OVERLAY_ID;
729		overlay.style.position = 'fixed';
730		overlay.style.top = 0;
731		overlay.style.left = 0;
732		overlay.style.zIndex = 1000;
733		overlay.style.width = '100%';
734		overlay.style.height = '100%';
735		overlay.style.backgroundColor = '#fff'; // 異常値対策
736		overlay.style.backgroundColor = OVERLAY_BACKGROUND_COLOR;
737		overlay.style.opacity = 0.3;
738		overlay.style.visibility = 'visible';
739		overlay.style.transition = '.3s linear';
740
741		// 読み込みイメージ
742		const indicator = document.createElement('div');
743		indicator.style.border = '16px solid #f3f3f3'; /* Light grey */
744		indicator.style.borderTop = '16px solid #3498db'; /* Blue */
745		indicator.style.borderRadius = '50%';
746		indicator.style.width = '120px';
747		indicator.style.height = '120px';
748		indicator.style.animation = 'request-indicator 2s linear infinite';
749		indicator.style.position = 'absolute';
750		indicator.style.top = 'calc( 50% - 60px )';
751		indicator.style.left = 'calc( 50% - 60px )';
752		overlay.appendChild(indicator);
753
754		// 読み込みアニメーション
755		const keyframes = '@keyframes request-indicator {' + [
756			'0% { transform: rotate(0deg); } ',
757			'100% { transform: rotate(360deg); }'
758		].join('') + '}';
759		const keyframeStyle = document.createElement('style');
760		keyframeStyle.appendChild(
761			document.createTextNode(keyframes)
762		);
763
764		const heads = document.getElementsByTagName('head');
765		if (heads && heads.length > 0) {
766			heads[0].appendChild(keyframeStyle);
767			document.body.appendChild(overlay);
768		}
769	}
770	
771	function hideOverlay() {
772		const overlay = document.getElementById(OVERLAY_ID);
773		if (!overlay) return;
774		overlay.parentNode.removeChild(overlay);
775	}
776	
777	function findAncestorByClassName(element, className) {
778		let e = element;
779		while(!e.classList.contains(className)) {
780			e = e.parentElement;
781			if (e.tagName.toLowerCase() == 'body') {
782				e = null;
783				break;
784			}
785		}
786		return e;
787	}
788
789
790	//-------------------------------------------
791	// ページ遷移処理
792	//-------------------------------------------
793	function initializePageTransition() {
794		
795		// 滞在開始時間
796		let pageViewStartTime = new Date();
797
798		// スクロール
799		let scrollHeightMax = 0;
800		let scrollPercentageMax = 0;
801		let pageHeight = getPageHeight();
802		let viewHeight = window.innerHeight;
803
804		// スクロールイベント処理
805		pageScroll();
806		document.addEventListener('scroll', function(ev) {
807			pageScroll(); 
808		});
809		function pageScroll() {
810			let scrollHeight = window.pageYOffset;
811			
812			if (scrollHeight > 0) { scrollHeight += viewHeight; }
813			let scrollPercentage = parseInt((scrollHeight / pageHeight) *100);
814			if (scrollPercentage > 100) { scrollPercentage = 100; }
815			
816			if (scrollHeight>scrollHeightMax) { scrollHeightMax = scrollHeight; }
817			if (scrollPercentage>scrollPercentageMax) { scrollPercentageMax = scrollPercentage; }
818		}
819
820
821		// ページ遷移前イベント処理
822		window.addEventListener('pagehide', sendPageTransition);
823		function sendPageTransition() {
824			let pageViewEndTime = new Date();
825			
826			let data = {};
827			data.__smz_ma = getCookieItem(COOKIE_KEY);
828			if (isExternal()) data._smz_external = "1";
829			data.dur      = pageViewEndTime.getTime() - pageViewStartTime.getTime();
830			data.scr      = scrollPercentageMax;
831			data.url      = document.location.href;
832			data.tm       = (new Date()).getTime();
833
834			let link = '//' + __smz_ma.hostname + __smz_ma.top_url + 'pt.json';
835			sendData(link, data);
836		}
837
838		function sendData(url, data) {
839			if ('sendBeacon' in navigator && !isSafari()) {
840				sendDataByBeacon(url, data);
841			}else{
842				sendDataByAjax(url, data);
843			}
844		}
845
846		function sendDataByBeacon(url, data) {
847
848			let dataForm = new FormData();
849			Object.keys(data).forEach(function(key) {
850				dataForm.append(key, data[key]);
851			})
852
853			navigator.sendBeacon(url, dataForm);
854		}
855
856		function sendDataByAjax(url, data) {
857			var xhr = new XMLHttpRequest();
858			xhr.open('POST', url, false);
859			//xhr.responseType = 'text';
860			xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');   
861			xhr.onload = function () {}
862			xhr.onerror = function (e) {}
863			xhr.send(
864				"__smz_ma=" + encodeURIComponent(data.__smz_ma) +
865				"&dur=" + encodeURIComponent(data.dur) +
866				"&scr=" + encodeURIComponent(data.scr) +
867				"&url=" + encodeURIComponent(data.url) +
868				"&tm=" + encodeURIComponent(data.tm)
869			);
870		}
871
872		function getPageHeight() {
873			var myScrollHeight = Math.max(
874				document.body.scrollHeight, document.documentElement.scrollHeight,
875				document.body.offsetHeight, document.documentElement.offsetHeight,
876				document.body.clientHeight, document.documentElement.clientHeight
877			);
878			return myScrollHeight;
879		}
880		
881	}
882
883	//-------------------------------------------
884	// 外部フォーム処理
885	//-------------------------------------------
886	function initializeExternalForm() {
887
888		let link = '//' + __smz_ma.hostname + __smz_ma.top_url + 'fmd.json?tm=' + (new Date()).getTime();
889		getFormDefineByAjax(link);
890
891		function getFormDefineByAjax(url) {
892			var xhr = new XMLHttpRequest();
893			xhr.open('POST', url);
894			xhr.responseType = 'text';
895			xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');   
896			xhr.onload = function () {
897				var json = JSON.parse(xhr.responseText);
898				if (json.url != null) {
899					initialize(json);
900				}
901			};
902			xhr.onerror = function (e) {};
903			xhr.send(
904				"url=" + encodeURIComponent(location.href)
905			);
906		}
907
908		function initialize(formCapture) {
909
910			// イベント(load/submit/unload)のタイミングでフォームデータを取得する
911			if (location.pathname==formCapture.url) {
912				if (formCapture.event=="load") {
913					// loadの場合は、DOMContentLoaded済なので即時
914					getFormData();
915				}else if (formCapture.event=="unload") {
916					// unloadの場合は、iOSを考慮しpagehide
917					window.addEventListener('pagehide', getFormData);
918				}else{
919					// submitの場合は、イベント発生時
920					window.addEventListener(formCapture.event, getFormData);
921				}
922			}
923			function getFormData() {
924
925				let formData = {};
926				const fieldList = formCapture.data;
927
928				fieldList.forEach(function(entity){
929					formData[entity.name] = getFormValue(entity);
930				});
931
932				formData["__smz_ma"] = getCookieItem(COOKIE_KEY);
933				if (isExternal()) formData["__smz_external"] = "1";
934				formData["__smz_form_key"] = formCapture.key;
935				formData["__smz_tm"] = (new Date()).getTime();
936
937				// メールが空の場合は処理を抜ける(URLが同一の確認画面対策)
938				if (formData["mail"]==null || formData["mail"]=="") {
939					return false;
940				}
941
942				// 送信
943				let link = '//' + __smz_ma.hostname + __smz_ma.top_url + 'fmv.json';
944				let data = { "form": JSON.stringify(formData) };
945				sendData(link, data);
946
947				return true;
948			}
949
950			function getFormValue(entity) {
951				let value = null;
952
953				if (entity.method=="name") {
954					let formElem = document.querySelector("[name='" + entity.param + "']");
955					if (formElem!=null) {
956						value = formElem.value;
957					}
958				}
959				else if (entity.method=="id") {
960					let formElem = document.querySelector("#" + entity.param );
961					if (formElem!=null) {
962						value = formElem.value;
963					}
964				}
965				else if (entity.method=="class") {
966					let formElem = document.querySelector("." + entity.param );
967					if (formElem!=null) {
968						value = formElem.value;
969					}
970				}
971				else if (entity.method=="selector") {
972					let formElem = document.querySelector(entity.param );
973					if (formElem!=null) {
974						value = formElem.value;
975					}
976				}
977
978				return value;
979			}
980			
981			function sendData(url, data) {
982				if ('sendBeacon' in navigator && !isSafari()) {
983					sendDataByBeacon(url, data);
984				}else{
985					sendDataByAjax(url, data);
986				}
987			}
988
989			function sendDataByBeacon(url, data) {
990
991				let dataForm = new FormData();
992				Object.keys(data).forEach(function(key) {
993					dataForm.append(key, data[key]);
994				})
995
996				navigator.sendBeacon(url, dataForm);
997			}
998
999			function sendDataByAjax(url, data) {
1000				var xhr = new XMLHttpRequest();
1001				xhr.open('POST', url, false);
1002				//xhr.responseType = 'text';
1003				xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');   
1004				xhr.onload = function () {}
1005				xhr.onerror = function (e) {}
1006				xhr.send(
1007					"form=" + encodeURIComponent(data.form)
1008				);
1009			}
1010
1011		}
1012
1013	}
1014
1015
1016	 /*\
1017	 |*|  based on
1018	 |*|  :: cookies.js ::
1019	 |*|
1020	 |*|  A complete cookies reader/writer framework with full unicode support.
1021	 |*|  https://developer.mozilla.org/en-US/docs/DOM/document.cookie
1022	 \*/
1023	function getCookieItem(sKey) {
1024		if (!sKey || !hasCookieItem(sKey)) { return null; }
1025		return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
1026	}
1027	function setCookieItem(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
1028		if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return; }
1029		var sExpires = "";
1030		if (vEnd) {
1031			switch (vEnd.constructor) {
1032				case Number:
1033					sExpires = vEnd === Infinity ? "; expires=Tue, 19 Jan 2038 03:14:07 GMT" : "; max-age=" + vEnd;
1034					break;
1035				case String:
1036					sExpires = "; expires=" + vEnd;
1037					break;
1038				case Date:
1039					sExpires = "; expires=" + vEnd.toGMTString();
1040					break;
1041			}
1042		}
1043		document.cookie = escape(sKey) + "=" + escape(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
1044	}
1045	function removeCookieItem(sKey, sPath) {
1046		if (!sKey || !hasCookieItem(sKey)) { return; }
1047		document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sPath ? "; path=" + sPath : "");
1048	}
1049	function hasCookieItem(sKey) {
1050		return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
1051	}
1052
1053	 /*\
1054	 |*|  Common Function
1055	 \*/
1056	function isSafari() {
1057 		var ua = navigator.userAgent.toLowerCase();
1058		return ( ua.indexOf('safari')!=-1 && ua.indexOf('chrome')==-1 );
1059	}
1060
1061
1062})()

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.