PageSourceSearch

http://dstv.fun/static/js/forum.js?oNh

js dstv.fun collected 2026-10-05 06:25:47 UTC 15,442 bytes, 465 lines download raw bytes

1/*
2	[Discuz!] (C)2001-2009 Comsenz Inc.
3	This is NOT a freeware, use is subject to license terms
4
5	$Id: forum.js 22522 2011-05-11 03:12:47Z monkey $
6//	Modified by Valery Votintsev
7*/
8
9function saveData(ignoreempty) {
10	var ignoreempty = isUndefined(ignoreempty) ? 0 : ignoreempty;
11	var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : ($('fastpostform') ? $('fastpostform') : $('postform'));
12	if(!obj) return;
13	if(typeof isfirstpost != 'undefined') {
14		if(typeof wysiwyg != 'undefined' && wysiwyg == 1) {
15			var messageisnull = trim(html2bbcode(editdoc.body.innerHTML)) === '';
16		} else {
17			var messageisnull = $('postform').message.value === '';
18		}
19		if(isfirstpost && (messageisnull && $('postform').subject.value === '')) {
20			return;
21		}
22		if(!isfirstpost && messageisnull) {
23			return;
24		}
25	}
26	var data = subject = message = '';
27	for(var i = 0; i < obj.elements.length; i++) {
28		var el = obj.elements[i];
29		if(el.name != '' && (el.tagName == 'SELECT' || el.tagName == 'TEXTAREA' || el.tagName == 'INPUT' && (el.type == 'text' || el.type == 'checkbox' || el.type == 'radio' || el.type == 'hidden' || el.type == 'select')) && el.name.substr(0, 6) != 'attach') {
30			var elvalue = el.value;
31			if(el.name == 'subject') {
32				subject = trim(elvalue);
33			} else if(el.name == 'message') {
34				if(typeof wysiwyg != 'undefined' && wysiwyg == 1) {
35					elvalue = html2bbcode(editdoc.body.innerHTML);
36				}
37				message = trim(elvalue);
38			}
39			if((el.type == 'checkbox' || el.type == 'radio') && !el.checked) {
40				continue;
41			} else if(el.tagName == 'SELECT') {
42				elvalue = el.value;
43			} else if(el.type == 'hidden') {
44				if(el.id) {
45					eval('var check = typeof ' + el.id + '_upload == \'function\'');
46					if(check) {
47						elvalue = elvalue;
48						if($(el.id + '_url')) {
49							elvalue += String.fromCharCode(1) + $(el.id + '_url').value;
50						}
51					} else {
52						continue;
53					}
54				} else {
55					continue;
56				}
57			}
58			if(trim(elvalue)) {
59				data += el.name + String.fromCharCode(9) + el.tagName + String.fromCharCode(9) + el.type + String.fromCharCode(9) + elvalue + String.fromCharCode(9, 9);
60			}
61		}
62	}
63
64	if(!subject && !message && !ignoreempty) {
65		return;
66	}
67
68	saveUserdata('forum', data);
69}
70
71function switchFullMode() {
72	var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : $('fastpostform');
73	if(obj && obj.message.value != '') {
74		saveData();
75	}
76	ajaxget('forum.php?mod=ajax&action=editor&cedit=yes' + (!fid ? '' : '&fid=' + fid), 'fastposteditor');
77	return false;
78}
79
80function fastUload() {
81	appendscript(JSPATH + 'forum_post.js?' + VERHASH);
82	safescript('forum_post_js', function () { uploadWindow(function (aid, url) {updatefastpostattach(aid, url)}, 'file') }, 100, 50);
83}
84
85function switchAdvanceMode(url) {
86	var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : $('fastpostform');
87	if(obj && obj.message.value != '') {
88		saveData();
89		url += (url.indexOf('?') != -1 ? '&' : '?') + 'cedit=yes';
90	}
91	location.href = url;
92	return false;
93}
94
95function sidebar_collapse(lang) {
96	if(lang[0]) {
97		toggle_collapse('sidebar', null, null, lang);
98		$('wrap').className = $('wrap').className == 'wrap with_side s_clear' ? 'wrap s_clear' : 'wrap with_side s_clear';
99	} else {
100		var collapsed = getcookie('collapse');
101		collapsed = updatestring(collapsed, 'sidebar', 1);
102		setcookie('collapse', collapsed, (collapsed ? 2592000 : -2592000));
103		location.reload();
104	}
105}
106
107function keyPageScroll(e, prev, next, url, page) {
108	e = e ? e : window.event;
109	var tagname = BROWSER.ie ? e.srcElement.tagName : e.target.tagName;
110	if(tagname == 'INPUT' || tagname == 'TEXTAREA') return;
111	actualCode = e.keyCode ? e.keyCode : e.charCode;
112	if(next && actualCode == 39) {
113		window.location = url + '&page=' + (page + 1);
114	}
115	if(prev && actualCode == 37) {
116		window.location = url + '&page=' + (page - 1);
117	}
118}
119
120function announcement() {
121	var ann = new Object();
122	ann.anndelay = 3000;ann.annst = 0;ann.annstop = 0;ann.annrowcount = 0;ann.anncount = 0;ann.annlis = $('anc').getElementsByTagName("li");ann.annrows = new Array();
123	ann.announcementScroll = function () {
124		if(this.annstop) {this.annst = setTimeout(function () {ann.announcementScroll();}, this.anndelay);return;}
125		if(!this.annst) {
126			var lasttop = -1;
127			for(i = 0;i < this.annlis.length;i++) {
128				if(lasttop != this.annlis[i].offsetTop) {
129					if(lasttop == -1) lasttop = 0;
130					this.annrows[this.annrowcount] = this.annlis[i].offsetTop - lasttop;this.annrowcount++;
131				}
132				lasttop = this.annlis[i].offsetTop;
133			}
134			if(this.annrows.length == 1) {
135				$('an').onmouseover = $('an').onmouseout = null;
136			} else {
137				this.annrows[this.annrowcount] = this.annrows[1];
138				$('ancl').innerHTML += $('ancl').innerHTML;
139				this.annst = setTimeout(function () {ann.announcementScroll();}, this.anndelay);
140				$('an').onmouseover = function () {ann.annstop = 1;};
141				$('an').onmouseout = function () {ann.annstop = 0;};
142			}
143			this.annrowcount = 1;
144			return;
145		}
146		if(this.annrowcount >= this.annrows.length) {
147			$('anc').scrollTop = 0;
148			this.annrowcount = 1;
149			this.annst = setTimeout(function () {ann.announcementScroll();}, this.anndelay);
150		} else {
151			this.anncount = 0;
152			this.announcementScrollnext(this.annrows[this.annrowcount]);
153		}
154	};
155	ann.announcementScrollnext = function (time) {
156		$('anc').scrollTop++;
157		this.anncount++;
158		if(this.anncount != time) {
159			this.annst = setTimeout(function () {ann.announcementScrollnext(time);}, 10);
160		} else {
161			this.annrowcount++;
162			this.annst = setTimeout(function () {ann.announcementScroll();}, this.anndelay);
163		}
164	};
165	ann.announcementScroll();
166}
167
168function removeindexheats() {
169	return confirm(lng['del_thread_sure']);
170}
171
172function showTypes(id, mod) {
173	var o = $(id);
174	if(!o) return false;
175	var s = o.className;
176	mod = isUndefined(mod) ? 1 : mod;
177	var baseh = o.getElementsByTagName('li')[0].offsetHeight * 2;
178	var tmph = o.offsetHeight;
179	var lang = [lng['expand'], lng['collapse']];
180	var cls = ['unfold', 'fold'];
181	if(tmph > baseh) {
182		var octrl = document.createElement('li');
183		octrl.className = cls[mod];
184		octrl.innerHTML = lang[mod];
185
186		o.insertBefore(octrl, o.firstChild);
187		o.className = s + ' cttp';
188		mod && (o.style.height = 'auto');
189
190		octrl.onclick = function () {
191			if(this.className == cls[0]) {
192				o.style.height = 'auto';
193				this.className = cls[1];
194				this.innerHTML = lang[1];
195			} else {
196				o.style.height = '';
197				this.className = cls[0];
198				this.innerHTML = lang[0];
199			}
200		}
201	}
202}
203
204var postpt = 0;
205function fastpostvalidate(theform, noajaxpost) {
206	if(postpt) {
207		return false;
208	}
209	postpt = 1;
210	setTimeout(function() {postpt = 0}, 2000);
211	noajaxpost = !noajaxpost ? 0 : noajaxpost;
212	s = '';
213	if(typeof fastpostvalidateextra == 'function') {
214		var v = fastpostvalidateextra();
215		if(!v) {
216			return false;
217		}
218	}
219	if(theform.message.value == '' && theform.subject.value == '') {
220		s = lng['enter_content']+'.';
221		theform.message.focus();
222//vot	} else if(mb_strlen(theform.subject.value) > 80) {
223	} else if(theform.subject.value.length > 80 ) { //vot
224		s = lng['title_long']+'.';
225		theform.subject.focus();
226	}
227	if(!disablepostctrl && ((postminchars != 0 && mb_strlen(theform.message.value) < postminchars) || (postmaxchars != 0 && mb_strlen(theform.message.value) > postmaxchars))) {
228		s = lng['content_long'] + lng['current_length']+': ' + mb_strlen(theform.message.value) + ' ' + lng['bytes']+'\n'+lng['system_limit']+': ' + postminchars + ' '+lng['up_to']+' ' + postmaxchars + ' '+lng['bytes'];
229	}
230	if(s) {
231		showError(s);
232		doane();
233		$('fastpostsubmit').disabled = false;
234		return false;
235	}
236	$('fastpostsubmit').disabled = true;
237	theform.message.value = parseurl(theform.message.value);
238	if(!noajaxpost) {
239		ajaxpost('fastpostform', 'fastpostreturn', 'fastpostreturn', 'onerror', $('fastpostsubmit'));
240		return false;
241	} else {
242		return true;
243	}
244}
245
246function updatefastpostattach(aid, url) {
247	ajaxget('forum.php?mod=ajax&action=attachlist&posttime=' + $('posttime').value + (!fid ? '' : '&fid=' 
247+ fid), 'attachlist');
248	$('attach_tblheader').style.display = '';
249}
250
251function succeedhandle_fastnewpost(locationhref, message, param) {
252	location.href = locationhref;
253}
254
255function errorhandle_fastnewpost() {
256	$('fastpostsubmit').disabled = false;
257}
258
259function atarget(obj) {
260	obj.target = getcookie('atarget') ? '_blank' : '';
261}
262
263function setatarget(v) {
264	$('atarget').className = 'y atarget_' + v;
265	$('atarget').onclick = function() {setatarget(v ? 0 : 1);};
266	setcookie('atarget', v, (v ? 2592000 : -1));
267}
268
269function loadData(quiet, formobj) {
270
271	var evalevent = function (obj) {
272		var script = obj.parentNode.innerHTML;
273		var re = /onclick="(.+?)["|>]/ig;
274		var matches = re.exec(script);
275		if(matches != null) {
276			matches[1] = matches[1].replace(/this\./ig, 'obj.');
277			eval(matches[1]);
278		}
279	};
280
281	var data = '';
282	data = loadUserdata('forum');
283	var formobj = !formobj ? $('postform') : formobj;
284
285	if(in_array((data = trim(data)), ['', 'null', 'false', null, false])) {
286		if(!quiet) {
287/*vot*/			showDialog(lng['recover_no'], 'info');
288		}
289		return;
290	}
291
292	if(!quiet && !confirm(lng['recover_sure'])) {
293		return;
294	}
295
296	var data = data.split(/\x09\x09/);
297	for(var i = 0; i < formobj.elements.length; i++) {
298		var el = formobj.elements[i];
299		if(el.name != '' && (el.tagName == 'SELECT' || el.tagName == 'TEXTAREA' || el.tagName == 'INPUT' && (el.type == 'text' || el.type == 'checkbox' || el.type == 'radio' || el.type == 'hidden'))) {
300			for(var j = 0; j < data.length; j++) {
301				var ele = data[j].split(/\x09/);
302				if(ele[0] == el.name) {
303					elvalue = !isUndefined(ele[3]) ? ele[3] : '';
304					if(ele[1] == 'INPUT') {
305						if(ele[2] == 'text') {
306							el.value = elvalue;
307						} else if((ele[2] == 'checkbox' || ele[2] == 'radio') && ele[3] == el.value) {
308							el.checked = true;
309							evalevent(el);
310						} else if(ele[2] == 'hidden') {
311							eval('var check = typeof ' + el.id + '_upload == \'function\'');
312							if(check) {
313								var v = elvalue.split(/\x01/);
314								el.value = v[0];
315								if(el.value) {
316									if($(el.id + '_url') && v[1]) {
317										$(el.id + '_url').value = v[1];
318									}
319									eval(el.id + '_upload(\'' + v[0] + '\', \'' + v[1] + '\')');
320									if($('unused' + v[0])) {
321										var attachtype = $('unused' + v[0]).parentNode.parentNode.parentNode.parentNode.id.substr(11);
322										$('unused' + v[0]).parentNode.parentNode.outerHTML = '';
323										$('unusednum_' + attachtype).innerHTML = parseInt($('unusednum_' + attachtype).innerHTML) - 1;
324										if($('unusednum_' + attachtype).innerHTML == 0 && $('attachnotice_' + attachtype)) {
325											$('attachnotice_' + attachtype).style.display = 'none';
326										}
327									}
328								}
329							}
330
331						}
332					} else if(ele[1] == 'TEXTAREA') {
333						if(ele[0] == 'message') {
334							if(!wysiwyg) {
335								textobj.value = elvalue;
336							} else {
337								editdoc.body.innerHTML = bbcode2html(elvalue);
338							}
339						} else {
340							el.value = elvalue;
341						}
342					} else if(ele[1] == 'SELECT') {
343						if($(el.id + '_ctrl_menu')) {
344							var lis = $(el.id + '_ctrl_menu').getElementsByTagName('li');
345							for(var k = 0; k < lis.length; k++) {
346								if(ele[3] == lis[k].k_value) {
347									lis[k].onclick();
348									break;
349								}
350							}
351						} else {
352							for(var k = 0; k < el.options.length; k++) {
353								if(ele[3] == el.options[k].value) {
354									el.options[k].selected = true;
355									break;
356								}
357							}
358						}
359					}
360					break;
361				}
362			}
363		}
364	}
365	if($('rstnotice')) {
366		$('rstnotice').style.display = 'none';
367	}
368	extraCheckall();
369}
370
371var checkForumcount = 0, checkForumtimeout = 30000, checkForumnew_handle;
372function checkForumnew(fid, lasttime) {
373	var timeout = checkForumtimeout;
374	var x = new Ajax();
375	x.get('forum.php?mod=ajax&action=forumchecknew&fid=' + fid + '&time=' + lasttime + '&inajax=yes', function(s){
376		if(s > 0) {
377			if($('separatorline')) {
378				var table = $('separatorline').parentNode;
379			} else {
380				var table = $('forum_' + fid);
381			}
382			if(!isUndefined(checkForumnew_handle)) {
383				clearTimeout(checkForumnew_handle);
384			}
385			removetbodyrow(table, 'forumnewshow');
386			var colspan = table.getElementsByTagName('tbody')[0].rows[0].children.length;
387			var checknew = {'tid':'', 'thread':{'common':{'className':'', 'val':'<a href="javascript:void(0);" onclick="ajaxget(\'forum.php?mod=ajax&action=forumchecknew&fid=' + fid+ '&time='+lasttime+'&uncheck=1&inajax=yes\', \'forumnew\');">'+lng['new_reply_exists'], 'colspan': colspan }}};
388			addtbodyrow(table, ['tbody'], ['forumnewshow'], 'separatorline', checknew);
389		} else {
390			if(checkForumcount < 50) {
391				if(checkForumcount > 0) {
392					var multiple =  Math.ceil(50 / checkForumcount);
393					if(multiple < 5) {
394						timeout = checkForumtimeout * (5 - multiple + 1);
395					}
396				}
397				checkForumnew_handle = setTimeout(function () {checkForumnew(fid, lasttime);}, timeout);
398			}
399		}
400		checkForumcount++;
401	});
402
403}
404function checkForumnew_btn(fid) {
405	if(isUndefined(fid)) return;
406	ajaxget('forum.php?mod=ajax&action=forumchecknew&fid=' + fid+ '&time='+lasttime+'&uncheck=2&inajax=yes', 'forumnew', 'ajaxwaitid');
407	lasttime = parseInt(Date.parse(new Date()) / 1000);
408}
409
410function addtbodyrow (table, insertID, changename, separatorid, jsonval) {
411	if(isUndefined(table) || isUndefined(insertID[0])) {
412		return;
413	}
414
415	var insertobj = document.createElement(insertID[0]);
416	var thread = jsonval.thread;
417	var tid = !isUndefined(jsonval.tid) ? jsonval.tid : '' ;
418
419	if(!isUndefined(changename[1])) {
420		removetbodyrow(table, changename[1] + tid);
421	}
422
423	insertobj.id = changename[0] + tid;
424	if(!isUndefined(insertID[1])) {
425		insertobj.className = insertID[1];
426	}
427	if($(separatorid)) {
428		table.insertBefore(insertobj, $(separatorid).nextSibling);
429	} else {
430		table.insertBefore(insertobj, table.firstChild);
431	}
432	var newTH = insertobj.insertRow(-1);
433	for(var value in thread) {
434		if(value != 0) {
435			var cell = newTH.insertCell(-1);
436			if(isUndefined(thread[value]['val'])) {
437				cell.innerHTML = thread[value];
438			} else {
439				cell.innerHTML = thread[value]['val'];
440			}
441			if(!isUndefined(thread[value]['className'])) {
442				cell.className = thread[value]['className'];
443			}
444			if(!isUndefined(thread[value]['colspan'])) {
445				cell.colSpan = thread[value]['colspan'];
446			}
447		}
448	}
449
450	if(!isUndefined(insertID[2])) {
451		_attachEvent(insertobj, insertID[2], function() {insertobj.className = '';});
452	}
453}
454function removetbodyrow(from, objid) {
455	if(!isUndefined(from) && $(objid)) {
456		from.removeChild($(objid));
457	}
458}
459
460function leftside(id) {
461	$(id).className = $(id).className == 'a' ? '' : 'a';
462	if(id == 'lf_fav') {
463		setcookie('leftsidefav', $(id).className == 'a' ? 0 : 1, 2592000);
464	}
465}

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.