forum_viewthread.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. /*
  2. [Discuz!] (C)2001-2099 Comsenz Inc.
  3. This is NOT a freeware, use is subject to license terms
  4. $Id: forum_viewthread.js 35221 2015-02-27 08:24:39Z nemohou $
  5. */
  6. var replyreload = '', attachimgST = new Array(), zoomgroup = new Array(), zoomgroupinit = new Array();
  7. function attachimggroup(pid) {
  8. if(!zoomgroupinit[pid]) {
  9. for(i = 0;i < aimgcount[pid].length;i++) {
  10. zoomgroup['aimg_' + aimgcount[pid][i]] = pid;
  11. }
  12. zoomgroupinit[pid] = true;
  13. }
  14. }
  15. function attachimgshow(pid, onlyinpost) {
  16. onlyinpost = !onlyinpost ? false : onlyinpost;
  17. aimgs = aimgcount[pid];
  18. aimgcomplete = 0;
  19. loadingcount = 0;
  20. for(i = 0;i < aimgs.length;i++) {
  21. obj = $('aimg_' + aimgs[i]);
  22. if(!obj) {
  23. aimgcomplete++;
  24. continue;
  25. }
  26. if(onlyinpost && obj.getAttribute('inpost') || !onlyinpost) {
  27. if(!obj.status) {
  28. obj.status = 1;
  29. if(obj.getAttribute('file')) obj.src = obj.getAttribute('file');
  30. loadingcount++;
  31. } else if(obj.status == 1) {
  32. if(obj.complete) {
  33. obj.status = 2;
  34. } else {
  35. loadingcount++;
  36. }
  37. } else if(obj.status == 2) {
  38. aimgcomplete++;
  39. if(obj.getAttribute('thumbImg')) {
  40. thumbImg(obj);
  41. }
  42. }
  43. if(loadingcount >= 10) {
  44. break;
  45. }
  46. }
  47. }
  48. if(aimgcomplete < aimgs.length) {
  49. setTimeout(function () {
  50. attachimgshow(pid, onlyinpost);
  51. }, 100);
  52. }
  53. }
  54. function attachimglstshow(pid, islazy, fid, showexif) {
  55. var aimgs = aimgcount[pid];
  56. var s = '';
  57. if(fid) {
  58. s = ' onmouseover="showMenu({\'ctrlid\':this.id, \'pos\': \'12!\'});"';
  59. }
  60. if(typeof aimgcount == 'object' && $('imagelistthumb_' + pid)) {
  61. for(pid in aimgcount) {
  62. var imagelist = '';
  63. for(i = 0;i < aimgcount[pid].length;i++) {
  64. if(!$('aimg_' + aimgcount[pid][i]) || $('aimg_' + aimgcount[pid][i]).getAttribute('inpost') || parseInt(aimgcount[pid][i]) != aimgcount[pid][i]) {
  65. continue;
  66. }
  67. if(fid) {
  68. imagelist += '<div id="pattimg_' + aimgcount[pid][i] + '_menu" class="tip tip_4" style="display: none;"><div class="tip_horn"></div><div class="tip_c"><a href="forum.php?mod=ajax&action=setthreadcover&aid=' + aimgcount[pid][i] + '&fid=' + fid + '" class="xi2" onclick="showWindow(\'setcover' + aimgcount[pid][i] + '\', this.href)">设为封面</a></div></div>';
  69. }
  70. imagelist += '<div class="pattimg">' +
  71. '<a id="pattimg_' + aimgcount[pid][i] + '" class="pattimg_zoom" href="javascript:;"' + s + ' onclick="zoom($(\'aimg_' + aimgcount[pid][i] + '\'), attachimggetsrc(\'aimg_' + aimgcount[pid][i] + '\'), 0, 0, ' + (parseInt(showexif) ? 1 : 0) + ')" title="点击放大">点击放大</a>' +
  72. '<img ' + (islazy ? 'file' : 'src') + '="forum.php?mod=image&aid=' + aimgcount[pid][i] + '&size=100x100&key=' + imagelistkey + '&atid=' + tid + '" width="100" height="100" /></div>';
  73. }
  74. if($('imagelistthumb_' + pid)) {
  75. $('imagelistthumb_' + pid).innerHTML = imagelist;
  76. }
  77. }
  78. }
  79. }
  80. function attachimggetsrc(img) {
  81. return $(img).getAttribute('zoomfile') ? $(img).getAttribute('zoomfile') : $(img).getAttribute('file');
  82. }
  83. function attachimglst(pid, op, islazy) {
  84. if(!op) {
  85. $('imagelist_' + pid).style.display = 'none';
  86. $('imagelistthumb_' + pid).style.display = '';
  87. } else {
  88. $('imagelistthumb_' + pid).style.display = 'none';
  89. $('imagelist_' + pid).style.display = '';
  90. if(islazy) {
  91. o = new lazyload();
  92. o.showImage();
  93. } else {
  94. attachimgshow(pid);
  95. }
  96. }
  97. doane();
  98. }
  99. function attachimginfo(obj, infoobj, show, event) {
  100. objinfo = fetchOffset(obj);
  101. if(show) {
  102. $(infoobj).style.left = objinfo['left'] + 'px';
  103. $(infoobj).style.top = obj.offsetHeight < 40 ? (objinfo['top'] + obj.offsetHeight) + 'px' : objinfo['top'] + 'px';
  104. $(infoobj).style.display = '';
  105. } else {
  106. if(BROWSER.ie) {
  107. $(infoobj).style.display = 'none';
  108. return;
  109. } else {
  110. var mousex = document.body.scrollLeft + event.clientX;
  111. var mousey = document.documentElement.scrollTop + event.clientY;
  112. if(mousex < objinfo['left'] || mousex > objinfo['left'] + objinfo['width'] || mousey < objinfo['top'] || mousey > objinfo['top'] + objinfo['height']) {
  113. $(infoobj).style.display = 'none';
  114. }
  115. }
  116. }
  117. }
  118. function signature(obj) {
  119. if(obj.style.maxHeightIE != '') {
  120. var height = (obj.scrollHeight > parseInt(obj.style.maxHeightIE)) ? obj.style.maxHeightIE : obj.scrollHeight + 'px';
  121. if(obj.innerHTML.indexOf('<IMG ') == -1) {
  122. obj.style.maxHeightIE = '';
  123. }
  124. return height;
  125. }
  126. }
  127. function tagshow(event) {
  128. var obj = BROWSER.ie ? event.srcElement : event.target;
  129. ajaxmenu(obj, 0, 1, 2);
  130. }
  131. function parsetag(pid) {
  132. if(!$('postmessage_'+pid) || $('postmessage_'+pid).innerHTML.match(/<script[^\>]*?>/i)) {
  133. return;
  134. }
  135. var havetag = false;
  136. var tagfindarray = new Array();
  137. var str = $('postmessage_'+pid).innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3, $4) {
  138. for(i in tagarray) {
  139. if(tagarray[i] && $3.indexOf(tagarray[i]) != -1) {
  140. havetag = true;
  141. $3 = $3.replace(tagarray[i], '<h_ ' + i + '>');
  142. tmp = $3.replace(/&[a-z]*?<h_ \d+>[a-z]*?;/ig, '');
  143. if(tmp != $3) {
  144. $3 = tmp;
  145. } else {
  146. tagfindarray[i] = tagarray[i];
  147. tagarray[i] = '';
  148. }
  149. }
  150. }
  151. return $2 + $3;
  152. });
  153. if(havetag) {
  154. $('postmessage_'+pid).innerHTML = str.replace(/<h_ (\d+)>/ig, function($1, $2) {
  155. return '<span href=\"forum.php?mod=tag&name=' + tagencarray[$2] + '\" onclick=\"tagshow(event)\" class=\"t_tag\">' + tagfindarray[$2] + '</span>';
  156. });
  157. }
  158. }
  159. function setanswer(pid, from){
  160. if(confirm('您确认要把该回复选为“最佳答案”吗?')){
  161. if(BROWSER.ie) {
  162. doane(event);
  163. }
  164. $('modactions').action='forum.php?mod=misc&action=bestanswer&tid=' + tid + '&pid=' + pid + '&from=' + from + '&bestanswersubmit=yes';
  165. $('modactions').submit();
  166. }
  167. }
  168. var authort;
  169. function showauthor(ctrlObj, menuid) {
  170. authort = setTimeout(function () {
  171. showMenu({'menuid':menuid});
  172. if($(menuid + '_ma').innerHTML == '') $(menuid + '_ma').innerHTML = ctrlObj.innerHTML;
  173. }, 500);
  174. if(!ctrlObj.onmouseout) {
  175. ctrlObj.onmouseout = function() {
  176. clearTimeout(authort);
  177. }
  178. }
  179. }
  180. function fastpostappendreply() {
  181. if($('fastpostrefresh') != null) {
  182. setcookie('fastpostrefresh', $('fastpostrefresh').checked ? 1 : 0, 2592000);
  183. if($('fastpostrefresh').checked) {
  184. location.href = 'forum.php?mod=redirect&tid='+tid+'&goto=lastpost&random=' + Math.random() + '#lastpost';
  185. return;
  186. }
  187. }
  188. newpos = fetchOffset($('post_new'));
  189. document.documentElement.scrollTop = newpos['top'];
  190. $('post_new').style.display = '';
  191. $('post_new').id = '';
  192. div = document.createElement('div');
  193. div.id = 'post_new';
  194. div.style.display = 'none';
  195. div.className = '';
  196. $('postlistreply').appendChild(div);
  197. $('fastpostsubmit').disabled = false;
  198. if($('fastpostmessage')) {
  199. $('fastpostmessage').value = '';
  200. } else {
  201. editdoc.body.innerHTML = BROWSER.firefox ? '<br />' : '';
  202. }
  203. if($('fastpostform').seccodehash){
  204. updateseccode($('fastpostform').seccodehash.value);
  205. $('fastpostform').seccodeverify.value = '';
  206. }
  207. if($('fastpostform').secqaahash){
  208. updatesecqaa($('fastpostform').secqaahash.value);
  209. $('fastpostform').secanswer.value = '';
  210. }
  211. showCreditPrompt();
  212. }
  213. function succeedhandle_fastpost(locationhref, message, param) {
  214. var pid = param['pid'];
  215. var tid = param['tid'];
  216. var from = param['from'];
  217. if(pid) {
  218. ajaxget('forum.php?mod=viewthread&tid=' + tid + '&viewpid=' + pid + '&from=' + from, 'post_new', 'ajaxwaitid', '', null, 'fastpostappendreply()');
  219. if(replyreload) {
  220. var reloadpids = replyreload.split(',');
  221. for(var i = 1;i < reloadpids.length;i++) {
  222. ajaxget('forum.php?mod=viewthread&tid=' + tid + '&viewpid=' + reloadpids[i] + '&from=' + from, 'post_' + reloadpids[i], 'ajaxwaitid');
  223. }
  224. }
  225. $('fastpostreturn').className = '';
  226. } else {
  227. if(!message) {
  228. message = '本版回帖需要审核,您的帖子将在通过审核后显示';
  229. }
  230. $('post_new').style.display = $('fastpostmessage').value = $('fastpostreturn').className = '';
  231. $('fastpostreturn').innerHTML = message;
  232. }
  233. if(param['sechash']) {
  234. updatesecqaa(param['sechash']);
  235. updateseccode(param['sechash']);
  236. }
  237. if($('attach_tblheader')) {
  238. $('attach_tblheader').style.display = 'none';
  239. }
  240. if($('attachlist')) {
  241. $('attachlist').innerHTML = '';
  242. }
  243. }
  244. function errorhandle_fastpost() {
  245. $('fastpostsubmit').disabled = false;
  246. }
  247. function succeedhandle_comment(locationhref, message, param) {
  248. ajaxget('forum.php?mod=misc&action=commentmore&tid=' + param['tid'] + '&pid=' + param['pid'], 'comment_' + param['pid']);
  249. hideWindow('comment');
  250. showCreditPrompt();
  251. }
  252. function succeedhandle_postappend(locationhref, message, param) {
  253. ajaxget('forum.php?mod=viewthread&tid=' + param['tid'] + '&viewpid=' + param['pid'], 'post_' + param['pid'], 'ajaxwaitid');
  254. hideWindow('postappend');
  255. }
  256. function recommendupdate(n) {
  257. if(getcookie('recommend')) {
  258. var objv = n > 0 ? $('recommendv_add') : $('recommendv_subtract');
  259. objv.style.display = '';
  260. objv.innerHTML = parseInt(objv.innerHTML) + 1;
  261. setTimeout(function () {
  262. $('recommentc').innerHTML = parseInt($('recommentc').innerHTML) + n;
  263. $('recommentv').style.display = 'none';
  264. }, 1000);
  265. setcookie('recommend', '');
  266. }
  267. }
  268. function postreviewupdate(pid, n) {
  269. var objv = n > 0 ? $('review_support_'+pid) : $('review_against_'+pid);
  270. objv.innerHTML = parseInt(objv.innerHTML ? objv.innerHTML : 0) + 1;
  271. }
  272. function favoriteupdate() {
  273. var obj = $('favoritenumber');
  274. obj.style.display = '';
  275. obj.innerHTML = parseInt(obj.innerHTML) + 1;
  276. }
  277. function switchrecommendv() {
  278. display('recommendv');
  279. display('recommendav');
  280. }
  281. function appendreply() {
  282. newpos = fetchOffset($('post_new'));
  283. document.documentElement.scrollTop = newpos['top'];
  284. $('post_new').style.display = '';
  285. $('post_new').id = '';
  286. div = document.createElement('div');
  287. div.id = 'post_new';
  288. div.style.display = 'none';
  289. div.className = '';
  290. $('postlistreply').appendChild(div);
  291. if($('postform')) {
  292. $('postform').replysubmit.disabled = false;
  293. }
  294. showCreditPrompt();
  295. }
  296. function poll_checkbox(obj) {
  297. if(obj.checked) {
  298. p++;
  299. for (var i = 0; i < $('poll').elements.length; i++) {
  300. var e = $('poll').elements[i];
  301. if(p == max_obj) {
  302. if(e.name.match('pollanswers') && !e.checked) {
  303. e.disabled = true;
  304. }
  305. }
  306. }
  307. } else {
  308. p--;
  309. for (var i = 0; i < $('poll').elements.length; i++) {
  310. var e = $('poll').elements[i];
  311. if(e.name.match('pollanswers') && e.disabled) {
  312. e.disabled = false;
  313. }
  314. }
  315. }
  316. $('pollsubmit').disabled = p <= max_obj && p > 0 ? false : true;
  317. }
  318. function itemdisable(i) {
  319. if($('itemt_' + i).className == 'z') {
  320. $('itemt_' + i).className = 'z xg1';
  321. $('itemc_' + i).value = '';
  322. itemset(i);
  323. } else {
  324. $('itemt_' + i).className = 'z';
  325. $('itemc_' + i).value = $('itemc_' + i).value > 0 ? $('itemc_' + i).value : 0;
  326. }
  327. }
  328. function itemop(i, v) {
  329. var h = v > 0 ? '-' + (v * 16) + 'px' : '0';
  330. $('item_' + i).style.backgroundPosition = '10px ' + h;
  331. }
  332. function itemclk(i, v) {
  333. $('itemc_' + i).value = v;
  334. $('itemt_' + i).className = 'z';
  335. }
  336. function itemset(i) {
  337. var v = $('itemc_' + i).value;
  338. var h = v > 0 ? '-' + (v * 16) + 'px' : '0';
  339. $('item_' + i).style.backgroundPosition = '10px ' + h;
  340. }
  341. function checkmgcmn(id) {
  342. if($('mgc_' + id) && !$('mgc_' + id + '_menu').getElementsByTagName('li').length) {
  343. $('mgc_' + id).innerHTML = '';
  344. $('mgc_' + id).style.display = 'none';
  345. }
  346. }
  347. function toggleRatelogCollapse(tarId, ctrlObj) {
  348. if($(tarId).className == 'rate') {
  349. $(tarId).className = 'rate rate_collapse';
  350. setcookie('ratecollapse', 1, 2592000);
  351. ctrlObj.innerHTML = '展开';
  352. } else {
  353. $(tarId).className = 'rate';
  354. setcookie('ratecollapse', 0, -2592000);
  355. ctrlObj.innerHTML = '收起';
  356. }
  357. }
  358. function copyThreadUrl(obj, bbname) {
  359. bbname = bbname || SITEURL;
  360. setCopy($('thread_subject').innerHTML.replace(/&amp;/g, '&') + '\n' + obj.href + '\n' + '(出处: '+bbname+')' + '\n', '帖子地址已经复制到剪贴板');
  361. return false;
  362. }
  363. function replyNotice() {
  364. var newurl = 'forum.php?mod=misc&action=replynotice&tid=' + tid + '&op=';
  365. var replynotice = $('replynotice');
  366. var status = replynotice.getAttribute("status");
  367. if(status == 1) {
  368. replynotice.href = newurl + 'receive';
  369. replynotice.innerHTML = '接收回复通知';
  370. replynotice.setAttribute("status", 0);
  371. } else {
  372. replynotice.href = newurl + 'ignore';
  373. replynotice.innerHTML = '取消回复通知';
  374. replynotice.setAttribute("status", 1);
  375. }
  376. }
  377. var connect_share_loaded = 0;
  378. function connect_share(connect_share_url, connect_uin) {
  379. if(parseInt(discuz_uid) <= 0) {
  380. return true;
  381. } else {
  382. if(connect_uin) {
  383. setTimeout(function () {
  384. if(!connect_share_loaded) {
  385. showDialog('分享服务连接失败,请稍后再试。', 'notice');
  386. $('append_parent').removeChild($('connect_load_js'));
  387. }
  388. }, 5000);
  389. connect_load(connect_share_url);
  390. } else {
  391. showDialog($('connect_share_unbind').innerHTML, 'info', '请先绑定QQ账号');
  392. }
  393. return false;
  394. }
  395. }
  396. function connect_load(src) {
  397. var e = document.createElement('script');
  398. e.type = "text/javascript";
  399. e.id = 'connect_load_js';
  400. e.src = src + '&_r=' + Math.random();
  401. e.async = true;
  402. $('append_parent').appendChild(e);
  403. }
  404. function connect_show_dialog(title, html, type) {
  405. var type = type ? type : 'info';
  406. showDialog(html, type, title, null, 0);
  407. }
  408. function connect_get_thread() {
  409. connect_thread_info.subject = $('connect_thread_title').value;
  410. if ($('postmessage_' + connect_thread_info.post_id)) {
  411. connect_thread_info.html_content = preg_replace(["'"], ['%27'], encodeURIComponent(preg_replace(['本帖最后由 .*? 于 .*? 编辑','&nbsp;','<em onclick="copycode\\(\\$\\(\'code0\'\\)\\);">复制代码</em>'], ['',' ', ''], $('postmessage_' + connect_thread_info.post_id).innerHTML)));
  412. }
  413. return connect_thread_info;
  414. }
  415. function lazyload(className) {
  416. var obj = this;
  417. lazyload.className = className;
  418. this.getOffset = function (el, isLeft) {
  419. var retValue = 0 ;
  420. while (el != null ) {
  421. retValue += el["offset" + (isLeft ? "Left" : "Top" )];
  422. el = el.offsetParent;
  423. }
  424. return retValue;
  425. };
  426. this.initImages = function (ele) {
  427. lazyload.imgs = [];
  428. var eles = lazyload.className ? $C(lazyload.className, ele) : [document.body];
  429. for (var i = 0; i < eles.length; i++) {
  430. var imgs = eles[i].getElementsByTagName('IMG');
  431. for(var j = 0; j < imgs.length; j++) {
  432. if(imgs[j].getAttribute('file') && !imgs[j].getAttribute('lazyloaded')) {
  433. if(this.getOffset(imgs[j]) > document.documentElement.clientHeight) {
  434. lazyload.imgs.push(imgs[j]);
  435. } else {
  436. imgs[j].onload = function(){thumbImg(this);};
  437. imgs[j].setAttribute('src', imgs[j].getAttribute('file'));
  438. imgs[j].setAttribute('lazyloaded', 'true');
  439. }
  440. }
  441. }
  442. }
  443. };
  444. this.showImage = function() {
  445. this.initImages();
  446. if(!lazyload.imgs.length) return false;
  447. var imgs = [];
  448. var scrollTop = Math.max(document.documentElement.scrollTop , document.body.scrollTop);
  449. for (var i=0; i<lazyload.imgs.length; i++) {
  450. var img = lazyload.imgs[i];
  451. var offsetTop = this.getOffset(img);
  452. if (!img.getAttribute('lazyloaded') && offsetTop > document.documentElement.clientHeight && (offsetTop - scrollTop < document.documentElement.clientHeight)) {
  453. var dom = document.createElement('div');
  454. var width = img.getAttribute('width') ? img.getAttribute('width') : 100;
  455. var height = img.getAttribute('height') ? img.getAttribute('height') : 100;
  456. dom.innerHTML = '<div style="width: '+width+'px; height: '+height+'px;background: url('+IMGDIR + '/loading.gif) no-repeat center center;"></div>';
  457. img.parentNode.insertBefore(dom.childNodes[0], img);
  458. img.onload = function () {
  459. if(!this.getAttribute('_load')) {
  460. this.setAttribute('_load', 1);
  461. this.style.width = this.style.height = '';
  462. this.parentNode.removeChild(this.previousSibling);
  463. if(this.getAttribute('lazyloadthumb')) {
  464. thumbImg(this);
  465. }
  466. }
  467. };
  468. img.style.width = img.style.height = '1px';
  469. img.setAttribute('src', img.getAttribute('file') ? img.getAttribute('file') : img.getAttribute('src'));
  470. img.setAttribute('lazyloaded', true);
  471. } else {
  472. imgs.push(img);
  473. }
  474. }
  475. lazyload.imgs = imgs;
  476. return true;
  477. };
  478. this.showImage();
  479. _attachEvent(window, 'scroll', function(){obj.showImage();});
  480. }
  481. function update_collection(){
  482. var obj = $('collectionnumber');
  483. sum = 1;
  484. obj.style.display = '';
  485. obj.innerText = parseInt(obj.innerText)+sum;
  486. }
  487. function display_blocked_post() {
  488. var movehiddendiv = (!$('hiddenposts').innerHTML) ? true : false;
  489. for (var i = 0; i < blockedPIDs.length; i++) {
  490. if(movehiddendiv) {
  491. $('hiddenposts').appendChild($("post_"+blockedPIDs[i]));
  492. }
  493. display("post_"+blockedPIDs[i]);
  494. }
  495. var postlistreply = $('postlistreply').innerHTML;
  496. $('hiddenpoststip').parentNode.removeChild($('postlistreply'));
  497. $('hiddenpoststip').parentNode.removeChild($('hiddenpoststip'));
  498. $('hiddenposts').innerHTML+='<div id="postlistreply" class="pl">'+postlistreply+'</div>';
  499. }
  500. function show_threadpage(pid, current, maxpage, ispreview) {
  501. if(!$('threadpage') || typeof tid == 'undefined') {
  502. return;
  503. };
  504. var clickvalue = function (page) {
  505. return 'ajaxget(\'forum.php?mod=viewthread&tid=' + tid + '&viewpid=' + pid + '&cp=' + page + (ispreview ? '&from=preview' : '') + '\', \'post_' + pid + '\', \'ajaxwaitid\');';
  506. };
  507. var pstart = current - 1;
  508. pstart = pstart < 1 ? 1 : pstart;
  509. var pend = current + 1;
  510. pend = pend > maxpage ? maxpage : pend;
  511. var s = '<div class="cm pgs mtm mbm cl"><div class="pg">';
  512. if(pstart > 1) {
  513. s += '<a href="javascript:;" onclick="' + clickvalue(1) + '">1 ...</a>';
  514. }
  515. for(i = pstart;i <= pend;i++) {
  516. s += i == current ? '<strong>' + i + '</strong>' : '<a href="javascript:;" onclick="' + clickvalue(i)+ '">' + i + '</a>';
  517. }
  518. if(pend < maxpage) {
  519. s += '<a href="javascript:;" onclick="' + clickvalue(maxpage)+ '">... ' + maxpage + '</a>';
  520. }
  521. if(current < maxpage) {
  522. s += '<a href="javascript:;" onclick="' + clickvalue(current + 1) + '" class="nxt">下一页</a>';
  523. }
  524. s += '<a href="javascript:;" onclick="' + clickvalue('all') + '">查看所有</a>';
  525. s += '</div></div>';
  526. $('threadpage').innerHTML = s;
  527. }
  528. var show_threadindex_data = '';
  529. function show_threadindex(pid, ispreview) {
  530. if(!show_threadindex_data) {
  531. var s = '<div class="tindex"><h3>目录</h3><ul>';
  532. for(i in $('threadindex').childNodes) {
  533. o = $('threadindex').childNodes[i];
  534. if(o.tagName == 'A') {
  535. var sub = o.getAttribute('sub').length * 2;
  536. o.href = "javascript:;";
  537. if(o.getAttribute('page')) {
  538. s += '<li style="margin-left:' + sub + 'em" onclick="ajaxget(\'forum.php?mod=viewthread&threadindex=yes&tid=' + tid + '&viewpid=' + pid + '&cp=' + o.getAttribute('page') + (ispreview ? '&from=preview' : '') + '\', \'post_' + pid + '\', \'ajaxwaitid\')">' + o.innerHTML + '</li>';
  539. } else if(o.getAttribute('tid') && o.getAttribute('pid')) {
  540. s += '<li style="margin-left:' + sub + 'em" onclick="ajaxget(\'forum.php?mod=viewthread&threadindex=yes&tid=' + o.getAttribute('tid') + '&viewpid=' + o.getAttribute('pid') + (ispreview ? '&from=preview' : '') + '\', \'post_' + pid + '\', \'ajaxwaitid\')">' + o.innerHTML + '</li>';
  541. }
  542. }
  543. }
  544. s += '</ul></div>';
  545. $('threadindex').innerHTML = s;
  546. show_threadindex_data = s;
  547. } else {
  548. $('threadindex').innerHTML = show_threadindex_data;
  549. }
  550. }
  551. function ctrlLeftInfo(sli_staticnum) {
  552. var sli = $('scrollleftinfo');
  553. var postlist_bottom = parseInt($('postlist').getBoundingClientRect().bottom);
  554. var sli_bottom = parseInt(sli.getBoundingClientRect().bottom);
  555. if(postlist_bottom < sli_staticnum && postlist_bottom != sli_bottom) {
  556. sli.style.top = (postlist_bottom - sli.offsetHeight - 5)+'px';
  557. } else{
  558. sli.style.top = 'auto';
  559. }
  560. }
  561. function fixed_avatar(pids, fixednv) {
  562. var fixedtopnv = fixednv ? new fixed_top_nv('nv', true) : false;
  563. if(fixednv) {
  564. fixedtopnv.init();
  565. }
  566. function fixedavatar(e) {
  567. var avatartop = fixednv ? fixedtopnv.run() : 0;
  568. for(var i = 0; i < pids.length; i++) {
  569. var pid = pids[i];
  570. var posttable = $('pid'+pid);
  571. var postavatar = $('favatar'+pid);
  572. if(!$('favatar'+pid)) {
  573. return;
  574. }
  575. var nextpost = $('_postposition'+pid);
  576. if(!postavatar || !nextpost || posttable.offsetHeight - 100 < postavatar.offsetHeight) {
  577. if(postavatar.style.position == 'fixed') {
  578. postavatar.style.position = '';
  579. }
  580. continue;
  581. }
  582. var avatarstyle = postavatar.style;
  583. posttabletop = parseInt(posttable.getBoundingClientRect().top);
  584. nextposttop = parseInt(nextpost.getBoundingClientRect().top);
  585. if(nextposttop > 0 && nextposttop <= postavatar.offsetHeight) {
  586. if(BROWSER.firefox) {
  587. if(avatarstyle.position != 'fixed') {
  588. avatarstyle.position = 'fixed';
  589. }
  590. avatarstyle.top = -(postavatar.offsetHeight - nextposttop)+'px';
  591. } else {
  592. postavatar.parentNode.style.position = 'relative';
  593. avatarstyle.top = '';
  594. avatarstyle.bottom = '0px';
  595. avatarstyle.position = 'absolute';
  596. }
  597. } else if(posttabletop < 0 && nextposttop > 0) {
  598. if(postavatar.parentNode.style.position != '') {
  599. postavatar.parentNode.style.position = '';
  600. }
  601. if(avatarstyle.position != 'fixed' || parseInt(avatarstyle.top) != avatartop) {
  602. avatarstyle.bottom = '';
  603. avatarstyle.top = avatartop + 'px';
  604. avatarstyle.position = 'fixed';
  605. }
  606. } else if(avatarstyle.position != '') {
  607. avatarstyle.position = '';
  608. }
  609. }
  610. }
  611. if(!(BROWSER.ie && BROWSER.ie < 7)) {
  612. _attachEvent(window, 'load', function(){_attachEvent(window, 'scroll', fixedavatar);});
  613. }
  614. }
  615. function submitpostpw(pid, tid) {
  616. var obj = $('postpw_' + pid);
  617. appendscript(JSPATH + 'md5.js?' + VERHASH);
  618. safescript('md5_js', function () {
  619. setcookie('postpw_' + pid, hex_md5(obj.value));
  620. if(!tid) {
  621. location.href = location.href;
  622. } else {
  623. location.href = 'forum.php?mod=viewthread&tid='+tid;
  624. }
  625. }, 100, 50);
  626. }
  627. function threadbegindisplay(type, w, h, s) {
  628. $('begincloseid').onclick = function() {
  629. $('threadbeginid').style.display = 'none';
  630. };
  631. var imgobj = $('threadbeginid');
  632. imgobj.style.left = (document.body.clientWidth - w)/2 + 'px';
  633. imgobj.style.top = (document.body.clientHeight - h)/2 + 'px';
  634. if(type == 1) {
  635. autozoom(w, h, s);
  636. } else if(type == 2) {
  637. autofade(w, h, s);
  638. } else {
  639. setTimeout(function() {
  640. $('threadbeginid').style.display = 'none';
  641. }, s);
  642. }
  643. }
  644. function autofade(w, h, s) {
  645. this.imgobj = $('threadbeginid');
  646. this.opacity = 0;
  647. this.fadein = function() {
  648. if(BROWSER.ie) {
  649. this.imgobj.filters.alpha.opacity = this.opacity;
  650. } else {
  651. this.imgobj.style.opacity = this.opacity/100;
  652. }
  653. if(this.opacity >= 100) {
  654. setTimeout(this.fadeout, s);
  655. return;
  656. }
  657. this.opacity++;
  658. setTimeout(this.fadein, 50);
  659. };
  660. this.fadeout = function() {
  661. if(BROWSER.ie) {
  662. this.imgobj.filters.alpha.opacity = this.opacity;
  663. } else {
  664. this.imgobj.style.opacity = this.opacity/100;
  665. }
  666. if(this.opacity <= 0) {
  667. this.imgobj.style.display = 'none';
  668. return;
  669. }
  670. this.opacity--;
  671. setTimeout(this.fadeout, 50);
  672. };
  673. this.fadein();
  674. }
  675. function autozoom(w, h, s) {
  676. this.height = 0;
  677. this.imgobj = $('threadbeginid');
  678. this.imgobj.style.overflow = 'hidden';
  679. this.imgobj.style.display = '';
  680. this.autozoomin = function() {
  681. this.height += 5;
  682. if(this.height >= h) {
  683. this.imgobj.style.height = h + 'px';
  684. setTimeout(this.autozoomout, s);
  685. return;
  686. }
  687. this.imgobj.style.height = this.height + 'px';
  688. setTimeout(this.autozoomin, 50);
  689. };
  690. this.autozoomout = function() {
  691. this.height -= 5;
  692. if(this.height <= 0) {
  693. this.imgobj.style.height = 0 + 'px';
  694. this.imgobj.style.display = 'none';
  695. return;
  696. }
  697. this.imgobj.style.height = this.height + 'px';
  698. setTimeout(this.autozoomout, 50);
  699. };
  700. this.autozoomin();
  701. }
  702. function readmode(title, pid) {
  703. var imagelist = '';
  704. if(aimgcount[pid]) {
  705. for(var i = 0; i < aimgcount[pid].length;i++) {
  706. var aimgObj = $('aimg_'+aimgcount[pid][i]);
  707. if(aimgObj.parentElement.className!="mbn") {
  708. var src = aimgObj.getAttribute('file');
  709. imagelist += '<div class="mbn"><img src="' + src + '" width="600" /></div>';
  710. }
  711. }
  712. }
  713. msg = $('postmessage_'+pid).innerHTML+imagelist;
  714. msg = '<div style="width:800px;max-height:500px; overflow-y:auto; padding: 10px;" class="pcb">'+msg+'</div>';
  715. showDialog(msg, 'info', title, null, 1);
  716. var coverObj = $('fwin_dialog_cover');
  717. coverObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=90)';
  718. coverObj.style.opacity = 0.9;
  719. }
  720. function changecontentdivid(tid) {
  721. if($('postlistreply')) {
  722. objtid = $('postlistreply').getAttribute('tid');
  723. if(objtid == tid) {
  724. return;
  725. }
  726. $('postlistreply').id = 'postlistreply_'+objtid;
  727. postnewdiv = $('postlistreply_'+objtid).childNodes;
  728. postnewdiv[postnewdiv.length-1].id = 'post_new_'+objtid;
  729. }
  730. $('postlistreply_'+tid).id = 'postlistreply';
  731. postnewdiv = $('postlistreply').childNodes;
  732. postnewdiv[postnewdiv.length-1].id = 'post_new';
  733. }
  734. function showmobilebbs(obj) {
  735. var content = '<h3 class="flb" style="cursor:move;"><em>下载掌上论坛</em><span><a href="javascript:;" class="flbc" onclick="hideWindow(\'mobilebbs\')" title="{lang close}">{lang close}</a></span></h3><div class="c"><h4>Andriod版本,扫描二维码可以直接下载到手机</h4><p class="mtm mbm vm"><span class="code_bg"><img src="'+ STATICURL +'image/common/zslt_andriod.png" alt="" /></span><img src="'+ STATICURL +'image/common/andriod.png" alt="适用于装有安卓系统的三星/HTC/小米等手机" /></p><h4>iPhone版本,扫描二维码可以直接下载到手机</h4><p class="mtm mbm vm"><span class="code_bg"><img src="'+ STATICURL +'image/common/zslt_ios.png" alt="" /></span><img src="'+ STATICURL +'image/common/ios.png" alt="适用于苹果手机" /></p></div>';
  736. showWindow('mobilebbs', content, 'html');
  737. }
  738. function succeedhandle_vfastpost(url, message, param) {
  739. $('vmessage').value = '';
  740. succeedhandle_fastpost(url, message, param);
  741. showCreditPrompt();
  742. }
  743. function vmessage() {
  744. var vf_tips = '#在这里快速回复#';
  745. $('vmessage').value = vf_tips;
  746. $('vmessage').style.color = '#CDCDCD';
  747. $('vmessage').onclick = function() {
  748. if($('vmessage').value==vf_tips) {
  749. $('vmessage').value='';
  750. $('vmessage').style.color="#000";
  751. }
  752. };
  753. $('vmessage').onblur = function() {
  754. if(!$('vmessage').value) {
  755. $('vmessage').value=vf_tips;
  756. $('vmessage').style.color="#CDCDCD";
  757. }
  758. };
  759. $('vreplysubmit').onclick = function() {
  760. if($('vmessage').value == vf_tips) {
  761. return false;
  762. }
  763. };
  764. $('vreplysubmit').onmouseover = function() {
  765. if($('vmessage').value != vf_tips) {
  766. ajaxget('forum.php?mod=ajax&action=checkpostrule&ac=reply', 'vfastpostseccheck');
  767. $('vreplysubmit').onmouseover = null;
  768. }
  769. };
  770. }