PageSourceSearch

https://www.unicef.or.jp/js/mode_change.js?20150929

js unicef.or.jp collected 2026-09-24 09:30:06 UTC 2,118 bytes, 75 lines download raw bytes

1// mode_change.js
2
3function load_check(mode_area,mode_btn,redirect_url) {
4	//urlパラメータ取得
5	var param = location.search;
6	//useragent check
7	if ((navigator.userAgent.indexOf('iPhone') > 0 &&
8	navigator.userAgent.indexOf('iPad') == -1) ||
9	navigator.userAgent.indexOf('iPod') > 0 ||
10	navigator.userAgent.indexOf('Android') > 0 && navigator.userAgent.indexOf('Mobile') > 0) {
11	
12		//cookie check
13		if (document.cookie) {
14			var result = 0;
15			var cookies = document.cookie.split("; ");
16			for (var i = 0; i < cookies.length; i++) {
17				var str = cookies[i].split("=");
18				if (str[0] == "view_mode") {
19					result = 1;
20					var cookie_value = unescape(str[1]);
21					if (cookie_value == "PC") {
22						//PC View
23						document.getElementById(mode_btn).style.display='block';
24						document.getElementById(mode_area).style.visibility='visible';
25						return true;
26					}else{
27						//SP Ridirect
28						location.replace(redirect_url + param);
29					}
30				}
31			}
32			if (result == 0) {
33				//SP Ridirect
34				location.replace(redirect_url + param);				
35			}
36		}else{
37			//SP Ridirect
38			location.replace(redirect_url + param);
39		}
40	}else{
41		//PCサイト表示
42		document.getElementById(mode_area).style.visibility='visible';
43		return true;
44	}	
45}
46
47function click_PC(PC_url){
48	var domain = location.hostname;
49	var param = location.search;
50	var result = domain.substring(domain.indexOf(".") + 1, domain.length );
51	set_Cookie('view_mode','PC',result,'/',2);
52	location.replace(PC_url + param);
53}
54
55function click_SP(SP_url){
56	var domain = location.hostname;
57	var param = location.search;
58	var result = domain.substring(domain.indexOf(".") + 1, domain.length );
59	set_Cookie('view_mode','SP',result,'/',2);
60	location.replace(SP_url + param);
61}
62
63function set_Cookie(name, value, domain, path, expireTimes) {
64	
65	str = escape(name) + "=" + escape(value);
66	if (domain != "") str += "; domain=" + domain;
67	if (path != "") str += "; path=" + path;
68	if (expireTimes != "") {
69		expires = new Date((new Date()).getTime() + (60 * 60 * 1000 * expireTimes));
70		str += "; expires=" + expires.toGMTString();
71	}
72
73	document.cookie = str;
74	
75}

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.