PageSourceSearch

https://www.town.hirono.fukushima.jp/_template_/_site_/_default_/_res/js/fm_util.js

js town.hirono.fukushima.jp collected 2026-10-02 05:30:35 UTC 3,372 bytes, 113 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";
18
19/*------------------------------------------------------------------------------*/
20var crtSize = defSize;
21function util_init(){
22	//フォント設定が残っていたら反映する
23	var tmp_fs= getCookie(cookie_fs);
24	if (tmp_fs) {
25		crtSize = parseInt(tmp_fs);
26		fsChange(crtSize);
27	}
28
29	//背景設定が残っていたら反映する
30	var tmp_bgid= getCookie(cookie_bgid);
31	var tmp_bgurl= getCookie(cookie_bgurl);
32	if (tmp_bgid && tmp_bgurl) {
33		bgChange(tmp_bgid,tmp_bgurl);
34	}
35}
36
37function getCookie(key){
38	var sCookie = document.cookie;
39	var aData = sCookie.split(";");
40	var oExp = new RegExp(" ", "g");
41	key = key.replace(oExp, ""); 
42	var i = 0;
43	while (aData[i]) {
44		var aWord = aData[i].split("=");
45		aWord[0] = aWord[0].replace(oExp, ""); 
46		if (key == aWord[0]) return unescape(aWord[1]);
47		if (++i >= aData.length) break;
48	}
49	return "";
50}
51
52function setCookie(key,value){
53	var str = key + "=" + escape(value) + ";";
54	str += "path=/;";
55	if (keepdays != 0) {
56		var dt = new Date();
57		dt.setDate(dt.getDate() + parseInt(keepdays));
58		str += "expires=" + dt.toGMTString() + ";";
59	}
60	document.cookie = str;
61}
62
63function deleteCookie(key){
64	var str = key + "=;";
65	str += "path=/;";
66	var dt = new Date();
67	dt.setDate(dt.getDate() -1);
68	str += "expires=" + dt.toGMTString() + ";";
69	document.cookie = str;
70}
71
72function fsChange(arg){
73	//未対応ブラウザ対応
74	if(!document.body){
75		s_message("n_use");
76	}else{
77		//現在のフォントサイズ値を変更
78		if(arg == "d"){
79			crtSize = defSize;
80			deleteCookie(cookie_fs);
81		}
82		else if(arg == "s"){
83			if (parseInt(crtSize) > parseInt(step) ){
84				crtSize -= parseInt(step);
85				setCookie(cookie_fs,crtSize);
86			}
87		}
88		else if(arg == "l"){
89			crtSize += parseInt(step);
90			setCookie(cookie_fs,crtSize);
91		}
92		//フォントサイズを変更
93		document.body.style.fontSize = crtSize + "%";
94	}
95}
96
97function bgChange(node_id,url_id){
98	var target = document.getElementById(node_id);
99	//未対応ブラウザ対応
100	if(!target || !target.cloneNode){
101		s_message("n_use");
102	}else{
103		target.href = eval(url_id);				//CMSでは相対パスでURLを設定するので、毎回パスを受け取りなおします
104		setCookie(cookie_bgurl,url_id);
105		setCookie(cookie_bgid,node_id);
106	}
107}
108
109function s_message(arg){
110	if(arg == "n_use"){
111		alert("お使いのブラウザではこの機能を使用できません");
112	}
113}

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.