PageSourceSearch

https://t-shevchenko.name/files/common/jscripts/floatpanel.js

js t-shevchenko.name collected 2026-10-02 11:32:57 UTC 7,013 bytes, 242 lines download raw bytes

1/*************************** Управління видимістю *********************************/
2function ChangeCInl(CInl, VInl, Color) {
3/* private */
4	if (CInl) {
5		ChangeStyle('span', 'class', 'CInl', 'display', 'inline');
6		ChangeStyle('span', 'class', 'CInl', 'background', Color);
7	}
8	else {
9		if (VInl) {
10			ChangeStyle('span', 'class', 'CInl', 'display', 'none');
11			ChangeStyle('span', 'class', 'CInl', 'background', 'inherit');
12		}
13		else {
14			ChangeStyle('span', 'class', 'CInl', 'display', 'inline');
15			ChangeStyle('span', 'class', 'CInl', 'background', 'inherit');
16		}
17	}
18} // ChangeCInl
19
20function ChangeRelDisplay(RelName, Value, Bg, TagName) {
21/* private */
22	ChangeStyle(TagName, 'rel', RelName, 'display', Value);
23	ChangeStyle(TagName, 'rel', RelName, 'background', Bg);
24} // ChangeRelDisplay
25
26function ChangeStyle(TagName, P1Name, P1Value, P2Name, P2Value) {
27/* private */
28var i;
29var P = document.body.getElementsByTagName(TagName);
30	for (i = 0; i < P.length; i++) {
31  	if (P[i].getAttribute(P1Name) == P1Value)
32    	P[i].style[P2Name] = P2Value;
33  }
34} // ChangeStyle
35
36function GetBgColor(Elt) {
37/* private */
38var Bg;
39var P = Elt.parentNode;
40	if (P.currentStyle)
41		Bg = P.currentStyle['backgroundColor'];
42	else if (window.getComputedStyle) {
43		Bg = document.defaultView.getComputedStyle(P, null).getPropertyValue('backgroundColor');
44		if (!Bg)
45			Bg = document.defaultView.getComputedStyle(P, null).getPropertyValue('background-color');
46	}
47	else
48		Bg = '';
49	return Bg;
50} // GetBgColor
51
52function ToggleCanonicStyle(Elt) {
53/* public */
54var Value = (Elt.checked) ? 'thin solid gray' : 'none';
55	ChangeStyle('div', 'class', 'Canonic', 'border', Value);
56} // ToggleCanonicStyle
57
58function ToggleInlineVar() {
59/* public */
60var Value;
61var CInl = document.getElementById('CInl');
62	if(!CInl)
63		return false;
64var VInl = document.getElementById('VInl');
65	if(!VInl)
66		return false;
67	CInl = CInl.checked;
68	VInl = VInl.checked;
69	Value = (VInl) ? 'inline' : 'none';
70	ChangeStyle('span', 'class', 'VInl', 'display', Value);
71	ChangeCInl(CInl, VInl, 'white');
72} // ToggleInlineVar
73
74function ToggleRelDisplay(Elt, AsInline) {
75/* public */
76var RelName = Elt.id;
77var P = (AsInline) ? 'inline' : 'block';
78var Value = (Elt.checked) ? P : 'none';
79var Bg = GetBgColor(Elt);
80	P = (AsInline) ? 'span' : 'p';
81	ChangeRelDisplay(RelName, Value, Bg, P);
82} // ToggleRelDisplay
83
84function ToggleVarEx(ExMode) {
85/* public */
86var CInl, K, R, R1, Value, VInl, VChecked;
87/* Премудрість в тому, що стилі, властивості яких ми хочемо міняти, мусять містити визначення в одній декларації, без повторень:
88Правильно:
89.VInl {background: #CEFFAD; display: none}
90Неправильно:
91.VInl, .V2 {display: none}
92.VInl, .V3 {background: #CEFFAD}
93*/
94	VInl = new Object();
95	CInl = document.getElementById('CInl');
96	if(!CInl)
97		return false;
98	R1 = document.getElementById('VInl');
99	if (R1)
100		VInl['VInl1'] = {Ch : R1.checked,
101										Bg : GetBgColor(R1)};
102	for (K = 2; K <= 9; K++) {
103		R1 = document.getElementById('VInl' + K);
104		if (R1)
105			VInl['VInl' + K] = {Ch : R1.checked,
106											   Bg : GetBgColor(R1)};
107	}
108	if (VInl.length == 0)
109		return false;
110	VChecked = false;
111	for (K in VInl)
112		VChecked = VChecked || VInl[K].Ch;
113	CInl = CInl.checked;
114	for (K in VInl) {
115		Value = (VInl[K].Ch) ? 'inline' : 'none';
116		if (K == 'VInl1')
117			ChangeStyle('span', 'class', 'VInl', 'display', Value);
118		else
119			ChangeStyle('span', 'class', K, 'display', Value);
120	}
121	ChangeCInl(CInl, VChecked, 'rgb(200, 220, 255)');
122	if (ExMode) {
123		for (K in VInl) {
124			if (VInl[K].Ch)
125				ChangeRelDisplay('Var' + K[4], 'block', VInl[K].Bg, 'div');
126			else
127				ChangeRelDisplay('Var' + K[4], 'none', 'inherit', 'div');
128		}
129		if (CInl)
130			ChangeRelDisplay('CInl', 'block', 'rgb(200, 220, 255)', 'div');
131		else {
132			if (VChecked)
133				ChangeRelDisplay('CInl', 'none', 'inherit', 'div');
134			else
135				ChangeRelDisplay('CInl', 'block', 'inherit', 'div');
136		}
137	}
138} // ToggleVarEx
139
140/************************* Управління Cookie ***********************************/
141function GetCookie(c_name) {
142if (document.cookie.length > 0) {
143  c_start=document.cookie.indexOf(c_name + "=");
144  if (c_start!=-1) {
145    c_start=c_start + c_name.length + 1;
146    c_end=document.cookie.indexOf(";",c_start);
147    if (c_end==-1)
148			c_end=document.cookie.length;
149    return unescape(document.cookie.substring(c_start,c_end));
150  }
151}
152return "";
153} // getCookie
154
155function SetCookie(c_name, value) {
156	var d = new Date();
157	d.setTime(d.getTime() + 604800000); // 7 days
158	var expires = d.toUTCString();
159	document.cookie = c_name + "=" + escape(value) + "; path=/; expires=" + expires;
160} // setCookie
161
162function DeleteCookie( name, path, domain ) {
163if ( GetCookie( name ) ) document.cookie = name + "=" +
164( ( path ) ? ";path=" + path : "") +
165( ( domain ) ? ";domain=" + domain : "" ) +
166";expires=Thu, 01-Jan-1970 00:00:01 GMT";
167} // DeleteCookie
168
169/********************************* Плаваюча панель ***************************/
170var FloatPanelActive = 0;
171var FloatPanelPosition = 4;
172
173function DisplayFloatPanel(Position) {
174var FP = document.getElementById('FloatPanel');
175	if (!FP)
176  	return;
177  if (!Position)
178   	Position = Math.abs(FloatPanelPosition);
179	switch (Position) {
180  	case -1:
181    	FloatPanelPosition = -FloatPanelPosition;
182    	FP.style.display = 'none';
183      break;
184    case 1:
185    	FP.style.display = 'block';
186      FloatPanelPosition = 1;
187      FP.style.bottom = 'auto';
188      FP.style.right = 'auto';
189      FP.style.left = '30px';
190      FP.style.top = '30px';
191      break;
192    case 2:
193    	FP.style.display = 'block';
194      FloatPanelPosition = 2;
195      FP.style.bottom = 'auto';
196      FP.style.right = '30px';
197      FP.style.left = 'auto';
198      FP.style.top = '30px';
199      break;
200    case 3:
201    	FP.style.display = 'block';
202      FloatPanelPosition = 3;
203      FP.style.bottom = '30px';
204      FP.style.right = '30px';
205      FP.style.left = 'auto';
206      FP.style.top = 'auto';
207      break;
208    case 4:
209    	FP.style.display = 'block';
210      FloatPanelPosition = 4;
211      FP.style.bottom = '30px';
212      FP.style.right = 'auto';
213      FP.style.left = '30px';
214      FP.style.top = 'auto';
215      break;
216  }
217  SetCookie('FPPos', FloatPanelPosition);
218} // DisplayFloatPanel
219
220var FPBStyle = 'inline';
221
222function InitFloatPanel() {
223	if (!FloatPanelActive)
224		return;
225var FPB = document.getElementById('FPanelBtn');
226	if (FPB)
227		FPB.style.display = FPBStyle;
228
229var FPP = GetCookie('FPPos');
230  if (FPP == '')
231  	FPP = 4;
232  else
233  	FPP = parseInt(FPP);
234  if (FPP > 0)
235	  DisplayFloatPanel(FPP);
236	else {
237		FloatPanelPosition = Math.abs(FPP);
238		DisplayFloatPanel(-1);
239	}
240} // InitFloatPanel
241
242DoLoadFunc = InitFloatPanel;

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.