PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/static/js/common_extra.js

https://github.com/jinbo51/DiscuzX
JavaScript | 1271 lines | 1214 code | 51 blank | 6 comment | 384 complexity | dc21aadff1b357e12f950e16c30a6373 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*
  2. [Discuz!] (C)2001-2099 Comsenz Inc.
  3. This is NOT a freeware, use is subject to license terms
  4. $Id: common_extra.js 33043 2013-04-12 03:31:00Z monkey $
  5. */
  6. function _relatedlinks(rlinkmsgid) {
  7. if(!$(rlinkmsgid) || $(rlinkmsgid).innerHTML.match(/<script[^\>]*?>/i)) {
  8. return;
  9. }
  10. var alink = new Array(), ignore = new Array();
  11. var i = 0;
  12. var msg = $(rlinkmsgid).innerHTML;
  13. msg = msg.replace(/(<ignore_js_op\>[\s|\S]*?<\/ignore_js_op\>)/ig, function($1) {
  14. ignore[i] = $1;
  15. i++;
  16. return '#ignore_js_op '+(i - 1)+'#';
  17. });
  18. var alink_i = 0;
  19. msg = msg.replace(/(<a.*?<\/a\>)/ig, function($1) {
  20. alink[alink_i] = $1;
  21. alink_i++;
  22. return '#alink '+(alink_i - 1)+'#';
  23. });
  24. var relatedid = new Array();
  25. msg = msg.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
  26. for(var j = 0; j < relatedlink.length; j++) {
  27. if(relatedlink[j] && !relatedid[j]) {
  28. if(relatedlink[j]['surl'] != '') {
  29. var ra = '<a href="'+relatedlink[j]['surl']+'" target="_blank" class="relatedlink">'+relatedlink[j]['sname']+'</a>';
  30. alink[alink_i] = ra;
  31. ra = '#alink '+alink_i+'#';
  32. alink_i++;
  33. } else {
  34. var ra = '<strong><font color="#FF0000">'+relatedlink[j]['sname']+'</font></strong>';
  35. }
  36. var $rtmp = $3;
  37. $3 = $3.replace(relatedlink[j]['sname'], ra);
  38. if($3 != $rtmp) {
  39. relatedid[j] = 1;
  40. }
  41. }
  42. }
  43. return $2 + $3;
  44. });
  45. for(var k in alink) {
  46. msg = msg.replace('#alink '+k+'#', alink[k]);
  47. }
  48. for(var l in ignore) {
  49. msg = msg.replace('#ignore_js_op '+l+'#', ignore[l]);
  50. }
  51. $(rlinkmsgid).innerHTML = msg;
  52. }
  53. function _updatesecqaa(idhash) {
  54. if($('secqaa_' + idhash)) {
  55. $('secqaaverify_' + idhash).value = '';
  56. if(secST['qaa_' + idhash]) {
  57. clearTimeout(secST['qaa_' + idhash]);
  58. }
  59. $('checksecqaaverify_' + idhash).innerHTML = '<img src="'+ IMGDIR + '/none.gif" width="16" height="16" class="vm" />';
  60. ajaxget('misc.php?mod=secqaa&action=update&idhash=' + idhash, 'secqaa_' + idhash, null, '', '', function() {
  61. secST['qaa_' + idhash] = setTimeout(function() {$('secqaa_' + idhash).innerHTML = '<span class="xi2 cur1" onclick="updatesecqaa(\''+idhash+'\')">刷新验证问答</span>';}, 180000);
  62. });
  63. }
  64. }
  65. function _updateseccode(idhash, play) {
  66. if(isUndefined(play)) {
  67. if($('seccode_' + idhash)) {
  68. $('seccodeverify_' + idhash).value = '';
  69. if(secST['code_' + idhash]) {
  70. clearTimeout(secST['code_' + idhash]);
  71. }
  72. $('checkseccodeverify_' + idhash).innerHTML = '<img src="'+ IMGDIR + '/none.gif" width="16" height="16" class="vm" />';
  73. ajaxget('misc.php?mod=seccode&action=update&idhash=' + idhash, 'seccode_' + idhash, null, '', '', function() {
  74. secST['code_' + idhash] = setTimeout(function() {$('seccode_' + idhash).innerHTML = '<span class="xi2 cur1" onclick="updateseccode(\''+idhash+'\')">刷新验证码</span>';}, 180000);
  75. });
  76. }
  77. } else {
  78. eval('window.document.seccodeplayer_' + idhash + '.SetVariable("isPlay", "1")');
  79. }
  80. }
  81. function _checksec(type, idhash, showmsg, recall) {
  82. var showmsg = !showmsg ? 0 : showmsg;
  83. var secverify = $('sec' + type + 'verify_' + idhash).value;
  84. if(!secverify) {
  85. return;
  86. }
  87. var x = new Ajax('XML', 'checksec' + type + 'verify_' + idhash);
  88. x.loading = '';
  89. $('checksec' + type + 'verify_' + idhash).innerHTML = '<img src="'+ IMGDIR + '/loading.gif" width="16" height="16" class="vm" />';
  90. x.get('misc.php?mod=sec' + type + '&action=check&inajax=1&&idhash=' + idhash + '&secverify=' + (BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(secverify) : secverify), function(s){
  91. var obj = $('checksec' + type + 'verify_' + idhash);
  92. obj.style.display = '';
  93. if(s.substr(0, 7) == 'succeed') {
  94. obj.innerHTML = '<img src="'+ IMGDIR + '/check_right.gif" width="16" height="16" class="vm" />';
  95. if(showmsg) {
  96. recall(1);
  97. }
  98. } else {
  99. obj.innerHTML = '<img src="'+ IMGDIR + '/check_error.gif" width="16" height="16" class="vm" />';
  100. if(showmsg) {
  101. if(type == 'code') {
  102. showError('验证码错误,请重新填写');
  103. } else if(type == 'qaa') {
  104. showError('验证问答错误,请重新填写');
  105. }
  106. recall(0);
  107. }
  108. }
  109. });
  110. }
  111. function _setDoodle(fid, oid, url, tid, from) {
  112. if(tid == null) {
  113. hideWindow(fid);
  114. } else {
  115. $(tid).style.display = '';
  116. $(fid).style.display = 'none';
  117. }
  118. var doodleText = '[img]'+url+'[/img]';
  119. if($(oid) != null) {
  120. if(from == "editor") {
  121. insertImage(url);
  122. } else if(from == "fastpost") {
  123. seditor_insertunit('fastpost', doodleText);
  124. } else if(from == "forumeditor") {
  125. if(wysiwyg) {
  126. insertText('<img src="' + url + '" border="0" alt="" />', false);
  127. } else {
  128. insertText(doodleText, strlen(doodleText), 0);
  129. }
  130. } else {
  131. insertContent(oid, doodleText);
  132. }
  133. }
  134. }
  135. function _showdistrict(container, elems, totallevel, changelevel, containertype) {
  136. var getdid = function(elem) {
  137. var op = elem.options[elem.selectedIndex];
  138. return op['did'] || op.getAttribute('did') || '0';
  139. };
  140. var pid = changelevel >= 1 && elems[0] && $(elems[0]) ? getdid($(elems[0])) : 0;
  141. var cid = changelevel >= 2 && elems[1] && $(elems[1]) ? getdid($(elems[1])) : 0;
  142. var did = changelevel >= 3 && elems[2] && $(elems[2]) ? getdid($(elems[2])) : 0;
  143. var coid = changelevel >= 4 && elems[3] && $(elems[3]) ? getdid($(elems[3])) : 0;
  144. var url = "home.php?mod=misc&ac=ajax&op=district&container="+container+"&containertype="+containertype
  145. +"&province="+elems[0]+"&city="+elems[1]+"&district="+elems[2]+"&community="+elems[3]
  146. +"&pid="+pid + "&cid="+cid+"&did="+did+"&coid="+coid+'&level='+totallevel+'&handlekey='+container+'&inajax=1'+(!changelevel ? '&showdefault=1' : '');
  147. ajaxget(url, container, '');
  148. }
  149. function _copycode(obj) {
  150. if(!obj) return false;
  151. if(window.getSelection) {
  152. var sel = window.getSelection();
  153. if (sel.setBaseAndExtent) {
  154. sel.setBaseAndExtent(obj, 0, obj, 1);
  155. } else {
  156. var rng = document.createRange();
  157. rng.selectNodeContents(obj);
  158. sel.addRange(rng);
  159. }
  160. } else {
  161. var rng = document.body.createTextRange();
  162. rng.moveToElementText(obj);
  163. rng.select();
  164. }
  165. setCopy(BROWSER.ie ? obj.innerText.replace(/\r\n\r\n/g, '\r\n') : obj.textContent, '代码已复制到剪贴板');
  166. }
  167. function _setCopy(text, msg){
  168. if(BROWSER.ie) {
  169. var r = clipboardData.setData('Text', text);
  170. if(r) {
  171. if(msg) {
  172. showPrompt(null, null, '<span>' + msg + '</span>', 1500);
  173. }
  174. } else {
  175. showDialog('<div class="c"><div style="width: 200px; text-align: center;">复制失败,请选择“允许访问”</div></div>', 'alert');
  176. }
  177. } else {
  178. var msg = '<div class="c"><div style="width: 200px; text-align: center; text-decoration:underline;">点此复制到剪贴板</div>' +
  179. AC_FL_RunContent('id', 'clipboardswf', 'name', 'clipboardswf', 'devicefont', 'false', 'width', '200', 'height', '40', 'src', STATICURL + 'image/common/clipboard.swf', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent', 'style' , 'margin-top:-20px') + '</div>';
  180. showDialog(msg, 'info');
  181. text = text.replace(/[\xA0]/g, ' ');
  182. CLIPBOARDSWFDATA = text;
  183. }
  184. }
  185. function _showselect(obj, inpid, t, rettype) {
  186. var showselect_row = function (inpid, s, v, notime, rettype) {
  187. if(v >= 0) {
  188. if(!rettype) {
  189. var notime = !notime ? 0 : 1;
  190. var t = today.getTime();
  191. t += 86400000 * v;
  192. var d = new Date();
  193. d.setTime(t);
  194. var month = d.getMonth() + 1;
  195. month = month < 10 ? '0' + month : month;
  196. var day = d.getDate();
  197. day = day < 10 ? '0' + day : day;
  198. var hour = d.getHours();
  199. hour = hour < 10 ? '0' + hour : hour;
  200. var minute = d.getMinutes();
  201. minute = minute < 10 ? '0' + minute : minute;
  202. return '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'' + d.getFullYear() + '-' + month + '-' + day + (!notime ? ' ' + hour + ':' + minute: '') + '\'">' + s + '</a>';
  203. } else {
  204. return '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'' + v + '\'">' + s + '</a>';
  205. }
  206. } else if(v == -1) {
  207. return '<a href="javascript:;" onclick="$(\'' + inpid + '\').focus()">' + s + '</a>';
  208. } else if(v == -2) {
  209. return '<a href="javascript:;" onclick="$(\'' + inpid + '\').onclick()">' + s + '</a>';
  210. }
  211. };
  212. if(!obj.id) {
  213. var t = !t ? 0 : t;
  214. var rettype = !rettype ? 0 : rettype;
  215. obj.id = 'calendarexp_' + Math.random();
  216. div = document.createElement('div');
  217. div.id = obj.id + '_menu';
  218. div.style.display = 'none';
  219. div.className = 'p_pop';
  220. $('append_parent').appendChild(div);
  221. s = '';
  222. if(!t) {
  223. s += showselect_row(inpid, '一天', 1, 0, rettype);
  224. s += showselect_row(inpid, '一周', 7, 0, rettype);
  225. s += showselect_row(inpid, '一个月', 30, 0, rettype);
  226. s += showselect_row(inpid, '三个月', 90, 0, rettype);
  227. s += showselect_row(inpid, '自定义', -2);
  228. } else {
  229. if($(t)) {
  230. var lis = $(t).getElementsByTagName('LI');
  231. for(i = 0;i < lis.length;i++) {
  232. s += '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = this.innerHTML;$(\''+obj.id+'_menu\').style.display=\'none\'">' + lis[i].innerHTML + '</a>';
  233. }
  234. s += showselect_row(inpid, '自定义', -1);
  235. } else {
  236. s += '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'0\'">永久</a>';
  237. s += showselect_row(inpid, '7 天', 7, 1, rettype);
  238. s += showselect_row(inpid, '14 天', 14, 1, rettype);
  239. s += showselect_row(inpid, '一个月', 30, 1, rettype);
  240. s += showselect_row(inpid, '三个月', 90, 1, rettype);
  241. s += showselect_row(inpid, '半年', 182, 1, rettype);
  242. s += showselect_row(inpid, '一年', 365, 1, rettype);
  243. s += showselect_row(inpid, '自定义', -1);
  244. }
  245. }
  246. $(div.id).innerHTML = s;
  247. }
  248. showMenu({'ctrlid':obj.id,'evt':'click'});
  249. if(BROWSER.ie && BROWSER.ie < 7) {
  250. doane(event);
  251. }
  252. }
  253. function _zoom(obj, zimg, nocover, pn, showexif) {
  254. zimg = !zimg ? obj.src : zimg;
  255. showexif = !parseInt(showexif) ? 0 : showexif;
  256. if(!zoomstatus) {
  257. window.open(zimg, '', '');
  258. return;
  259. }
  260. if(!obj.id) obj.id = 'img_' + Math.random();
  261. var faid = !obj.getAttribute('aid') ? 0 : obj.getAttribute('aid');
  262. var menuid = 'imgzoom';
  263. var menu = $(menuid);
  264. var zoomid = menuid + '_zoom';
  265. var imgtitle = !nocover && obj.title ? '<div class="imgzoom_title">' + htmlspecialchars(obj.title) + '</div>' +
  266. (showexif ? '<div id="' + zoomid + '_exif" class="imgzoom_exif" onmouseover="this.className=\'imgzoom_exif imgzoom_exif_hover\'" onmouseout="this.className=\'imgzoom_exif\'"></div>' : '')
  267. : '';
  268. var cover = !nocover ? 1 : 0;
  269. var pn = !pn ? 0 : 1;
  270. var maxh = (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight) - 70;
  271. var loadCheck = function (obj) {
  272. if(obj.complete) {
  273. var imgw = loading.width;
  274. var imgh = loading.height;
  275. var r = imgw / imgh;
  276. var w = document.body.clientWidth * 0.95;
  277. w = imgw > w ? w : imgw;
  278. var h = w / r;
  279. if(w < 100 & h < 100) {
  280. $(menuid + '_waiting').style.display = 'none';
  281. hideMenu();
  282. return;
  283. }
  284. if(h > maxh) {
  285. h = maxh;
  286. w = h * r;
  287. }
  288. if($(menuid)) {
  289. $(menuid).removeAttribute('top_');$(menuid).removeAttribute('left_');
  290. clearTimeout($(menuid).getAttribute('timer'));
  291. }
  292. showimage(zimg, w, h, imgw, imgh);
  293. if(showexif && faid) {
  294. var x = new Ajax();
  295. x.get('forum.php?mod=ajax&action=exif&aid=' + faid + '&inajax=1', function(s, x) {
  296. if(s) {
  297. $(zoomid + '_exif').style.display = '';
  298. $(zoomid + '_exif').innerHTML = s;
  299. } else {
  300. $(zoomid + '_exif').style.display = 'none';
  301. }
  302. });
  303. }
  304. } else {
  305. setTimeout(function () { loadCheck(loading); }, 100);
  306. }
  307. };
  308. var showloading = function (zimg, pn) {
  309. if(!pn) {
  310. if(!$(menuid + '_waiting')) {
  311. waiting = document.createElement('img');
  312. waiting.id = menuid + '_waiting';
  313. waiting.src = IMGDIR + '/imageloading.gif';
  314. waiting.style.opacity = '0.8';
  315. waiting.style.filter = 'alpha(opacity=80)';
  316. waiting.style.position = 'absolute';
  317. waiting.style.zIndex = '100000';
  318. $('append_parent').appendChild(waiting);
  319. }
  320. }
  321. $(menuid + '_waiting').style.display = '';
  322. $(menuid + '_waiting').style.left = (document.body.clientWidth - 42) / 2 + 'px';
  323. $(menuid + '_waiting').style.top = ((document.documentElement.clientHeight - 42) / 2 + Math.max(document.documentElement.scrollTop, document.body.scrollTop)) + 'px';
  324. loading = new Image();
  325. setTimeout(function () { loadCheck(loading); }, 100);
  326. if(!pn) {
  327. $(menuid + '_zoomlayer').style.display = 'none';
  328. }
  329. loading.src = zimg;
  330. };
  331. var adjustpn = function(h) {
  332. h = h < 90 ? 90 : h;
  333. if($('zimg_prev')) {
  334. $('zimg_prev').style.height= parseInt(h) + 'px';
  335. }
  336. if($('zimg_next')) {
  337. $('zimg_next').style.height= parseInt(h) + 'px';
  338. }
  339. };
  340. var showimage = function (zimg, w, h, imgw, imgh) {
  341. $(menuid + '_waiting').style.display = 'none';
  342. $(menuid + '_zoomlayer').style.display = '';
  343. $(menuid + '_img').style.width = 'auto';
  344. $(menuid + '_img').style.height = 'auto';
  345. $(menuid).style.width = (w < 300 ? 320 : w + 20) + 'px';
  346. mheight = h + 63;
  347. menu.style.height = mheight + 'px';
  348. $(menuid + '_zoomlayer').style.height = (mheight < 120 ? 120 : mheight) + 'px';
  349. $(menuid + '_img').innerHTML = '<img id="' + zoomid + '" src="' + zimg + '" width="' + w + '" height="' + h + '" w="' + imgw + '" h="' + imgh + '" />' + imgtitle;
  350. if($(menuid + '_imglink')) {
  351. $(menuid + '_imglink').href = zimg;
  352. }
  353. setMenuPosition('', menuid, '00');
  354. adjustpn(h);
  355. };
  356. var adjustTimer = 0;
  357. var adjustTimerCount = 0;
  358. var wheelDelta = 0;
  359. var clientX = 0;
  360. var clientY = 0;
  361. var adjust = function(e, a) {
  362. if(BROWSER.ie && BROWSER.ie<7) {
  363. } else {
  364. if(adjustTimerCount) {
  365. adjustTimer = (function(){
  366. return setTimeout(function () {
  367. adjustTimerCount++;
  368. adjust(e);
  369. }, 20);
  370. })();
  371. $(menuid).setAttribute('timer', adjustTimer);
  372. if(adjustTimerCount > 17) {
  373. clearTimeout(adjustTimer);
  374. adjustTimerCount = 0;
  375. doane();
  376. }
  377. } else if(!a) {
  378. adjustTimerCount = 1;
  379. if(adjustTimer) {
  380. clearTimeout(adjustTimer);
  381. adjust(e, a);
  382. } else {
  383. adjust(e, a);
  384. }
  385. doane();
  386. }
  387. }
  388. var ele = $(zoomid);
  389. if(!ele) {
  390. return;
  391. }
  392. var imgw = ele.getAttribute('w');
  393. var imgh = ele.getAttribute('h');
  394. if(!a) {
  395. e = e || window.event;
  396. try {
  397. if(e.altKey || e.shiftKey || e.ctrlKey) return;
  398. } catch (e) {
  399. e = {'wheelDelta':wheelDelta, 'clientX':clientX, 'clientY':clientY};
  400. }
  401. var step = 0;
  402. if(e.wheelDelta <= 0 || e.detail > 0) {
  403. if(ele.width - 1 <= 200 || ele.height - 1 <= 200) {
  404. clearTimeout(adjustTimer);
  405. adjustTimerCount = 0;
  406. doane(e);return;
  407. }
  408. step = parseInt(imgw/ele.width)-4;
  409. } else {
  410. if(ele.width + 1 >= imgw*40) {
  411. clearTimeout(adjustTimer);
  412. adjustTimerCount = 0;
  413. doane(e);return;
  414. }
  415. step = 4-parseInt(imgw/ele.width) || 2;
  416. }
  417. if(BROWSER.ie && BROWSER.ie<7) { step *= 5;}
  418. wheelDelta = e.wheelDelta;
  419. clientX = e.clientX;
  420. clientY = e.clientY;
  421. var ratio = 0;
  422. if(imgw > imgh) {
  423. ratio = step/ele.height;
  424. ele.height += step;
  425. ele.width = imgw*(ele.height/imgh);
  426. } else if(imgw < imgh) {
  427. ratio = step/ele.width;
  428. ele.width += step;
  429. ele.height = imgh*(ele.width/imgw);
  430. }
  431. if(BROWSER.ie && BROWSER.ie<7) {
  432. setMenuPosition('', menuid, '00');
  433. } else {
  434. var menutop = parseFloat(menu.getAttribute('top_') || menu.style.top);
  435. var menuleft = parseFloat(menu.getAttribute('left_') || menu.style.left);
  436. var imgY = clientY - menutop - 39;
  437. var imgX = clientX - menuleft - 10;
  438. var newTop = (menutop - imgY*ratio) + 'px';
  439. var newLeft = (menuleft - imgX*ratio) + 'px';
  440. menu.style.top = newTop;
  441. menu.style.left = newLeft;
  442. menu.setAttribute('top_', newTop);
  443. menu.setAttribute('left_', newLeft);
  444. }
  445. } else {
  446. ele.width = imgw;
  447. ele.height = imgh;
  448. }
  449. menu.style.width = (parseInt(ele.width < 300 ? 300 : parseInt(ele.width)) + 20) + 'px';
  450. var mheight = (parseInt(ele.height) + 50);
  451. menu.style.height = mheight + 'px';
  452. $(menuid + '_zoomlayer').style.height = (mheight < 120 ? 120 : mheight) + 'px';
  453. adjustpn(ele.height);
  454. doane(e);
  455. };
  456. if(!menu && !pn) {
  457. menu = document.createElement('div');
  458. menu.id = menuid;
  459. if(cover) {
  460. menu.innerHTML = '<div class="zoominner" id="' + menuid + '_zoomlayer" style="display:none"><p><span class="y"><a id="' + menuid + '_imglink" class="imglink" target="_blank" title="在新窗口打开">在新窗口打开</a><a id="' + menuid + '_adjust" href="javascipt:;" class="imgadjust" title="实际大小">实际大小</a>' +
  461. '<a href="javascript:;" onclick="hideMenu()" class="imgclose" title="关闭">关闭</a></span>鼠标滚轮缩放图片</p>' +
  462. '<div class="zimg_p" id="' + menuid + '_picpage"></div><div class="hm" id="' + menuid + '_img"></div></div>';
  463. } else {
  464. menu.innerHTML = '<div class="popupmenu_popup" id="' + menuid + '_zoomlayer" style="width:auto"><span class="right y"><a href="javascript:;" onclick="hideMenu()" class="flbc" style="width:20px;margin:0 0 2px 0">关闭</a></span>鼠标滚轮缩放图片<div class="zimg_p" id="' + menuid + '_picpage"></div><div class="hm" id="' + menuid + '_img"></div></div>';
  465. }
  466. if(BROWSER.ie || BROWSER.chrome){
  467. menu.onmousewheel = adjust;
  468. } else {
  469. menu.addEventListener('DOMMouseScroll', adjust, false);
  470. }
  471. $('append_parent').appendChild(menu);
  472. if($(menuid + '_adjust')) {
  473. $(menuid + '_adjust').onclick = function(e) {adjust(e, 1)};
  474. }
  475. }
  476. showloading(zimg, pn);
  477. picpage = '';
  478. $(menuid + '_picpage').innerHTML = '';
  479. if(typeof zoomgroup == 'object' && zoomgroup[obj.id] && typeof aimgcount == 'object' && aimgcount[zoomgroup[obj.id]]) {
  480. authorimgs = aimgcount[zoomgroup[obj.id]];
  481. var aid = obj.id.substr(5), authorlength = authorimgs.length, authorcurrent = '';
  482. if(authorlength > 1) {
  483. for(i = 0; i < authorlength;i++) {
  484. if(aid == authorimgs[i]) {
  485. authorcurrent = i;
  486. }
  487. }
  488. if(authorcurrent !== '') {
  489. paid = authorcurrent > 0 ? authorimgs[authorcurrent - 1] : authorimgs[authorlength - 1];
  490. picpage += ' <div id="zimg_prev" onmouseover="dragMenuDisabled=true;this.style.backgroundPosition=\'0 50px\'" onmouseout="dragMenuDisabled=false;this.style.backgroundPosition=\'0 -100px\';" onclick="_zoom_page(\'' + paid + '\', ' + (showexif ? 1 : 0) + ')" class="zimg_prev"><strong>上一张</strong></div> ';
  491. paid = authorcurrent < authorlength - 1 ? authorimgs[authorcurrent + 1] : authorimgs[0];
  492. picpage += ' <div id="zimg_next" onmouseover="dragMenuDisabled=true;this.style.backgroundPosition=\'100% 50px\'" onmouseout="dragMenuDisabled=false;this.style.backgroundPosition=\'100% -100px\';" onclick="_zoom_page(\'' + paid + '\', ' + (showexif ? 1 : 0) + ')" class="zimg_next"><strong>下一张</strong></div> ';
  493. }
  494. if(picpage) {
  495. $(menuid + '_picpage').innerHTML = picpage;
  496. }
  497. }
  498. }
  499. showMenu({'ctrlid':obj.id,'menuid':menuid,'duration':3,'pos':'00','cover':cover,'drag':menuid,'maxh':''});
  500. }
  501. function _zoom_page(paid, showexif) {
  502. var imagesrc = $('aimg_' + paid).getAttribute('zoomfile') ? $('aimg_' + paid).getAttribute('zoomfile') : $('aimg_' + paid).getAttribute('file');
  503. zoom($('aimg_' + paid), imagesrc, 0, 1, showexif ? 1 : 0);
  504. }
  505. function _switchTab(prefix, current, total, activeclass) {
  506. activeclass = !activeclass ? 'a' : activeclass;
  507. for(var i = 1; i <= total;i++) {
  508. var classname = ' '+$(prefix + '_' + i).className+' ';
  509. $(prefix + '_' + i).className = classname.replace(' '+activeclass+' ','').substr(1);
  510. $(prefix + '_c_' + i).style.display = 'none';
  511. }
  512. $(prefix + '_' + current).className = $(prefix + '_' + current).className + ' '+activeclass;
  513. $(prefix + '_c_' + current).style.display = '';
  514. }
  515. function _initTab(frameId, type) {
  516. if (typeof document['diyform'] == 'object' || $(frameId).className.indexOf('tab') < 0) return false;
  517. type = type || 'click';
  518. var tabs = $(frameId+'_title').childNodes;
  519. var arrTab = [];
  520. for(var i in tabs) {
  521. if (tabs[i]['nodeType'] == 1 && tabs[i]['className'].indexOf('move-span') > -1) {
  522. arrTab.push(tabs[i]);
  523. }
  524. }
  525. var counter = 0;
  526. var tab = document.createElement('ul');
  527. tab.className = 'tb cl';
  528. var len = arrTab.length;
  529. for(var i = 0;i < len; i++) {
  530. var tabId = arrTab[i].id;
  531. if (hasClass(arrTab[i],'frame') || hasClass(arrTab[i],'tab')) {
  532. var arrColumn = [];
  533. for (var j in arrTab[i].childNodes) {
  534. if (typeof arrTab[i].childNodes[j] == 'object' && !hasClass(arrTab[i].childNodes[j],'title')) arrColumn.push(arrTab[i].childNodes[j]);
  535. }
  536. var frameContent = document.createElement('div');
  537. frameContent.id = tabId+'_content';
  538. frameContent.className = hasClass(arrTab[i],'frame') ? 'content cl '+arrTab[i].className.substr(arrTab[i].className.lastIndexOf(' ')+1) : 'content cl';
  539. var colLen = arrColumn.length;
  540. for (var k = 0; k < colLen; k++) {
  541. frameContent.appendChild(arrColumn[k]);
  542. }
  543. } else {
  544. var frameContent = $(tabId+'_content');
  545. frameContent = frameContent || document.createElement('div');
  546. }
  547. frameContent.style.display = counter ? 'none' : '';
  548. $(frameId+'_content').appendChild(frameContent);
  549. var li = document.createElement('li');
  550. li.id = tabId;
  551. li.className = counter ? '' : 'a';
  552. var reg = new RegExp('style=\"(.*?)\"', 'gi');
  553. var matchs = '', style = '', imgs = '';
  554. while((matchs = reg.exec(arrTab[i].innerHTML))) {
  555. if(matchs[1].substr(matchs[1].length,1) != ';') {
  556. matchs[1] += ';';
  557. }
  558. style += matchs[1];
  559. }
  560. style = style ? ' style="'+style+'"' : '';
  561. reg = new RegExp('(<img.*?>)', 'gi');
  562. while((matchs = reg.exec(arrTab[i].innerHTML))) {
  563. imgs += matchs[1];
  564. }
  565. li.innerHTML = arrTab[i]['innerText'] ? arrTab[i]['innerText'] : arrTab[i]['textContent'];
  566. var a = arrTab[i].getElementsByTagName('a');
  567. var href = a && a[0] ? a[0].href : 'javascript:;';
  568. var onclick = type == 'click' ? ' onclick="return false;"' : '';
  569. li.innerHTML = '<a href="' + href + '"' + onclick + ' onfocus="this.blur();" ' + style + '>' + imgs + li.innerHTML + '</a>';
  570. _attachEvent(li, type, switchTabUl);
  571. tab.appendChild(li);
  572. $(frameId+'_title').removeChild(arrTab[i]);
  573. counter++;
  574. }
  575. $(frameId+'_title').appendChild(tab);
  576. }
  577. function switchTabUl (e) {
  578. e = e || window.event;
  579. var aim = e.target || e.srcElement;
  580. var tabId = aim.id;
  581. var parent = aim.parentNode;
  582. while(parent['nodeName'] != 'UL' && parent['nodeName'] != 'BODY') {
  583. tabId = parent.id;
  584. parent = parent.parentNode;
  585. }
  586. if(parent['nodeName'] == 'BODY') return false;
  587. var tabs = parent.childNodes;
  588. var len2 = tabs.length;
  589. for(var j = 0; j < len2; j++) {
  590. tabs[j].className = (tabs[j].id == tabId) ? 'a' : '';
  591. var content = $(tabs[j].id+'_content');
  592. if (content) content.style.display = tabs[j].id == tabId ? '' : 'none';
  593. }
  594. }
  595. function slideshow(el) {
  596. var obj = this;
  597. if(!el.id) el.id = Math.random();
  598. if(typeof slideshow.entities == 'undefined') {
  599. slideshow.entities = {};
  600. }
  601. this.id = el.id;
  602. if(slideshow.entities[this.id]) return false;
  603. slideshow.entities[this.id] = this;
  604. this.slideshows = [];
  605. this.slidebar = [];
  606. this.slideother = [];
  607. this.slidebarup = '';
  608. this.slidebardown = '';
  609. this.slidenum = 0;
  610. this.slidestep = 0;
  611. this.container = el;
  612. this.imgs = [];
  613. this.imgLoad = [];
  614. this.imgLoaded = 0;
  615. this.imgWidth = 0;
  616. this.imgHeight = 0;
  617. this.getMEvent = function(ele, value) {
  618. value = !value ? 'mouseover' : value;
  619. var mevent = !ele ? '' : ele.getAttribute('mevent');
  620. mevent = (mevent == 'click' || mevent == 'mouseover') ? mevent : value;
  621. return mevent;
  622. };
  623. this.slideshows = $C('slideshow', el);
  624. this.slideshows = this.slideshows.length>0 ? this.slideshows[0].childNodes : null;
  625. this.slidebar = $C('slidebar', el);
  626. this.slidebar = this.slidebar.length>0 ? this.slidebar[0] : null;
  627. this.barmevent = this.getMEvent(this.slidebar);
  628. this.slideother = $C('slideother', el);
  629. this.slidebarup = $C('slidebarup', el);
  630. this.slidebarup = this.slidebarup.length>0 ? this.slidebarup[0] : null;
  631. this.barupmevent = this.getMEvent(this.slidebarup, 'click');
  632. this.slidebardown = $C('slidebardown', el);
  633. this.slidebardown = this.slidebardown.length>0 ? this.slidebardown[0] : null;
  634. this.bardownmevent = this.getMEvent(this.slidebardown, 'click');
  635. this.slidenum = parseInt(this.container.getAttribute('slidenum'));
  636. this.slidestep = parseInt(this.container.getAttribute('slidestep'));
  637. this.timestep = parseInt(this.container.getAttribute('timestep'));
  638. this.timestep = !this.timestep ? 2500 : this.timestep;
  639. this.index = this.length = 0;
  640. this.slideshows = !this.slideshows ? filterTextNode(el.childNodes) : filterTextNode(this.slideshows);
  641. this.length = this.slideshows.length;
  642. for(i=0; i<this.length; i++) {
  643. this.slideshows[i].style.display = "none";
  644. _attachEvent(this.slideshows[i], 'mouseover', function(){obj.stop();});
  645. _attachEvent(this.slideshows[i], 'mouseout', function(){obj.goon();});
  646. }
  647. for(i=0, L=this.slideother.length; i<L; i++) {
  648. for(var j=0;j<this.slideother[i].childNodes.length;j++) {
  649. if(this.slideother[i].childNodes[j].nodeType == 1) {
  650. this.slideother[i].childNodes[j].style.display = "none";
  651. }
  652. }
  653. }
  654. if(!this.slidebar) {
  655. if(!this.slidenum && !this.slidestep) {
  656. this.container.parentNode.style.position = 'relative';
  657. this.slidebar = document.createElement('div');
  658. this.slidebar.className = 'slidebar';
  659. this.slidebar.style.position = 'absolute';
  660. this.slidebar.style.top = '5px';
  661. this.slidebar.style.left = '4px';
  662. this.slidebar.style.display = 'none';
  663. var html = '<ul>';
  664. for(var i=0; i<this.length; i++) {
  665. html += '<li on'+this.barmevent+'="slideshow.entities[' + this.id + '].xactive(' + i + '); return false;">' + (i + 1).toString() + '</li>';
  666. }
  667. html += '</ul>';
  668. this.slidebar.innerHTML = html;
  669. this.container.parentNode.appendChild(this.slidebar);
  670. this.controls = this.slidebar.getElementsByTagName('li');
  671. }
  672. } else {
  673. this.controls = filterTextNode(this.slidebar.childNodes);
  674. for(i=0; i<this.controls.length; i++) {
  675. if(this.slidebarup == this.controls[i] || this.slidebardown == this.controls[i]) continue;
  676. _attachEvent(this.controls[i], this.barmevent, function(){slidexactive()});
  677. _attachEvent(this.controls[i], 'mouseout', function(){obj.goon();});
  678. }
  679. }
  680. if(this.slidebarup) {
  681. _attachEvent(this.slidebarup, this.barupmevent, function(){slidexactive('up')});
  682. }
  683. if(this.slidebardown) {
  684. _attachEvent(this.slidebardown, this.bardownmevent, function(){slidexactive('down')});
  685. }
  686. this.activeByStep = function(index) {
  687. var showindex = 0,i = 0;
  688. if(index == 'down') {
  689. showindex = this.index + 1;
  690. if(showindex > this.length) {
  691. this.runRoll();
  692. } else {
  693. for (i = 0; i < this.slidestep; i++) {
  694. if(showindex >= this.length) showindex = 0;
  695. this.index = this.index - this.slidenum + 1;
  696. if(this.index < 0) this.index = this.length + this.index;
  697. this.active(showindex);
  698. showindex++;
  699. }
  700. }
  701. } else if (index == 'up') {
  702. var tempindex = this.index;
  703. showindex = this.index - this.slidenum;
  704. if(showindex < 0) return false;
  705. for (i = 0; i < this.slidestep; i++) {
  706. if(showindex < 0) showindex = this.length - Math.abs(showindex);
  707. this.active(showindex);
  708. this.index = tempindex = tempindex - 1;
  709. if(this.index <0) this.index = this.length - 1;
  710. showindex--;
  711. }
  712. }
  713. return false;
  714. };
  715. this.active = function(index) {
  716. this.slideshows[this.index].style.display = "none";
  717. this.slideshows[index].style.display = "block";
  718. if(this.controls && this.controls.length > 0) {
  719. this.controls[this.index].className = '';
  720. this.controls[index].className = 'on';
  721. }
  722. for(var i=0,L=this.slideother.length; i<L; i++) {
  723. this.slideother[i].childNodes[this.index].style.display = "none";
  724. this.slideother[i].childNodes[index].style.display = "block";
  725. }
  726. this.index = index;
  727. };
  728. this.xactive = function(index) {
  729. if(!this.slidenum && !this.slidestep) {
  730. this.stop();
  731. if(index == 'down') index = this.index == this.length-1 ? 0 : this.index+1;
  732. if(index == 'up') index = this.index == 0 ? this.length-1 : this.index-1;
  733. this.active(index);
  734. } else {
  735. this.activeByStep(index);
  736. }
  737. };
  738. this.goon = function() {
  739. this.stop();
  740. var curobj = this;
  741. this.timer = setTimeout(function () {
  742. curobj.run();
  743. }, this.timestep);
  744. };
  745. this.stop = function() {
  746. clearTimeout(this.timer);
  747. };
  748. this.run = function() {
  749. var index = this.index + 1 < this.length ? this.index + 1 : 0;
  750. if(!this.slidenum && !this.slidestep) {
  751. this.active(index);
  752. } else {
  753. this.activeByStep('down');
  754. }
  755. var ss = this;
  756. this.timer = setTimeout(function(){
  757. ss.run();
  758. }, this.timestep);
  759. };
  760. this.runRoll = function() {
  761. for(var i = 0; i < this.slidenum; i++) {
  762. if(this.slideshows[i] && typeof this.slideshows[i].style != 'undefined') this.slideshows[i].style.display = 'block';
  763. for(var j=0,L=this.slideother.length; j<L; j++) {
  764. this.slideother[j].childNodes[i].style.display = 'block';
  765. }
  766. }
  767. this.index = this.slidenum - 1;
  768. };
  769. var imgs = this.slideshows.length ? this.slideshows[0].parentNode.getElementsByTagName('img') : [];
  770. for(i=0, L=imgs.length; i<L; i++) {
  771. this.imgs.push(imgs[i]);
  772. this.imgLoad.push(new Image());
  773. this.imgLoad[i].onerror = function (){obj.imgLoaded ++;};
  774. this.imgLoad[i].src = this.imgs[i].src;
  775. }
  776. this.getSize = function () {
  777. if(this.imgs.length == 0) return false;
  778. var img = this.imgs[0];
  779. this.imgWidth = img.width ? parseInt(img.width) : 0;
  780. this.imgHeight = img.height ? parseInt(img.height) : 0;
  781. var ele = img.parentNode;
  782. while ((!this.imgWidth || !this.imgHeight) && !hasClass(ele,'slideshow') && ele != document.body) {
  783. this.imgWidth = ele.style.width ? parseInt(ele.style.width) : 0;
  784. this.imgHeight = ele.style.height ? parseInt(ele.style.height) : 0;
  785. ele = ele.parentNode;
  786. }
  787. return true;
  788. };
  789. this.getSize();
  790. this.checkLoad = function () {
  791. var obj = this;
  792. this.container.style.display = 'block';
  793. for(i = 0;i < this.imgs.length;i++) {
  794. if(this.imgLoad[i].complete && !this.imgLoad[i].status) {
  795. this.imgLoaded++;
  796. this.imgLoad[i].status = 1;
  797. }
  798. }
  799. var percentEle = $(this.id+'_percent');
  800. if(this.imgLoaded < this.imgs.length) {
  801. if (!percentEle) {
  802. var dom = document.createElement('div');
  803. dom.id = this.id+"_percent";
  804. dom.style.width = this.imgWidth ? this.imgWidth+'px' : '150px';
  805. dom.style.height = this.imgHeight ? this.imgHeight+'px' : '150px';
  806. dom.style.lineHeight = this.imgHeight ? this.imgHeight+'px' : '150px';
  807. dom.style.backgroundColor = '#ccc';
  808. dom.style.textAlign = 'center';
  809. dom.style.top = '0';
  810. dom.style.left = '0';
  811. dom.style.marginLeft = 'auto';
  812. dom.style.marginRight = 'auto';
  813. this.slideshows[0].parentNode.appendChild(dom);
  814. percentEle = dom;
  815. }
  816. el.parentNode.style.position = 'relative';
  817. percentEle.innerHTML = (parseInt(this.imgLoaded / this.imgs.length * 100)) + '%';
  818. setTimeout(function () {obj.checkLoad();}, 100);
  819. } else {
  820. if (percentEle) percentEle.parentNode.removeChild(percentEle);
  821. if(this.slidebar) this.slidebar.style.display = '';
  822. this.index = this.length - 1 < 0 ? 0 : this.length - 1;
  823. if(this.slideshows.length > 0) {
  824. if(!this.slidenum || !this.slidestep) {
  825. this.run();
  826. } else {
  827. this.runRoll();
  828. }
  829. }
  830. }
  831. };
  832. this.checkLoad();
  833. }
  834. function slidexactive(step) {
  835. var e = getEvent();
  836. var aim = e.target || e.srcElement;
  837. var parent = aim.parentNode;
  838. var xactivei = null, slideboxid = null,currentslideele = null;
  839. currentslideele = hasClass(aim, 'slidebarup') || hasClass(aim, 'slidebardown') || hasClass(parent, 'slidebar') ? aim : null;
  840. while(parent && parent != document.body) {
  841. if(!currentslideele && hasClass(parent, 'slidebar')) {
  842. currentslideele = parent;
  843. }
  844. if(!currentslideele && (hasClass(parent, 'slidebarup') || hasClass(parent, 'slidebardown'))) {
  845. currentslideele = parent;
  846. }
  847. if(hasClass(parent, 'slidebox')) {
  848. slideboxid = parent.id;
  849. break;
  850. }
  851. parent = parent.parentNode;
  852. }
  853. var slidebar = $C('slidebar', parent);
  854. var children = slidebar.length == 0 ? [] : filterTextNode(slidebar[0].childNodes);
  855. if(currentslideele && (hasClass(currentslideele, 'slidebarup') || hasClass(currentslideele, 'slidebardown'))) {
  856. xactivei = step;
  857. } else {
  858. for(var j=0,i=0,L=children.length;i<L;i++){
  859. if(currentslideele && children[i] == currentslideele) {
  860. xactivei = j;
  861. break;
  862. }
  863. if(!hasClass(children[i], 'slidebarup') && !hasClass(children[i], 'slidebardown')) j++;
  864. }
  865. }
  866. if(slideboxid != null && xactivei != null) slideshow.entities[slideboxid].xactive(xactivei);
  867. }
  868. function filterTextNode(list) {
  869. var newlist = [];
  870. for(var i=0; i<list.length; i++) {
  871. if (list[i].nodeType == 1) {
  872. newlist.push(list[i]);
  873. }
  874. }
  875. return newlist;
  876. }
  877. function _runslideshow() {
  878. var slideshows = $C('slidebox');
  879. for(var i=0,L=slideshows.length; i<L; i++) {
  880. new slideshow(slideshows[i]);
  881. }
  882. }
  883. function _showTip(ctrlobj) {
  884. if(!ctrlobj.id) {
  885. ctrlobj.id = 'tip_' + Math.random();
  886. }
  887. menuid = ctrlobj.id + '_menu';
  888. if(!$(menuid)) {
  889. var div = document.createElement('div');
  890. div.id = ctrlobj.id + '_menu';
  891. div.className = 'tip tip_4';
  892. div.style.display = 'none';
  893. div.innerHTML = '<div class="tip_horn"></div><div class="tip_c">' + ctrlobj.getAttribute('tip') + '</div>';
  894. $('append_parent').appendChild(div);
  895. }
  896. $(ctrlobj.id).onmouseout = function () { hideMenu('', 'prompt'); };
  897. showMenu({'mtype':'prompt','ctrlid':ctrlobj.id,'pos':'12!','duration':2,'zindex':JSMENU['zIndex']['prompt']});
  898. }
  899. function _showPrompt(ctrlid, evt, msg, timeout, classname) {
  900. var menuid = ctrlid ? ctrlid + '_pmenu' : 'ntcwin';
  901. var duration = timeout ? 0 : 3;
  902. if($(menuid)) {
  903. $(menuid).parentNode.removeChild($(menuid));
  904. }
  905. var div = document.createElement('div');
  906. div.id = menuid;
  907. div.className = !classname ? (ctrlid ? 'tip tip_js' : 'ntcwin') : classname;
  908. div.style.display = 'none';
  909. $('append_parent').appendChild(div);
  910. if(ctrlid) {
  911. msg = '<div id="' + ctrlid + '_prompt"><div class="tip_horn"></div><div class="tip_c">' + msg + '</div>';
  912. } else {
  913. msg = '<table cellspacing="0" cellpadding="0" class="popupcredit"><tr><td class="pc_l">&nbsp;</td><td class="pc_c"><div class="pc_inner">' + msg +
  914. '</td><td class="pc_r">&nbsp;</td></tr></table>';
  915. }
  916. div.innerHTML = msg;
  917. if(ctrlid) {
  918. if(!timeout) {
  919. evt = 'click';
  920. }
  921. if($(ctrlid)) {
  922. if($(ctrlid).evt !== false) {
  923. var prompting = function() {
  924. showMenu({'mtype':'prompt','ctrlid':ctrlid,'evt':evt,'menuid':menuid,'pos':'210'});
  925. };
  926. if(evt == 'click') {
  927. $(ctrlid).onclick = prompting;
  928. } else {
  929. $(ctrlid).onmouseover = prompting;
  930. }
  931. }
  932. showMenu({'mtype':'prompt','ctrlid':ctrlid,'evt':evt,'menuid':menuid,'pos':'210','duration':duration,'timeout':timeout,'zindex':JSMENU['zIndex']['prompt']});
  933. $(ctrlid).unselectable = false;
  934. }
  935. } else {
  936. showMenu({'mtype':'prompt','pos':'00','menuid':menuid,'duration':duration,'timeout':timeout,'zindex':JSMENU['zIndex']['prompt']});
  937. $(menuid).style.top = (parseInt($(menuid).style.top) - 100) + 'px';
  938. }
  939. }
  940. function _showCreditPrompt() {
  941. var notice = getcookie('creditnotice').split('D');
  942. var basev = getcookie('creditbase').split('D');
  943. var creditrule = decodeURI(getcookie('creditrule', 1)).replace(String.fromCharCode(9), ' ');
  944. if(!discuz_uid || notice.length < 2 || notice[9] != discuz_uid) {
  945. setcookie('creditnotice', '');
  946. setcookie('creditrule', '');
  947. return;
  948. }
  949. var creditnames = creditnotice.split(',');
  950. var creditinfo = [];
  951. var e;
  952. for(var i = 0; i < creditnames.length; i++) {
  953. e = creditnames[i].split('|');
  954. creditinfo[e[0]] = [e[1], e[2]];
  955. }
  956. creditShow(creditinfo, notice, basev, 0, 1, creditrule);
  957. }
  958. function creditShow(creditinfo, notice, basev, bk, first, creditrule) {
  959. var s = '', check = 0;
  960. for(i = 1; i <= 8; i++) {
  961. v = parseInt(Math.abs(parseInt(notice[i])) / 5) + 1;
  962. if(notice[i] !== '0' && creditinfo[i]) {
  963. s += '<span>' + creditinfo[i][0] + (notice[i] != 0 ? (notice[i] > 0 ? '<em>+' : '<em class="desc">') + notice[i] + '</em>' : '') + creditinfo[i][1] + '</span>';
  964. }
  965. if(notice[i] > 0) {
  966. notice[i] = parseInt(notice[i]) - v;
  967. basev[i] = parseInt(basev[i]) + v;
  968. } else if(notice[i] < 0) {
  969. notice[i] = parseInt(notice[i]) + v;
  970. basev[i] = parseInt(basev[i]) - v;
  971. }
  972. if($('hcredit_' + i)) {
  973. $('hcredit_' + i).innerHTML = basev[i];
  974. }
  975. }
  976. for(i = 1; i <= 8; i++) {
  977. if(notice[i] != 0) {
  978. check = 1;
  979. }
  980. }
  981. if(!s || first) {
  982. setcookie('creditnotice', '');
  983. setcookie('creditbase', '');
  984. setcookie('creditrule', '');
  985. if(!s) {
  986. return;
  987. }
  988. }
  989. if(!$('creditpromptdiv')) {
  990. showPrompt(null, null, '<div id="creditpromptdiv">' + (creditrule ? '<i>' + creditrule + '</i> ' : '') + s + '</div>', 0);
  991. } else {
  992. $('creditpromptdiv').innerHTML = s;
  993. }
  994. setTimeout(function () {hideMenu(1, 'prompt');$('append_parent').removeChild($('ntcwin'));}, 1500);
  995. }
  996. function _showColorBox(ctrlid, layer, k, bgcolor) {
  997. var tag1 = !bgcolor ? 'color' : 'backcolor', tag2 = !bgcolor ? 'forecolor' : 'backcolor';
  998. if(!$(ctrlid + '_menu')) {
  999. var menu = document.createElement('div');
  1000. menu.id = ctrlid + '_menu';
  1001. menu.className = 'p_pop colorbox';
  1002. menu.unselectable = true;
  1003. menu.style.display = 'none';
  1004. var coloroptions = ['Black', 'Sienna', 'DarkOliveGreen', 'DarkGreen', 'DarkSlateBlue', 'Navy', 'Indigo', 'DarkSlateGray', 'DarkRed', 'DarkOrange', 'Olive', 'Green', 'Teal', 'Blue', 'SlateGray', 'DimGray', 'Red', 'SandyBrown', 'YellowGreen', 'SeaGreen', 'MediumTurquoise', 'RoyalBlue', 'Purple', 'Gray', 'Magenta', 'Orange', 'Yellow', 'Lime', 'Cyan', 'DeepSkyBlue', 'DarkOrchid', 'Silver', 'Pink', 'Wheat', 'LemonChiffon', 'PaleGreen', 'PaleTurquoise', 'LightBlue', 'Plum', 'White'];
  1005. var colortexts = ['黑色', '赭色', '暗橄榄绿色', '暗绿色', '暗灰蓝色', '海军色', '靛青色', '墨绿色', '暗红色', '暗桔黄色', '橄榄色', '绿色', '水鸭色', '蓝色', '灰石色', '暗灰色', '红色', '沙褐色', '黄绿色', '海绿色', '间绿宝石', '皇家蓝', '紫色', '灰色', '红紫色', '橙色', '黄色', '酸橙色', '青色', '深天蓝色', '暗紫色', '银色', '粉色', '浅黄色', '柠檬绸色', '苍绿色', '苍宝石绿', '亮蓝色', '洋李色', '白色'];
  1006. var str = '';
  1007. for(var i = 0; i < 40; i++) {
  1008. str += '<input type="button" style="background-color: ' + coloroptions[i] + '"' + (typeof setEditorTip == 'function' ? ' onmouseover="setEditorTip(\'' + colortexts[i] + '\')" onmouseout="setEditorTip(\'\')"' : '') + ' onclick="'
  1009. + (typeof wysiwyg == 'undefined' ? 'seditor_insertunit(\'' + k + '\', \'[' + tag1 + '=' + coloroptions[i] + ']\', \'[/' + tag1 + ']\')' : (ctrlid == editorid + '_tbl_param_4' ? '$(\'' + ctrlid + '\').value=\'' + coloroptions[i] + '\';hideMenu(2)' : 'discuzcode(\'' + tag2 + '\', \'' + coloroptions[i] + '\')'))
  1010. + '" title="' + colortexts[i] + '" />' + (i < 39 && (i + 1) % 8 == 0 ? '<br />' : '');
  1011. }
  1012. menu.innerHTML = str;
  1013. $('append_parent').appendChild(menu);
  1014. }
  1015. showMenu({'ctrlid':ctrlid,'evt':'click','layer':layer});
  1016. }
  1017. function _toggle_collapse(objname, noimg, complex, lang) {
  1018. var obj = $(objname);
  1019. if(obj) {
  1020. obj.style.display = obj.style.display == '' ? 'none' : '';
  1021. var collapsed = getcookie('collapse');
  1022. collapsed = updatestring(collapsed, objname, !obj.style.display);
  1023. setcookie('collapse', collapsed, (collapsed ? 2592000 : -2592000));
  1024. }
  1025. if(!noimg) {
  1026. var img = $(objname + '_img');
  1027. if(img.tagName != 'IMG') {
  1028. if(img.className.indexOf('_yes') == -1) {
  1029. img.className = img.className.replace(/_no/, '_yes');
  1030. if(lang) {
  1031. img.innerHTML = lang[0];
  1032. }
  1033. } else {
  1034. img.className = img.className.replace(/_yes/, '_no');
  1035. if(lang) {
  1036. img.innerHTML = lang[1];
  1037. }
  1038. }
  1039. } else {
  1040. img.src = img.src.indexOf('_yes.gif') == -1 ? img.src.replace(/_no\.gif/, '_yes\.gif') : img.src.replace(/_yes\.gif/, '_no\.gif');
  1041. }
  1042. img.blur();
  1043. }
  1044. if(complex) {
  1045. var objc = $(objname + '_c');
  1046. if(objc) {
  1047. objc.className = objc.className == 'umh' ? 'umh umn' : 'umh';
  1048. }
  1049. }
  1050. }
  1051. function _extstyle(css) {
  1052. if(!$('css_extstyle')) {
  1053. loadcss('extstyle');
  1054. }
  1055. $('css_extstyle').href = css ? css + '/style.css' : STATICURL + 'image/common/extstyle_none.css';
  1056. currentextstyle = css;
  1057. setcookie('extstyle', css, 86400 * 30);
  1058. if($('css_widthauto') && !$('css_widthauto').disabled) {
  1059. CSSLOADED['widthauto'] = 0;
  1060. loadcss('widthauto');
  1061. }
  1062. }
  1063. function _widthauto(obj) {
  1064. var strs = ['切换到宽版', '切换到窄版'];
  1065. if($('css_widthauto')) {
  1066. CSSLOADED['widthauto'] = 1;
  1067. }
  1068. if(!CSSLOADED['widthauto'] || $('css_widthauto').disabled) {
  1069. if(!CSSLOADED['widthauto']) {
  1070. loadcss('widthauto');
  1071. } else {
  1072. $('css_widthauto').disabled = false;
  1073. }
  1074. HTMLNODE.className += ' widthauto';
  1075. setcookie('widthauto', 1, 86400 * 30);
  1076. obj.innerHTML = strs[1];
  1077. obj.title = strs[1];
  1078. } else {
  1079. $('css_widthauto').disabled = true;
  1080. HTMLNODE.className = HTMLNODE.className.replace(' widthauto', '');
  1081. setcookie('widthauto', -1, 86400 * 30);
  1082. obj.innerHTML = strs[0];
  1083. obj.title = strs[0];
  1084. }
  1085. hideMenu();
  1086. }
  1087. function _showCreditmenu() {
  1088. if(!$('extcreditmenu_menu')) {
  1089. menu = document.createElement('div');
  1090. menu.id = 'extcreditmenu_menu';
  1091. menu.style.display = 'none';
  1092. menu.className = 'p_pop';
  1093. menu.innerHTML = '<div class="p_opt"><img src="'+ IMGDIR + '/loading.gif" width="16" height="16" class="vm" /> 请稍候...</div>';
  1094. $('append_parent').appendChild(menu);
  1095. ajaxget($('extcreditmenu').href, 'extcreditmenu_menu', 'ajaxwaitid');
  1096. }
  1097. showMenu({'ctrlid':'extcreditmenu','ctrlclass':'a','duration':2});
  1098. }
  1099. function _showUpgradeinfo() {
  1100. if(!$('g_upmine_menu')) {
  1101. menu = document.createElement('div');
  1102. menu.id = 'g_upmine_menu';
  1103. menu.style.display = 'none';
  1104. menu.className = 'p_pop';
  1105. menu.innerHTML = '<div class="p_opt"><img src="'+ IMGDIR + '/loading.gif" width="16" height="16" class="vm" /> 请稍候...</div>';
  1106. $('append_parent').appendChild(menu);
  1107. ajaxget('home.php?mod=spacecp&ac=usergroup&showextgroups=1', 'g_upmine_menu', 'ajaxwaitid');
  1108. }
  1109. showMenu({'ctrlid':'g_upmine','ctrlclass':'a','duration':2});
  1110. }
  1111. function _showForummenu(fid) {
  1112. if($('fjump_menu') && !$('fjump_menu').innerHTML) {
  1113. ajaxget('forum.php?mod=ajax&action=forumjump&jfid=' + fid, 'fjump_menu', 'ajaxwaitid');
  1114. }
  1115. }
  1116. function _showUserApp(fid) {
  1117. var menu = $('mn_userapp_menu');
  1118. if(menu && !menu.innerHTML) {
  1119. ajaxget('misc.php?mod=manyou&action=menu', 'mn_userapp_menu', 'ajaxwaitid');
  1120. }
  1121. }
  1122. function _imageRotate(imgid, direct) {
  1123. var image = $(imgid);
  1124. if(!image.getAttribute('deg')) {
  1125. var deg = 0;
  1126. image.setAttribute('ow', image.width);
  1127. image.setAttribute('oh', image.height);
  1128. if(BROWSER.ie) {
  1129. image.setAttribute('om', parseInt(image.currentStyle.marginBottom));
  1130. }
  1131. } else {
  1132. var deg = parseInt(image.getAttribute('deg'));
  1133. }
  1134. var ow = image.getAttribute('ow');
  1135. var oh = image.getAttribute('oh');
  1136. deg = direct == 1 ? deg - 90 : deg + 90;
  1137. if(deg > 270) {
  1138. deg = 0;
  1139. } else if(deg < 0) {
  1140. deg = 270;
  1141. }
  1142. image.setAttribute('deg', deg);
  1143. if(BROWSER.ie) {
  1144. if(!isNaN(image.getAttribute('om'))) {
  1145. image.style.marginBottom = (image.getAttribute('om') + (BROWSER.ie < 8 ? 0 : (deg == 90 || deg == 270 ? Math.abs(ow - oh) : 0))) + 'px';
  1146. }
  1147. image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (deg / 90) + ')';
  1148. } else {
  1149. switch(deg) {
  1150. case 90:var cow = oh, coh = ow, cx = 0, cy = -oh;break;
  1151. case 180:var cow = ow, coh = oh, cx = -ow, cy = -oh;break;
  1152. case 270:var cow = oh, coh = ow, cx = -ow, cy = 0;break;
  1153. }
  1154. var canvas = $(image.getAttribute('canvasid'));
  1155. if(!canvas) {
  1156. var i = document.createElement("canvas");
  1157. i.id = 'canva_' + Math.random();
  1158. image.setAttribute('canvasid', i.id);
  1159. image.parentNode.insertBefore(i, image);
  1160. canvas = $(i.id);
  1161. }
  1162. if(deg) {
  1163. var canvasContext = canvas.getContext('2d');
  1164. canvas.setAttribute('width', cow);
  1165. canvas.setAttribute('height', coh);
  1166. canvasContext.rotate(deg * Math.PI / 180);
  1167. canvasContext.drawImage(image, cx, cy, ow, oh);
  1168. image.style.display = 'none';
  1169. canvas.style.display = '';
  1170. } else {
  1171. image.style.display = '';
  1172. canvas.style.display = 'none';
  1173. }
  1174. }
  1175. }
  1176. function _createPalette(colorid, id, func) {
  1177. var iframe = "<iframe name=\"c"+colorid+"_frame\" src=\"\" frameborder=\"0\" width=\"210\" height=\"148\" scrolling=\"no\"></iframe>";
  1178. if (!$("c"+colorid+"_menu")) {
  1179. var dom = document.createElement('span');
  1180. dom.id = "c"+colorid+"_menu";
  1181. dom.style.display = 'none';
  1182. dom.innerHTML = iframe;
  1183. $('append_parent').appendChild(dom);
  1184. }
  1185. func = !func ? '' : '|' + func;
  1186. window.frames["c"+colorid+"_frame"].location.href = SITEURL+STATICURL+"image/admincp/getcolor.htm?c"+colorid+"|"+id+func;
  1187. showMenu({'ctrlid':'c'+colorid});
  1188. var iframeid = "c"+colorid+"_menu";
  1189. _attachEvent(window, 'scroll', function(){hideMenu(iframeid);});
  1190. }
  1191. function _setShortcut() {
  1192. $('shortcuttip').onclick = function() {
  1193. var msg = '1、点击"' + '<a href="javascript:;" class="xi2 xw1" ';
  1194. msg += 'onclick="this.href = \'forum.php?mod=misc&action=shortcut\';this.click();saveUserdata(\'setshortcut\', 1);"';
  1195. msg += '>下载桌面快捷</a>' + '",下载完成后,可移动文件到系统桌面<br />';
  1196. msg += '2、点击"' + '<a href="forum.php?mod=misc&action=shortcut&type=ico" class="xi2 xw1">';
  1197. msg += '下载ICO图标</a>' + '",下载完成后,右击桌面快捷文件->属性->更改图标,选择已下载的ICO图标即可';
  1198. showDialog(msg, 'notice', '添加桌面快捷');
  1199. };
  1200. $('shortcutcloseid').onclick = function() {
  1201. $('shortcut').style.display = 'none';
  1202. saveUserdata('setshortcut', 2);
  1203. };
  1204. this.height = 0;
  1205. this.shortcut = $('shortcut');
  1206. this.shortcut.style.overflow = 'hidden';
  1207. this.shortcut.style.display = 'block';
  1208. this.autozoomin = function() {
  1209. var maxheight = 30;
  1210. this.height += 5;
  1211. if(this.height >= maxheight) {
  1212. this.shortcut.style.height = maxheight + 'px';
  1213. return;
  1214. }
  1215. this.shortcut.style.height = this.height + 'px';
  1216. setTimeout(this.autozoomin, 50);
  1217. };
  1218. this.autozoomin();
  1219. }