PageSourceSearch

https://www.ec-store.net/campaign/asset/js/config.js?20240306

js ec-store.net collected 2026-09-25 18:39:10 UTC 9,795 bytes, 248 lines download raw bytes

1/**
2 * config.js: ver 1.0.7
3 * 全ページ共通(YOU)
4 *
5 * 一時停止, 値の比較
6 * リダイレクト, 404ページ
7 * 日付フォーマット, 時間フォーマット, 時限
8 * URLパラメータをオブジェクト化して返却, URLパラメータを変更(引数で置換), パラメータを取得, URLパラメータを追加 & setQryにネストで変更
9 * 先祖要素の取得
10 * サイドメニューの追加, パンくずの追加, フッターボタンの追加, レコメンド商品の追加, Appバナーの表示
11 *
12 * Last Modified - 2026.03.26
13 * shelpassバナーを非表示
14 */
15(function (global) {
16	'use strict';
17
18	var href			= location.href,
19		pathname		= location.pathname,
20		search			= location.search,
21		hash			= location.hash,
22		device			= Flgs.device;
23
24	var d				= document,
25		main 			= d.querySelector('main.region-main'),
26		root			= d.querySelector('#contents'),
27		bread			= d.querySelector('.site-main'),
28		footer 			= d.querySelector('.contents.footer'),
29		recommend 		= d.querySelector('.contents.recommend'),
30		app 			= d.querySelector('.contents.app');
31
32	var brandObject		= '/campaign/asset/json/brand.json',
33		sideMenuFile 	= '/operation/common/html/pc/leftnavi.html',
34		swsRoot			= '/sws/r/rSWS',
35		errorPage		= '/CustomError/Error404_sws.html';
36
37	var CONFIG			= {
38		// 一時停止
39		sleep: function (e) { return new Promise(function (resolve) { setTimeout(resolve, e) }); },
40		// 値の比較
41		result: function (e) { return (e === null || e === undefined || e === '') ? false : true; },
42		// リダイレクト
43		redirect: function (e) { location.replace(e); },
44		// 404 ページ
45		error: function () { location.replace(errorPage); },
46		// 日付フォーマット
47		formatDate: function () {
48			var date = new Date(), array = [];
49			array[0] = date.getFullYear();
50			array[1] = (date.getMonth() + 1).toString().padStart(2, 0);
51			array[2] = date.getDate().toString().padStart(2, 0);
52			return array.join('');
53		},
54		// 時間フォーマット
55		formatTime: function () {
56			var date = new Date(), array = [];
57			array[0] = date.getHours().toString().padStart(2, 0);
58			array[1] = date.getMinutes().toString().padStart(2, 0);
59			array[2] = date.getSeconds().toString().padStart(2, 0);
60			return array.join('');
61		},
62		// 時限
63		getTimed: function (start, end) {
64			var today = CONFIG.formatDate()+CONFIG.formatTime();
65			return (start <= today && end >= today) ? true : false;
66		},
67		// URLパラメータをオブジェクト化して返却
68		getQry: function () {
69			var obj = {};
70			if (CONFIG.result(search)) {
71				search.substring(1).split('&').forEach(function (e) {
72					obj[e.split('=')[0]] = e.split('=')[1];
73				});
74			}
75			return obj;
76		},
77		// URLパラメータを変更(引数で置換)
78		setQry: function (arg) {
79			search	= CONFIG.result(search) ? search.replace(search, arg) : arg;
80			search	= CONFIG.result(search) ? '?'+search : '';
81			hash	= location.hash ? hash : '';
82			history.replaceState(null, null, pathname+search+hash);
83		},
84		// URLパラメータを取得
85		getSRCH: function (key) {
86			var params = new URLSearchParams(search);
87			return params.get(key);
88		},
89		// URLパラメータを追加 & setQryにネストで変更
90		setSRCH: function (key, val) {
91			var params = new URLSearchParams(search);
92			params.set(key, val);
93			return params.toString();
94		},
95		// 先祖要素の取得
96		closest: function (node, selector) {
97			return (node.closest || function (_selector) {
98				do {
99					if ((node.matches || node.msMatchesSelector).call(node, _selector)) {
100						return node;
101					}
102					node = node.parentElement || node.parentNode;
103				} while (node !== null && node.nodeType === 1);
104				return null;
105			}).call(node, selector);
106		},
107		// サイドメニューの追加
108		setSideMenu: function () {
109			if (!main) return;
110			if (!Flgs.sidemenu) return;
111			if (!(device === 'pc')) return;
112			fetch(sideMenuFile).then(function (r) {
113				return r.text();
114			}).then(function (res) {
115				main.insertAdjacentHTML('beforebegin', '<div class="region-nav" id="leftnavi">'+res+'</div>');
116			}).catch(function (err) {
117				console.error(err);
118			});
119		},
120		// パンくずの追加
121		// フッターボタンの追加
122		setCommonElements: function () {
123			var arr = { format: '', brand: '' };
124			if (CONFIG.result(CONFIG.getSRCH('brand'))) {
125				arr.format = 'full';
126				arr.brand = CONFIG.getSRCH('brand');
127			} else {
128				arr.format = 'short';
129				arr.brand = pathname.split('/').slice(-1)[0].split('_')[0];
130			}
131			fetch(brandObject).then(function (r) {
132				return r.json();
133			}).then(function (res) {
134				CONFIG.setBreadCrumbs(res, arr.format, arr.brand);
135				CONFIG.setFooterButtons(res, arr.format, arr.brand);
136			});
137		},
138		// パンくず
139		setBreadCrumbs: function (arg, format, brand) {
140			if (!bread) return;
141			if (!Flgs.bread) return;
142			var arr = {
143				brandTop: '',
144				brandName: '',
145				breadCrumbs: []
146			};
147			for (var i=0; i<arg.length; i++) {
148				if (brand === arg[i][format]) {
149					arr.brandTop = arg[i].brandtop;
150					arr.brandName = arg[i].brand;
151					break;
152				}
153			}
154			var aspx = pathname.split('/').slice(-1)[0];
155			switch (aspx) {
156				case 'news.aspx':
157					arr.breadCrumbs[0] = {link: swsRoot, text: 'TOP'};
158					arr.breadCrumbs[1] = {link: pathname, text: 'ニュース一覧'};
159					arr.breadCrumbs[2] = CONFIG.result(CONFIG.getSRCH('article')) ? {link: '', text: '詳細'} : '';
160					break;
161				case 'topics.aspx':
162				case 'catalog.aspx':
163					var pageName = aspx.split('.')[0].toUpperCase();
164					arr.breadCrumbs[0] = {link: swsRoot, text: 'TOP'};
165					arr.breadCrumbs[1] = (CONFIG.result(arr.brandTop) && arr.brandTop !== swsRoot) ? {link: arr.brandTop, text: arr.brandName} : {link: '', text: pageName};
166					arr.breadCrumbs[2] = (CONFIG.result(arr.brandTop) && arr.brandTop !== swsRoot) ? {link: '', text: pageName} : '';
167					break;
168				default:
169					arr.breadCrumbs[0] = {link: swsRoot, text: 'TOP'};
170					arr.breadCrumbs[1] = (CONFIG.result(arr.brandTop) && arr.brandTop !== swsRoot) ? {link: arr.brandTop, text: arr.brandName} : {link: '', text: Flgs.title};
171					arr.breadCrumbs[2] = (CONFIG.result(arr.brandTop) && arr.brandTop !== swsRoot) ? {link: '', text: Flgs.title} : '';
172					break;
173			}
174			arr.breadCrumbs = arr.breadCrumbs.filter(function (e) {
175				if (CONFIG.result(e)) return e;
176			});
177
178			var element = d.createElement('ul');
179			element.id = 'bread-clumbs';
180			arr.breadCrumbs.forEach(function (e, i) {
181				if (i === 0) {
182					element.insertAdjacentHTML('beforeend', '<li><a href="'+e.link+'">'+e.text+'</a></li>');
183				} else {
184					if (arr.breadCrumbs.length === (i+1)) {
185						element.insertAdjacentHTML('beforeend', '<li><em>'+e.text+'</em></li>');
186					} else {
187						element.insertAdjacentHTML('beforeend', '<li><a href="'+e.link+'">'+e.text+'</a></li>');
188					}
189				}
190			});
191			if (device === 'pc') {
192				bread.insertAdjacentHTML('afterbegin', '<div class="str-outer of-full"><div class="str-inner">'+element.outerHTML+'</div></div>');
193			} else {
194				bread.insertAdjacentHTML('beforebegin', '<nav class="nav-breadcrumb"><div class="str-outer"><div class="str-inner">'+element.outerHTML+'</div></div></nav>');
195			}
196		},
197		// フッター
198		setFooterButtons: function (arg, format, brand) {
199			if (!footer) return;
200			if (!Flgs.footer) return footer.parentNode.removeChild(footer);
201			for (var i=0; i<arg.length; i++) {
202				var e = arg[i];
203				if (brand === e[format]) {
204					footer.insertAdjacentHTML('beforeend', '<div class="brand">'+
205						(CONFIG.result(e.brandtop) ? '<a href="'+e.brandtop+'" target="_blank">'+e.brand+' トップ</a>' : '')+
206						(CONFIG.result(e.topics) ? '<a href="'+e.topics+'" target="_blank">'+e.brand+' トピックス一覧</a>' : '')+
207					'</div>');
208					break;
209				} else {
210					if (!(arg.length === (i+1))) continue;
211					if (!(footer.children.length === 0)) break;
212					footer.insertAdjacentHTML('beforeend', '<div class="brand">'+
213						(CONFIG.result(arg[0].brandtop) ? '<a href="'+arg[0].brandtop+'" target="_blank">'+arg[0].brand+' トップ</a>' : '')+
214						(CONFIG.result(arg[0].topics) ? '<a href="'+arg[0].topics+'" target="_blank">'+arg[0].brand+' トピックス一覧</a>' : '')+
215					'</div>');
216				}
217			}
218		},
219		// レコメンド商品の追加
220		setRecommends: function () {
221			if (!recommend) return;
222			if (!Flgs.recommend) return recommend.parentNode.removeChild(recommend);
223			if (device === 'pc') {
224				recommend.insertAdjacentHTML('beforeend', '<div class="block-common-title"><span>RECOMMENDS</span></div><ul class="block-thumbnail-t " id="rt_pc_auto_lp_1"></ul>');
225			} else {
226				recommend.insertAdjacentHTML('beforeend', '<div class="str-outer"><div class="str-inner"><div class="str-outer of-type-02"><section class="item-list" id="rt_sp_auto_lp_1"><h2 class="mod-hdgL2 align-center"><span>RECOMMENDS</span></h2></section></div></div></div>');
227			}
228		},
229		// Appバナーの追加
230		// 2026.3.26 ~ appフラグの値に関わらず、バナー非表示、app要素を削除する仕様へ変更。(バナートルツメの指示により)。表示再開に備え、.appの大元の要素生成は据え置き。
231		setAppBanners: function () {
232			if (!app) return;
233			// if (!Flgs.app) return app.parentNode.removeChild(app);
234			return app.parentNode.removeChild(app);
235			// app.insertAdjacentHTML('beforeend', '<div class="shelpass"><a href="https://mypage.baroque.shop/apl/all/?code=sws_lpfooter" target="_blank"><img src="/campaign/asset/img/shelpass.jpg"></a></div>');
236		},
237	};
238	global.CONFIG = CONFIG;
239	return CONFIG;
240})((this || 0).self || global);
241
242/** //////////////////////////////////////// *
243 * 共通項目 - 実行
244 * //////////////////////////////////////// */
245CONFIG.setSideMenu();
246CONFIG.setCommonElements();
247CONFIG.setRecommends();
248CONFIG.setAppBanners();

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.