PageSourceSearch

https://axeman.su/styles/prosilver/template/forum_fn.js

js axeman.su collected 2026-10-05 00:03:33 UTC 8,731 bytes, 420 lines download raw bytes

1/**
2* phpBB3 forum functions
3*/
4
5/**
6* Window popup
7*/
8function popup(url, width, height, name)
9{
10	if (!name)
11	{
12		name = '_popup';
13	}
14
15	window.open(url.replace(/&/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width);
16	return false;
17}
18
19/**
20* Jump to page
21*/
22function jumpto()
23{
24	var page = prompt(lang.jump_page, on_page);
25
26	if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0)
27	{
28		if (base_url.indexOf('?') == -1)
29		{
30			document.location.href = base_url + '?start=' + ((page - 1) * per_page);
31		}
32		else
33		{
34			document.location.href = base_url.replace(/&/g, '&') + '&start=' + ((page - 1) * per_page);
35		}
36	}
37}
38
39/**
40* Mark/unmark checklist
41* id = ID of parent container, name = name prefix, state = state [true/false]
42*/
43function marklist(id, name, state)
44{
45	var parent = document.getElementById(id);
46	if (!parent)
47	{
48		eval('parent = document.' + id);
49	}
50
51	if (!parent)
52	{
53		return;
54	}
55
56	var rb = parent.getElementsByTagName('input');
57	
58	for (var r = 0; r < rb.length; r++)
59	{	
60		if (rb[r].name.substr(0, name.length) == name)
61		{
62			rb[r].checked = state;
63		}
64	}
65}
66
67/**
68* Resize viewable area for attached image or topic review panel (possibly others to come)
69* e = element
70*/
71function viewableArea(e, itself)
72{
73	if (!e) return;
74	if (!itself)
75	{
76		e = e.parentNode;
77	}
78	
79	if (!e.vaHeight)
80	{
81		// Store viewable area height before changing style to auto
82		e.vaHeight = e.offsetHeight;
83		e.vaMaxHeight = e.style.maxHeight;
84		e.style.height = 'auto';
85		e.style.maxHeight = 'none';
86		e.style.overflow = 'visible';
87	}
88	else
89	{
90		// Restore viewable area height to the default
91		e.style.height = e.vaHeight + 'px';
92		e.style.overflow = 'auto';
93		e.style.maxHeight = e.vaMaxHeight;
94		e.vaHeight = false;
95	}
96}
97
98/**
99* Set display of page element
100* s[-1,0,1] = hide,toggle display,show
101* type = string: inline, block, inline-block or other CSS "display" type
102*/
103function dE(n, s, type)
104{
105	if (!type)
106	{
107		type = 'block';
108	}
109
110	var e = document.getElementById(n);
111	if (!s)
112	{
113		s = (e.style.display == '' || e.style.display == type) ? -1 : 1;
114	}
115	e.style.display = (s == 1) ? type : 'none';
116}
117
118/**
119* Alternate display of subPanels
120*/
121function subPanels(p)
122{
123	var i, e, t;
124
125	if (typeof(p) == 'string')
126	{
127		show_panel = p;
128	}
129
130	for (i = 0; i < panels.length; i++)
131	{
132		e = document.getElementById(panels[i]);
133		t = document.getElementById(panels[i] + '-tab');
134
135		if (e)
136		{
137			if (panels[i] == show_panel)
138			{
139				e.style.display = 'block';
140				if (t)
141				{
142					t.className = 'activetab';
143				}
144			}
145			else
146			{
147				e.style.display = 'none';
148				if (t)
149				{
150					t.className = '';
151				}
152			}
153		}
154	}
155}
156
157/**
158* Call print preview
159*/
160function printPage()
161{
162	if (is_ie)
163	{
164		printPreview();
165	}
166	else
167	{
168		window.print();
169	}
170}
171
172/**
173* Show/hide groups of blocks
174* c = CSS style name
175* e = checkbox element
176* t = toggle dispay state (used to show 'grip-show' image in the profile block when hiding the profiles) 
177*/
178function displayBlocks(c, e, t)
179{
180	var s = (e.checked == true) ?  1 : -1;
181
182	if (t)
183	{
184		s *= -1;
185	}
186
187	var divs = document.getElementsByTagName("DIV");
188
189	for (var d = 0; d < divs.length; d++)
190	{
191		if (divs[d].className.indexOf(c) == 0)
192		{
193			divs[d].style.display = (s == 1) ? 'none' : 'block';
194		}
195	}
196}
197
198function selectCode(a)
199{
200	// Get ID of code block
201	var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
202
203	// Not IE and IE9+
204	if (window.getSelection)
205	{
206		var s = window.getSelection();
207		// Safari
208		if (s.setBaseAndExtent)
209		{
210			s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
211		}
212		// Firefox and Opera
213		else
214		{
215			// workaround for bug # 42885
216			if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
217			{
218				e.innerHTML = e.innerHTML + '&nbsp;';
219			}
220
221			var r = document.createRange();
222			r.setStart(e.firstChild, 0);
223			r.setEnd(e.lastChild, e.lastChild.textContent.length);
224			s.removeAllRanges();
225			s.addRange(r);
226		}
227	}
228	// Some older browsers
229	else if (document.getSelection)
230	{
231		var s = document.getSelection();
232		var r = document.createRange();
233		r.selectNodeContents(e);
234		s.removeAllRanges();
235		s.addRange(r);
236	}
237	// IE
238	else if (document.selection)
239	{
240		var r = document.body.createTextRange();
241		r.moveToElementText(e);
242		r.select();
243	}
244}
245
246/**
247* Play quicktime file by determining it's width/height
248* from the displayed rectangle area
249*/
250function play_qt_file(obj)
251{
252	var rectangle = obj.GetRectangle();
253
254	if (rectangle)
255	{
256		rectangle = rectangle.split(',');
257		var x1 = parseInt(rectangle[0]);
258		var x2 = parseInt(rectangle[2]);
259		var y1 = parseInt(rectangle[1]);
260		var y2 = parseInt(rectangle[3]);
261
262		var width = (x1 < 0) ? (x1 * -1) + x2 : x2 - x1;
263		var height = (y1 < 0) ? (y1 * -1) + y2 : y2 - y1;
264	}
265	else
266	{
267		var width = 200;
268		var height = 0;
269	}
270
271	obj.width = width;
272	obj.height = height + 16;
273
274	obj.SetControllerVisible(true);
275	obj.Play();
276}
277
278jQuery(function($)
279{
280	// Preload sending animation for silly IE and Chrome
281	var $preloader = $('<button class="sending" style="position: absolute; top: -99px; left: -99px;"></button>').appendTo(document.body);
282	setTimeout(function(){$preloader.remove();}, 10);
283
284	// Forms submitting indication
285	$('form input[type=submit]').on('click', function()
286	{
287		var $submit = $(this);
288		if ($submit.hasClass('sending')) return false;
289		$(this).parents('form').off('submit.sending').one('submit.sending', function(e)
290		{
291			if (e.isDefaultPrevented()) return;
292			$submit.addClass('sending');
293			var last = (new Date()).getTime();
294			var timer = setInterval(function()
295			{
296				if ((new Date()).getTime() - last > 2000)
297				{
298					$submit.removeClass('sending');
299					clearInterval(timer);
300					return;
301				}
302				last = (new Date()).getTime();
303			}, 1000);
304		});
305	});
306
307	// Ctrl+Enter and Alt+Enter titles for default and alternate submit buttons
308	$('form input[type=submit].default-submit-action').attr('title', 'Ctrl+Enter');
309	$('form input[type=submit].alternate-submit-action').attr('title', 'Alt+Enter');
310
311	// Enter, Ctrl+Enter and Alt+Enter handler
312	$('form input[type=text], form input[type=password], form textarea').on('keydown', function (e)
313	{
314		var is_input = !$(this).is('textarea');
315
316		// Detect enter in autocomplete
317		if (is_input)
318		{
319			var in_autocomplete = $(this).data('in_autocomplete');
320			$(this).data('in_autocomplete', (e.which == 40 /*down*/ || e.which == 38 /*up*/ || e.which == 34 /*pgdn*/ || e.which == 33 /*pgup*/));
321			if (in_autocomplete && (e.which == 13 || e.which == 10)) return true;
322		}
323
324		if ((e.which == 13 || e.which == 10) && (is_input || e.ctrlKey || e.altKey))
325		{
326			// Find proper submit button
327			var $form = $(this).parents('form');
328			var $submit = $form.find('input[type=submit].' + (e.altKey ? 'alternate' : 'default') + '-submit-action:eq(0)');
329			if ($submit.length == 0)
330			{
331				if (e.altKey) return false;
332				$submit = $form.find('input[type=submit]');
333				if ($submit.length == 0) return false;
334				if ($submit.length > 1)
335				{
336					$submit = $form.find('input[type=submit][name=submit]');
337					if ($submit.length != 1) return false;
338				}
339			}
340
341			// Submit form
342			if (window.opera && e.ctrlKey)
343			{
344				// Prevent creation of new tab in Opera
345				// Unfortunately this method does not work with the button with name="submit"
346				if ($submit.attr('name') == 'submit') return false;
347				$submit.triggerHandler('click');
348				if ($submit.attr('name'))
349				{
350					var $input = $('<input type="hidden" />').attr('name', $submit.attr('name')).val($submit.val());
351					$form.append($input).submit();
352					$input.remove();
353				}
354				else
355				{
356					$form.submit();
357				}
358			}
359			else
360			{
361				$submit.click();
362			}
363			return false;
364		}
365
366		return true;
367	});
368
369	// Global back to top code
370	if ($('#back-to-top').length)
371	{
372		var is_visible = false;
373		$(window).scroll(function()
374		{
375			if ($(this).scrollTop() > 150)
376			{
377				if (is_visible) return;
378				is_visible = true;
379				$('#back-to-top').stop(true, true).fadeIn();
380			}
381			else
382			{
383				if (!is_visible) return;
384				is_visible = false;
385				$('#back-to-top').stop(true, true).fadeOut();
386			}
387		});
388		$(window).scroll();
389
390		var is_tower = false;
391		$(window).resize(function()
392		{
393			if ($(document).width() - $('#wrap').width() > 120)
394			{
395				if (is_tower) return;
396				is_tower = true;
397				$('#back-to-top').addClass('tower');
398			}
399			else
400			{
401				if (!is_tower) return;
402				is_tower = false;
403				$('#back-to-top').removeClass('tower');
404			}
405		});
406		$(window).resize();
407
408		$('#back-to-top').click(function()
409		{
410			$('body:not(:animated),html:not(:animated)').animate({ scrollTop: 0 }, 400);
411			return false;
412		});
413	}
414
415	// Spoilers code
416	$('dl.spoilerbox > dt').on('click', function()
417	{
418		$(this).parent().toggleClass('spoilerbox-on');
419	});
420});

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.