common_extra.js 45 KB

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