PageSourceSearch

https://www.town.nishiaizu.fukushima.jp/ssi/js/fontsize.js

js town.nishiaizu.fukushima.jp collected 2026-10-02 07:10:06 UTC 6,626 bytes, 201 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 = 62.5;
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  if(isNaN(currentSize)){
47	currentSize = defaultSize;
48  }
49}
50
51/*
52========== ::: head内にstyle要素を出力 ::: ==========
53*/
54
55currentSize_h1 = currentSize + 50;
56currentSize_h2 = currentSize + 30;
57currentSize_h3 = currentSize + 20;
58currentSize_h4 = currentSize + 10;
59currentSize_h5 = currentSize;
60currentSize_t_h2 = currentSize + 20;
61currentSize_t_h3 = currentSize + 10;
62document.writeln( '<style type="text/css" media="screen,print,tv">' );
63// document.write( 'body,th,td{font-size:' + currentSize + fontSizeUnit+ '}' );
64document.write( 'html{font-size:' + currentSize + fontSizeUnit+ '}' );
65document.write( 'h1{font-size:' + currentSize_h1 + fontSizeUnit+ '}' );
66document.write( 'h2{font-size:' + currentSize_h2 + fontSizeUnit+ '}' );
67document.write( 'h3{font-size:' + currentSize_h3 + fontSizeUnit+ '}' );
68document.write( 'h4{font-size:' + currentSize_h4 + fontSizeUnit+ '}' );
69document.write( 'h5,h6{font-size:' + currentSize_h5 + fontSizeUnit+ '}' );
70document.write( '#mainmenu h2{font-size:' + currentSize_t_h2 + fontSizeUnit+ '}' );
71document.write( '#mainmenu h3,#contentmenu h2,#contentmenu h3{font-size:' + currentSize_t_h3 + fontSizeUnit+ '}' );
72document.writeln( '</style>' );
73
74/*===================================
75  [関数 fsc]
76  引数CMDに渡される値に応じて
77  変更後の値を算出しクッキーに書き込む。
78====================================*/
79
80function fsc( CMD ){
81  // 拡大:現時点の値に一回の操作で変化させる値を加えて操作後の値"newSize"に代入
82  if ( CMD == "larger" ){
83	var newSize = Number( currentSize + perOrder );
84	SetCookie( ckName , newSize );          //クッキー書き込み
85  }
86
87  // 縮小:現時点の値から一回の操作で変化させる値を引き操作後の値に代入
88  // 現時点のサイズの値が一回の操作で変化させる値と同じならそのまま操作後の値に代入
89  if ( CMD == "smaller" ){
90	if ( currentSize != perOrder ){
91	  var newSize = Number( currentSize - perOrder );
92	  SetCookie( ckName , newSize );          //クッキー書き込み
93	}
94	else{
95	  var newSize = Number( currentSize );
96	}
97  }
98
99  // 元に戻す:操作後の値を初期値にする
100  if ( CMD == "default" ){
101	DeleteCookie( ckName );          //クッキー削除
102  }
103
104  // ページの再読み込み
105  // 再読み込みをすることで変更後の値を反映したstyle要素が出力される
106  location.reload();
107}
108
109// _______________________________________ end of function fsc() ___ 
110
111/*===================================
112  [関数 SetCookie]
113  クッキーに値を書き込む
114====================================*/
115function SetCookie( name , value ){
116  var dobj = new Date();
117  dobj.setTime(dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);
118  var expiryDate = dobj.toGMTString();
119  document.cookie = name + '=' + escape(value) + ';expires=' + expiryDate + ';path=' + ckPath;
120
121}
122
123/*===================================
124  [関数 GetCookie]
125  クッキーを取得する
126====================================*/
127function GetCookie (name){
128  var arg  = name + "=";
129  var alen = arg.length;
130  var clen = document.cookie.length;
131  var i = 0;
132  while (i < clen){
133	var j = i + alen;
134	if (document.cookie.substring(i, j) == arg)
135	return getCookieVal (j);
136	i = document.cookie.indexOf(" ", i) + 1;
137	if (i == 0) break;
138  }
139  return null;
140}
141
142/*===================================
143  [関数 getCookieVal]
144  クッキーの値を抽出する
145====================================*/
146function getCookieVal (offset){
147  var endstr = document.cookie.indexOf (";", offset);
148  if (endstr == -1)
149  endstr = document.cookie.length;
150  return unescape(document.cookie.substring(offset,endstr));
151}
152
153/*===================================
154  [関数 DeleteCookie]
155  クッキーを削除する
156====================================*/
157function DeleteCookie(name){
158  if (GetCookie(name)){
159	document.cookie = name + '=' +
160	'; expires=Thu, 01-Jan-70 00:00:01 GMT;path='+ckPath;
161  }
162}
163
164/* FONTタグのサイズなどをスタイル指定に変換する関数(convert_some_tag_to_style)の定義
165 * 2009.07.23 Netcrew N.I追記
166*/
167function convert_some_tag_to_style(){
168	var font_tags = document.getElementsByTagName('font');
169
170	for(i=0,L=font_tags.length;i<L;i++){
171		switch(font_tags[i].getAttribute("size")){
172			case "+3":
173				font_tags[i].style.fontSize=currentSize_h1+fontSizeUnit;
174				break;
175			case "+2":
176				font_tags[i].style.fontSize=currentSize_h2+fontSizeUnit;
177				break;
178			case "+1":
179				font_tags[i].style.fontSize=currentSize_h3+fontSizeUnit;
180				break;
181			case "+0":
182			default:
183				break;
184			case "-1":
185				font_tags[i].style.fontSize=currentSize_h4+fontSizeUnit;
186				break;
187			case "-2":
188				font_tags[i].style.fontSize=currentSize_h5+fontSizeUnit;
189				break;
190			case "-3":
191				font_tags[i].style.fontSize=currentSize_h5+fontSizeUnit;
192				break;
193		}
194			font_tags[i].removeAttribute("size");
195	}
196}
197
198
199window.onload = convert_some_tag_to_style;
200
201//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.