PageSourceSearch

https://www.city.morioka.iwate.jp/_template_/_site_/_default_/_res/js/fm_util.js

js city.morioka.iwate.jp collected 2026-10-02 05:16:53 UTC 3,859 bytes, 133 lines download raw bytes

1/*------------------------------------------------------------------------------
2    フォントサイズ変更&背景色変更スクリプト CMS連動バージョン
3	[注]CMSテンプレート内に背景色を設定するCSSのURLを設定する必要があります
4--------------------------------------------------------------------------------*/
5
6/* ------ 設定 [共通]------ */
7var uniq_name = "fcmn_";	//クッキー名称の冠[変更可]
8var keepdays = 0;			//クッキーの保存期間[変更可]
9
10/* ------ 設定 [フォントサイズ変更]------ */
11var step = 10;			//このパーセント刻みで文字の大小を変えます[変更可]
12var defSize = 100;		//初期値(パーセント)[変更可]
13var cookie_fs = uniq_name + "fontsize";
14
15/* ------ 設定 [背景色変更]------ */
16var cookie_bgurl = uniq_name + "bgurl";
17var cookie_bgid = uniq_name + "bgid";
18var bgclassmap = {			//背景色クラス定義(CSS統合)
19	"bgcss1": "color-a",
20	"bgcss2": "color-b",
21	"bgcss3": "color-c",
22	"bgcss4": ""
23};
24
25/*------------------------------------------------------------------------------*/
26var crtSize = defSize;
27
28(function(){
29	var $ = FI.jQuery;
30
31	$(function() {
32		//フォント設定が残っていたら反映する
33		var tmp_fs= getCookie(cookie_fs);
34		if (tmp_fs) {
35			crtSize = parseInt(tmp_fs);
36			fsChange(crtSize);
37		}
38
39		//背景設定が残っていたら反映する
40		var tmp_bgid= getCookie(cookie_bgid);
41		var tmp_bgurl= getCookie(cookie_bgurl);
42		if (tmp_bgid && tmp_bgurl) {
43			bgChange(tmp_bgid,tmp_bgurl);
44		}
45	});
46})();
47
48function getCookie(key){
49	var sCookie = document.cookie;
50	var aData = sCookie.split(";");
51	var oExp = new RegExp(" ", "g");
52	key = key.replace(oExp, ""); 
53	var i = 0;
54	while (aData[i]) {
55		var aWord = aData[i].split("=");
56		aWord[0] = aWord[0].replace(oExp, ""); 
57		if (key == aWord[0]) return unescape(aWord[1]);
58		if (++i >= aData.length) break;
59	}
60	return "";
61}
62
63function setCookie(key,value){
64	var str = key + "=" + escape(value) + ";";
65	str += "path=/;";
66	if (keepdays != 0) {
67		var dt = new Date();
68		dt.setDate(dt.getDate() + parseInt(keepdays));
69		str += "expires=" + dt.toGMTString() + ";";
70	}
71	document.cookie = str;
72}
73
74function deleteCookie(key){
75	var str = key + "=;";
76	str += "path=/;";
77	var dt = new Date();
78	dt.setDate(dt.getDate() -1);
79	str += "expires=" + dt.toGMTString() + ";";
80	document.cookie = str;
81}
82
83function fsChange(arg){
84	//未対応ブラウザ対応
85	if(!document.body){
86		s_message("n_use");
87	}else{
88		//現在のフォントサイズ値を変更
89		if(arg == "d"){
90			crtSize = defSize;
91			deleteCookie(cookie_fs);
92		}
93		else if(arg == "s"){
94			if (parseInt(crtSize) > parseInt(step) ){
95				crtSize -= parseInt(step);
96				setCookie(cookie_fs,crtSize);
97			}
98		}
99		else if(arg == "l"){
100			crtSize += parseInt(step);
101			setCookie(cookie_fs,crtSize);
102		}
103		//フォントサイズを変更
104		document.body.style.fontSize = crtSize + "%";
105	}
106}
107
108function bgChange(node_id,url_id){
109	var target = document.getElementById(node_id);
110	//未対応ブラウザ対応
111	if(!target || !target.cloneNode){
112		s_message("n_use");
113	}else{
114		target.href = eval(url_id);				//CMSでは相対パスでURLを設定するので、毎回パスを受け取りなおします
115		setCookie(cookie_bgurl,url_id);
116		setCookie(cookie_bgid,node_id);
117		
118		// bodyクラス切替
119		Object.keys(bgclassmap).forEach(function(key){
120			if(bgclassmap[key]) document.body.classList.remove(bgclassmap[key]);
121		});
122		var theme_class = bgclassmap[url_id] || '';
123		if(theme_class){
124			 document.body.classList.add(theme_class);
125		}
126	}
127}
128
129function s_message(arg){
130	if(arg == "n_use"){
131		alert("お使いのブラウザではこの機能を使用できません");
132	}
133}

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.