PageSourceSearch

https://www.pref.fukushima.jp/ssi/js/fontsize.js

js pref.fukushima.jp collected 2026-09-24 18:19:03 UTC 6,887 bytes, 216 lines download raw bytes

1/*
2===========================================================
3フォントサイズ変更スクリプト(タイプC)
4Last Updated:09/21/2001
5
6insomnia!Web Labo.
7http://www3.airnet.ne.jp/insomnia/
8http://www3.airnet.ne.jp/insomnia/labo/fsc/fscC.html
9===========================================================
10*/
11
12/*
13========== ::: 初期設定 ::: ==========
14*/
15
16// 値の単位を設定(必ずダブルクオートかクオートで括る)
17var fontSizeUnit = "%";
18
19// 一回の操作で変化させる値を設定(ダブルクオートやクオートで括らない)
20var perOrder = 20;
21
22// 初期状態の値を設定(ダブルクオートやクオートで括らない)
23var defaultSize = 100;
24
25// クッキーの名前(必ずダブルクオートかクオートで括る)
26var ckName = "ckfontsize";
27
28// クッキーの有効期限(日)(ダブルクオートやクオートで括らない)
29var ckDays = 2;
30
31// クッキーのパス(必ずダブルクオートかクオートで括る。指定が不要の場合は"/"にする)
32var ckPath = "/";
33
34/*
35========== ::: ページ読み込み時の値を設定 ::: ==========
36*/
37
38// クッキー読み出し
39var fsCK = GetCookie( ckName );
40
41if ( fsCK == null ){
42  var currentSize = defaultSize;          //クッキーが無ければ現在の値を初期状態の値に設定
43}
44else{
45  var currentSize = eval( fsCK );          //クッキーがあれば現在の値をクッキーの値に設定
46}
47
48/*
49========== ::: head内にstyle要素を出力 ::: ==========
50*/
51
52currentSize_h1 = currentSize + 50;
53currentSize_h2 = currentSize + 30;
54currentSize_h3 = currentSize + 20;
55currentSize_h4 = currentSize + 10;
56currentSize_h5 = currentSize;
57currentSize_t_h2 = currentSize + 20;
58currentSize_t_h3 = currentSize + 10;
59document.writeln( '<style type="text/css" media="screen,print,tv">' );
60document.write( 'body,th,td{font-size:' + currentSize + fontSizeUnit+ '}' );
61document.write( 'h1{font-size:' + currentSize_h1 + fontSizeUnit+ '}' );
62document.write( 'h2{font-size:' + currentSize_h2 + fontSizeUnit+ '}' );
63document.write( 'h3{font-size:' + currentSize_h3 + fontSizeUnit+ '}' );
64document.write( 'h4{font-size:' + currentSize_h4 + fontSizeUnit+ '}' );
65document.write( 'h5,h6{font-size:' + currentSize_h5 + fontSizeUnit+ '}' );
66document.write( '#mainmenu h2{font-size:' + currentSize_t_h2 + fontSizeUnit+ '}' );
67document.write( '#mainmenu h3,#contentmenu h2,#contentmenu h3{font-size:' + currentSize_t_h3 + fontSizeUnit+ '}' );
68document.writeln( '</style>' );
69
70/*===================================
71  [関数 fsc]
72  引数CMDに渡される値に応じて
73  変更後の値を算出しクッキーに書き込む。
74====================================*/
75
76function fsc( CMD ){
77  // 拡大:現時点の値に一回の操作で変化させる値を加えて操作後の値"newSize"に代入
78  if ( CMD == "larger" ){
79    var newSize = Number( currentSize + perOrder );
80    SetCookie( ckName , newSize );          //クッキー書き込み
81  }
82
83  // 縮小:現時点の値から一回の操作で変化させる値を引き操作後の値に代入
84  // 現時点のサイズの値が一回の操作で変化させる値と同じならそのまま操作後の値に代入
85  if ( CMD == "smaller" ){
86    if ( currentSize != perOrder ){
87      var newSize = Number( currentSize - perOrder );
88      SetCookie( ckName , newSize );          //クッキー書き込み
89    }
90    else{
91      var newSize = Number( currentSize );
92    }
93  }
94
95  // 元に戻す:操作後の値を初期値にする
96  if ( CMD == "default" ){
97    DeleteCookie( ckName );          //クッキー削除
98  }
99
100  // ページの再読み込み
101  // 再読み込みをすることで変更後の値を反映したstyle要素が出力される
102  location.reload();
103}
104
105// _______________________________________ end of function fsc() ___ 
106
107/*===================================
108  [関数 SetCookie]
109  クッキーに値を書き込む
110====================================*/
111function SetCookie( name , value ){
112  var dobj = new Date();
113  dobj.setTime(dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);
114  var expiryDate = dobj.toGMTString();
115  document.cookie = name + '=' + escape(value) + ';expires=' + expiryDate + ';path=' + ckPath;
116
117}
118
119/*===================================
120  [関数 GetCookie]
121  クッキーを取得する
122====================================*/
123function GetCookie (name){
124  var arg  = name + "=";
125  var alen = arg.length;
126  var clen = document.cookie.length;
127  var i = 0;
128  while (i < clen){
129    var j = i + alen;
130    if (document.cookie.substring(i, j) == arg)
131    return getCookieVal (j);
132    i = document.cookie.indexOf(" ", i) + 1;
133    if (i == 0) break;
134  }
135  return null;
136}
137
138/*===================================
139  [関数 getCookieVal]
140  クッキーの値を抽出する
141====================================*/
142function getCookieVal (offset){
143  var endstr = document.cookie.indexOf (";", offset);
144  if (endstr == -1)
145  endstr = document.cookie.length;
146  return unescape(document.cookie.substring(offset,endstr));
147}
148
149/*===================================
150  [関数 DeleteCookie]
151  クッキーを削除する
152====================================*/
153function DeleteCookie(name){
154  if (GetCookie(name)){
155    document.cookie = name + '=' +
156    '; expires=Thu, 01-Jan-70 00:00:01 GMT;path='+ckPath;
157  }
158}
159
160/* FONTタグのサイズなどをスタイル指定に変換する関数(convert_some_tag_to_style)の定義
161 * 2009.07.23 Netcrew N.I追記
162*/
163function convert_some_tag_to_style(){
164	var font_tags = document.getElementsByTagName('font');
165
166	for(i=0,L=font_tags.length;i<L;i++){
167		switch(font_tags[i].getAttribute("size")){
168			case "+3":
169				font_tags[i].style.fontSize=currentSize_h1+fontSizeUnit;
170				break;
171			case "+2":
172				font_tags[i].style.fontSize=currentSize_h2+fontSizeUnit;
173				break;
174			case "+1":
175				font_tags[i].style.fontSize=currentSize_h3+fontSizeUnit;
176				break;
177			case "+0":
178			default:
179				break;
180			case "-1":
181				font_tags[i].style.fontSize=currentSize_h4+fontSizeUnit;
182				break;
183			case "-2":
184				font_tags[i].style.fontSize=currentSize_h5+fontSizeUnit;
185				break;
186			case "-3":
187				font_tags[i].style.fontSize=currentSize_h5+fontSizeUnit;
188				break;
189		}
190			font_tags[i].removeAttribute("size");
191	}
192}
193
194function change_image_init(){
195	try {
196		var img_array = document.getElementsByTagName("img");
197		var img_num = img_array.length;
198		for(var i=0; i < img_num; i++){
199			if(img_array[i].getAttribute("src").match("_off.")){
200				img_array[i].onmouseover = function (){
201					this.setAttribute("src", this.getAttribute("src").replace("off", "hover"));
202				}
203				img_array[i].onmouseout = function() {
204					this.setAttribute("src", this.getAttribute("src").replace("hover", "off"));
205				}
206			}
207		}
208	} catch(e){
209//		alert("test");
210	}
211}
212
213
214window.onload = change_image_init,convert_some_tag_to_style;
215
216//EOF

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.