home.js 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. /*
  2. [Discuz!] (C)2001-2099 Comsenz Inc.
  3. This is NOT a freeware, use is subject to license terms
  4. $Id: home.js 34052 2013-09-25 06:18:43Z andyzheng $
  5. */
  6. var note_step = 0;
  7. var note_oldtitle = document.title;
  8. var note_timer;
  9. function addSort(obj) {
  10. if (obj.value == 'addoption') {
  11. showWindow('addoption', 'home.php?mod=spacecp&ac=blog&op=addoption&handlekey=addoption&oid='+obj.id);
  12. }
  13. }
  14. function addOption(sid, aid) {
  15. var obj = $(aid);
  16. var newOption = $(sid).value;
  17. $(sid).value = "";
  18. if (newOption!=null && newOption!='') {
  19. var newOptionTag=document.createElement('option');
  20. newOptionTag.text=newOption;
  21. newOptionTag.value="new:" + newOption;
  22. try {
  23. obj.add(newOptionTag, obj.options[0]);
  24. } catch(ex) {
  25. obj.add(newOptionTag, obj.selecedIndex);
  26. }
  27. obj.value="new:" + newOption;
  28. } else {
  29. obj.value=obj.options[0].value;
  30. }
  31. }
  32. function blogAddOption(sid, aid) {
  33. var obj = $(aid);
  34. var newOption = $(sid).value;
  35. newOption = newOption.replace(/^\s+|\s+$/g,"");
  36. $(sid).value = "";
  37. if (newOption!=null && newOption!='') {
  38. var newOptionTag=document.createElement('option');
  39. newOptionTag.text=newOption;
  40. newOptionTag.value="new:" + newOption;
  41. try {
  42. obj.add(newOptionTag, obj.options[0]);
  43. } catch(ex) {
  44. obj.add(newOptionTag, obj.selecedIndex);
  45. }
  46. obj.value="new:" + newOption;
  47. return true;
  48. } else {
  49. alert('分类名不能为空!');
  50. return false;
  51. }
  52. }
  53. function blogCancelAddOption(aid) {
  54. var obj = $(aid);
  55. obj.value=obj.options[0].value;
  56. }
  57. function checkAll(form, name) {
  58. for(var i = 0; i < form.elements.length; i++) {
  59. var e = form.elements[i];
  60. if(e.name.match(name)) {
  61. e.checked = form.elements['chkall'].checked;
  62. }
  63. }
  64. }
  65. function cnCode(str) {
  66. str = str.replace(/<\/?[^>]+>|\[\/?.+?\]|"/ig, "");
  67. str = str.replace(/\s{2,}/ig, ' ');
  68. return BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(str) : str;
  69. }
  70. function getExt(path) {
  71. return path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
  72. }
  73. function resizeImg(id,size) {
  74. var theImages = $(id).getElementsByTagName('img');
  75. for (i=0; i<theImages.length; i++) {
  76. theImages[i].onload = function() {
  77. if (this.width > size) {
  78. this.style.width = size + 'px';
  79. if (this.parentNode.tagName.toLowerCase() != 'a') {
  80. var zoomDiv = document.createElement('div');
  81. this.parentNode.insertBefore(zoomDiv,this);
  82. zoomDiv.appendChild(this);
  83. zoomDiv.style.position = 'relative';
  84. zoomDiv.style.cursor = 'pointer';
  85. this.title = '点击图片,在新窗口显示原始尺寸';
  86. var zoom = document.createElement('img');
  87. zoom.src = 'image/zoom.gif';
  88. zoom.style.position = 'absolute';
  89. zoom.style.marginLeft = size -28 + 'px';
  90. zoom.style.marginTop = '5px';
  91. this.parentNode.insertBefore(zoom,this);
  92. zoomDiv.onmouseover = function() {
  93. zoom.src = 'image/zoom_h.gif';
  94. };
  95. zoomDiv.onmouseout = function() {
  96. zoom.src = 'image/zoom.gif';
  97. };
  98. zoomDiv.onclick = function() {
  99. window.open(this.childNodes[1].src);
  100. };
  101. }
  102. }
  103. }
  104. }
  105. }
  106. function zoomTextarea(id, zoom) {
  107. zoomSize = zoom ? 10 : -10;
  108. obj = $(id);
  109. if(obj.rows + zoomSize > 0 && obj.cols + zoomSize * 3 > 0) {
  110. obj.rows += zoomSize;
  111. obj.cols += zoomSize * 3;
  112. }
  113. }
  114. function ischeck(id, prefix) {
  115. form = document.getElementById(id);
  116. for(var i = 0; i < form.elements.length; i++) {
  117. var e = form.elements[i];
  118. if(e.name.match(prefix) && e.checked) {
  119. if(confirm("您确定要执行本操作吗?")) {
  120. return true;
  121. } else {
  122. return false;
  123. }
  124. }
  125. }
  126. alert('请选择要操作的对象');
  127. return false;
  128. }
  129. function copyRow(tbody) {
  130. var add = false;
  131. var newnode;
  132. if($(tbody).rows.length == 1 && $(tbody).rows[0].style.display == 'none') {
  133. $(tbody).rows[0].style.display = '';
  134. newnode = $(tbody).rows[0];
  135. } else {
  136. newnode = $(tbody).rows[0].cloneNode(true);
  137. add = true;
  138. }
  139. tags = newnode.getElementsByTagName('input');
  140. for(i = 0;i < tags.length;i++) {
  141. if(tags[i].name == 'pics[]') {
  142. tags[i].value = 'http://';
  143. }
  144. }
  145. if(add) {
  146. $(tbody).appendChild(newnode);
  147. }
  148. }
  149. function delRow(obj, tbody) {
  150. if($(tbody).rows.length == 1) {
  151. var trobj = obj.parentNode.parentNode;
  152. tags = trobj.getElementsByTagName('input');
  153. for(i = 0;i < tags.length;i++) {
  154. if(tags[i].name == 'pics[]') {
  155. tags[i].value = 'http://';
  156. }
  157. }
  158. trobj.style.display='none';
  159. } else {
  160. $(tbody).removeChild(obj.parentNode.parentNode);
  161. }
  162. }
  163. function insertWebImg(obj) {
  164. if(checkImage(obj.value)) {
  165. insertImage(obj.value);
  166. obj.value = 'http://';
  167. } else {
  168. alert('图片地址不正确');
  169. }
  170. }
  171. function checkFocus(target) {
  172. var obj = $(target);
  173. if(!obj.hasfocus) {
  174. obj.focus();
  175. }
  176. }
  177. function insertImage(text) {
  178. text = "\n[img]" + text + "[/img]\n";
  179. insertContent('message', text);
  180. }
  181. function insertContent(target, text) {
  182. var obj = $(target);
  183. selection = document.selection;
  184. checkFocus(target);
  185. if(!isUndefined(obj.selectionStart)) {
  186. var opn = obj.selectionStart + 0;
  187. obj.value = obj.value.substr(0, obj.selectionStart) + text + obj.value.substr(obj.selectionEnd);
  188. } else if(selection && selection.createRange) {
  189. var sel = selection.createRange();
  190. sel.text = text;
  191. sel.moveStart('character', -strlen(text));
  192. } else {
  193. obj.value += text;
  194. }
  195. }
  196. function checkImage(url) {
  197. var re = /^http\:\/\/.{5,200}\.(jpg|gif|png)$/i;
  198. return url.match(re);
  199. }
  200. function quick_validate(obj) {
  201. if($('seccode')) {
  202. var code = $('seccode').value;
  203. var x = new Ajax();
  204. x.get('cp.php?ac=common&op=seccode&code=' + code, function(s){
  205. s = trim(s);
  206. if(s != 'succeed') {
  207. alert(s);
  208. $('seccode').focus();
  209. return false;
  210. } else {
  211. obj.form.submit();
  212. return true;
  213. }
  214. });
  215. } else {
  216. obj.form.submit();
  217. return true;
  218. }
  219. }
  220. function stopMusic(preID, playerID) {
  221. var musicFlash = preID.toString() + '_' + playerID.toString();
  222. if($(musicFlash)) {
  223. $(musicFlash).SetVariable('closePlayer', 1);
  224. }
  225. }
  226. function showFlash(host, flashvar, obj, shareid) {
  227. var flashAddr = {
  228. 'youku.com' : 'http://player.youku.com/player.php/sid/FLASHVAR=/v.swf',
  229. 'ku6.com' : 'http://player.ku6.com/refer/FLASHVAR/v.swf',
  230. 'youtube.com' : 'http://www.youtube.com/v/FLASHVAR',
  231. '5show.com' : 'http://www.5show.com/swf/5show_player.swf?flv_id=FLASHVAR',
  232. 'sina.com.cn' : 'http://vhead.blog.sina.com.cn/player/outer_player.swf?vid=FLASHVAR',
  233. 'sohu.com' : 'http://v.blog.sohu.com/fo/v4/FLASHVAR',
  234. 'mofile.com' : 'http://tv.mofile.com/cn/xplayer.swf?v=FLASHVAR',
  235. 'music' : 'FLASHVAR',
  236. 'flash' : 'FLASHVAR'
  237. };
  238. var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="480" height="400">'
  239. + '<param name="movie" value="FLASHADDR" />'
  240. + '<param name="quality" value="high" />'
  241. + '<param name="bgcolor" value="#FFFFFF" />'
  242. + '<param name="allowScriptAccess" value="never" />'
  243. + '<param name="allowNetworking" value="internal" />'
  244. + '<embed width="480" height="400" menu="false" quality="high" allowScriptAccess="never" allowNetworking="internal" src="FLASHADDR" type="application/x-shockwave-flash" />'
  245. + '</object>';
  246. var videoFlash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="480" height="450">'
  247. + '<param value="transparent" name="wmode"/>'
  248. + '<param value="FLASHADDR" name="movie" />'
  249. + '<param name="allowScriptAccess" value="never" />'
  250. + '<param name="allowNetworking" value="none" />'
  251. + '<embed src="FLASHADDR" wmode="transparent" allowfullscreen="true" type="application/x-shockwave-flash" width="480" height="450" allowScriptAccess="never" allowNetworking="internal"></embed>'
  252. + '</object>';
  253. var musicFlash = '<object id="audioplayer_SHAREID" height="24" width="290" data="' + STATICURL + 'image/common/player.swf" type="application/x-shockwave-flash">'
  254. + '<param value="' + STATICURL + 'image/common/player.swf" name="movie"/>'
  255. + '<param value="autostart=yes&bg=0xCDDFF3&leftbg=0x357DCE&lefticon=0xF2F2F2&rightbg=0xF06A51&rightbghover=0xAF2910&righticon=0xF2F2F2&righticonhover=0xFFFFFF&text=0x357DCE&slider=0x357DCE&track=0xFFFFFF&border=0xFFFFFF&loader=0xAF2910&soundFile=FLASHADDR" name="FlashVars"/>'
  256. + '<param value="high" name="quality"/>'
  257. + '<param value="false" name="menu"/>'
  258. + '<param value="#FFFFFF" name="bgcolor"/>'
  259. + '</object>';
  260. var musicMedia = '<object height="64" width="290" data="FLASHADDR" type="audio/x-ms-wma">'
  261. + '<param value="FLASHADDR" name="src"/>'
  262. + '<param value="1" name="autostart"/>'
  263. + '<param value="true" name="controller"/>'
  264. + '</object>';
  265. var flashHtml = videoFlash;
  266. var videoMp3 = true;
  267. if('' == flashvar) {
  268. alert('音乐地址错误,不能为空');
  269. return false;
  270. }
  271. if('music' == host) {
  272. var mp3Reg = new RegExp('.mp3$', 'ig');
  273. var flashReg = new RegExp('.swf$', 'ig');
  274. flashHtml = musicMedia;
  275. videoMp3 = false;
  276. if(mp3Reg.test(flashvar)) {
  277. videoMp3 = true;
  278. flashHtml = musicFlash;
  279. } else if(flashReg.test(flashvar)) {
  280. videoMp3 = true;
  281. flashHtml = flash;
  282. }
  283. }
  284. flashvar = encodeURI(flashvar);
  285. if(flashAddr[host]) {
  286. var flash = flashAddr[host].replace('FLASHVAR', flashvar);
  287. flashHtml = flashHtml.replace(/FLASHADDR/g, flash);
  288. flashHtml = flashHtml.replace(/SHAREID/g, shareid);
  289. }
  290. if(!obj) {
  291. $('flash_div_' + shareid).innerHTML = flashHtml;
  292. return true;
  293. }
  294. if($('flash_div_' + shareid)) {
  295. $('flash_div_' + shareid).style.display = '';
  296. $('flash_hide_' + shareid).style.display = '';
  297. obj.style.display = 'none';
  298. return true;
  299. }
  300. if(flashAddr[host]) {
  301. var flashObj = document.createElement('div');
  302. flashObj.id = 'flash_div_' + shareid;
  303. obj.parentNode.insertBefore(flashObj, obj);
  304. flashObj.innerHTML = flashHtml;
  305. obj.style.display = 'none';
  306. var hideObj = document.createElement('div');
  307. hideObj.id = 'flash_hide_' + shareid;
  308. var nodetxt = document.createTextNode("收起");
  309. hideObj.appendChild(nodetxt);
  310. obj.parentNode.insertBefore(hideObj, obj);
  311. hideObj.style.cursor = 'pointer';
  312. hideObj.onclick = function() {
  313. if(true == videoMp3) {
  314. stopMusic('audioplayer', shareid);
  315. flashObj.parentNode.removeChild(flashObj);
  316. hideObj.parentNode.removeChild(hideObj);
  317. } else {
  318. flashObj.style.display = 'none';
  319. hideObj.style.display = 'none';
  320. }
  321. obj.style.display = '';
  322. };
  323. }
  324. }
  325. function userapp_open() {
  326. var x = new Ajax();
  327. x.get('home.php?mod=spacecp&ac=common&op=getuserapp&inajax=1', function(s){
  328. $('my_userapp').innerHTML = s;
  329. $('a_app_more').className = 'fold';
  330. $('a_app_more').innerHTML = '收起';
  331. $('a_app_more').onclick = function() {
  332. userapp_close();
  333. };
  334. });
  335. }
  336. function userapp_close() {
  337. var x = new Ajax();
  338. x.get('home.php?mod=spacecp&ac=common&op=getuserapp&subop=off&inajax=1', function(s){
  339. $('my_userapp').innerHTML = s;
  340. $('a_app_more').className = 'unfold';
  341. $('a_app_more').innerHTML = '展开';
  342. $('a_app_more').onclick = function() {
  343. userapp_open();
  344. };
  345. });
  346. }
  347. function startMarquee(h, speed, delay, sid) {
  348. var t = null;
  349. var p = false;
  350. var o = $(sid);
  351. o.innerHTML += o.innerHTML;
  352. o.onmouseover = function() {p = true};
  353. o.onmouseout = function() {p = false};
  354. o.scrollTop = 0;
  355. function start() {
  356. t = setInterval(scrolling, speed);
  357. if(!p) {
  358. o.scrollTop += 2;
  359. }
  360. }
  361. function scrolling() {
  362. if(p) return;
  363. if(o.scrollTop % h != 0) {
  364. o.scrollTop += 2;
  365. if(o.scrollTop >= o.scrollHeight/2) o.scrollTop = 0;
  366. } else {
  367. clearInterval(t);
  368. setTimeout(start, delay);
  369. }
  370. }
  371. setTimeout(start, delay);
  372. }
  373. function readfeed(obj, id) {
  374. if(Cookie.get("read_feed_ids")) {
  375. var fcookie = Cookie.get("read_feed_ids");
  376. fcookie = id + ',' + fcookie;
  377. } else {
  378. var fcookie = id;
  379. }
  380. Cookie.set("read_feed_ids", fcookie, 48);
  381. obj.className = 'feedread';
  382. }
  383. function showreward() {
  384. if(Cookie.get('reward_notice_disable')) {
  385. return false;
  386. }
  387. var x = new Ajax();
  388. x.get('home.php?mod=misc&ac=ajax&op=getreward', function(s){
  389. if(s) {
  390. msgwin(s, 2000);
  391. }
  392. });
  393. }
  394. function msgwin(s, t) {
  395. var msgWinObj = $('msgwin');
  396. if(!msgWinObj) {
  397. var msgWinObj = document.createElement("div");
  398. msgWinObj.id = 'msgwin';
  399. msgWinObj.style.display = 'none';
  400. msgWinObj.style.position = 'absolute';
  401. msgWinObj.style.zIndex = '100000';
  402. $('append_parent').appendChild(msgWinObj);
  403. }
  404. msgWinObj.innerHTML = s;
  405. msgWinObj.style.display = '';
  406. msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
  407. msgWinObj.style.opacity = 0;
  408. var sTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
  409. pbegin = sTop + (document.documentElement.clientHeight / 2);
  410. pend = sTop + (document.documentElement.clientHeight / 5);
  411. setTimeout(function () {showmsgwin(pbegin, pend, 0, t)}, 10);
  412. msgWinObj.style.left = ((document.documentElement.clientWidth - msgWinObj.clientWidth) / 2) + 'px';
  413. msgWinObj.style.top = pbegin + 'px';
  414. }
  415. function showmsgwin(b, e, a, t) {
  416. step = (b - e) / 10;
  417. var msgWinObj = $('msgwin');
  418. newp = (parseInt(msgWinObj.style.top) - step);
  419. if(newp > e) {
  420. msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + a + ')';
  421. msgWinObj.style.opacity = a / 100;
  422. msgWinObj.style.top = newp + 'px';
  423. setTimeout(function () {showmsgwin(b, e, a += 10, t)}, 10);
  424. } else {
  425. msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
  426. msgWinObj.style.opacity = 1;
  427. setTimeout('displayOpacity(\'msgwin\', 100)', t);
  428. }
  429. }
  430. function displayOpacity(id, n) {
  431. if(!$(id)) {
  432. return;
  433. }
  434. if(n >= 0) {
  435. n -= 10;
  436. $(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + n + ')';
  437. $(id).style.opacity = n / 100;
  438. setTimeout('displayOpacity(\'' + id + '\',' + n + ')', 50);
  439. } else {
  440. $(id).style.display = 'none';
  441. $(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
  442. $(id).style.opacity = 1;
  443. }
  444. }
  445. function urlto(url) {
  446. window.location.href = url;
  447. }
  448. function explode(sep, string) {
  449. return string.split(sep);
  450. }
  451. function selector(pattern, context) {
  452. var re = new RegExp('([a-z0-9]*)([\.#:]*)(.*|$)', 'ig');
  453. var match = re.exec(pattern);
  454. var conditions = cc = [];
  455. if (match[2] == '#') conditions.push(['id', '=', match[3]]);
  456. else if(match[2] == '.') conditions.push(['className', '~=', match[3]]);
  457. else if(match[2] == ':') conditions.push(['type', '=', match[3]]);
  458. var s = match[3].replace(/\[(.*)\]/g,'$1').split('@');
  459. for(var i=0; i<s.length; i++) {
  460. if (cc = /([\w]+)([=^%!$~]+)(.*)$/.exec(s[i]))
  461. conditions.push([cc[1], cc[2], cc[3]]);
  462. }
  463. var list = conditions[0] && conditions[0][0] == 'id' ? [document.getElementById(conditions[0][2])] : (context || document).getElementsByTagName(match[1] || "*");
  464. if(!list || !list.length) return [];
  465. if(conditions) {
  466. var elements = [];
  467. var attrMapping = {'for': 'htmlFor', 'class': 'className'};
  468. for(var i=0; i<list.length; i++) {
  469. var pass = true;
  470. for(var j=0; j<conditions.length; j++) {
  471. var attr = attrMapping[conditions[j][0]] || conditions[j][0];
  472. var val = list[i][attr] || (list[i].getAttribute ? list[i].getAttribute(attr) : '');
  473. var pattern = null;
  474. if(conditions[j][1] == '=') {
  475. pattern = new RegExp('^'+conditions[j][2]+'$', 'i');
  476. } else if(conditions[j][1] == '^=') {
  477. pattern = new RegExp('^' + conditions[j][2], 'i');
  478. } else if(conditions[j][1] == '$=') {
  479. pattern = new RegExp(conditions[j][2] + '$', 'i');
  480. } else if(conditions[j][1] == '%=') {
  481. pattern = new RegExp(conditions[j][2], 'i');
  482. } else if(conditions[j][1] == '~=') {
  483. pattern = new RegExp('(^|[ ])' + conditions[j][2] + '([ ]|$)', 'i');
  484. }
  485. if(pattern && !pattern.test(val)) {
  486. pass = false;
  487. break;
  488. }
  489. }
  490. if(pass) elements.push(list[i]);
  491. }
  492. return elements;
  493. } else {
  494. return list;
  495. }
  496. }
  497. function showBlock(cid, oid) {
  498. if(parseInt(cid)) {
  499. var listObj = $(oid);
  500. var x = new Ajax();
  501. x.get('portal.php?mod=cp&ac=block&operation=getblock&classid='+cid, function(s){
  502. listObj.innerHTML = s;
  503. })
  504. }
  505. }
  506. function resizeTx(obj){
  507. var oid = obj.id + '_limit';
  508. if(!BROWSER.ie) obj.style.height = 0;
  509. obj.style.height = obj.scrollHeight + 'px';
  510. if($(oid)) $(oid).style.display = obj.scrollHeight > 30 ? '':'none';
  511. }
  512. function showFace(showid, target, dropstr) {
  513. if($(showid + '_menu') != null) {
  514. $(showid+'_menu').style.display = '';
  515. } else {
  516. var faceDiv = document.createElement("div");
  517. faceDiv.id = showid+'_menu';
  518. faceDiv.className = 'p_pop facel';
  519. faceDiv.style.position = 'absolute';
  520. faceDiv.style.zIndex = 1001;
  521. var faceul = document.createElement("ul");
  522. for(i=1; i<31; i++) {
  523. var faceli = document.createElement("li");
  524. faceli.innerHTML = '<img src="' + STATICURL + 'image/smiley/comcom/'+i+'.gif" onclick="insertFace(\''+showid+'\','+i+', \''+ target +'\', \''+dropstr+'\')" style="cursor:pointer; position:relative;" />';
  525. faceul.appendChild(faceli);
  526. }
  527. faceDiv.appendChild(faceul);
  528. $('append_parent').appendChild(faceDiv)
  529. }
  530. setMenuPosition(showid, 0);
  531. doane();
  532. _attachEvent(document.body, 'click', function(){if($(showid+'_menu')) $(showid+'_menu').style.display = 'none';});
  533. }
  534. function insertFace(showid, id, target, dropstr) {
  535. var faceText = '[em:'+id+':]';
  536. if($(target) != null) {
  537. insertContent(target, faceText);
  538. if(dropstr) {
  539. $(target).value = $(target).value.replace(dropstr, "");
  540. }
  541. }
  542. }
  543. function wall_add(id) {
  544. var obj = $('comment_ul');
  545. var newdl = document.createElement("dl");
  546. newdl.id = 'comment_'+id+'_li';
  547. newdl.className = 'bbda cl';
  548. var x = new Ajax();
  549. x.get('home.php?mod=misc&ac=ajax&op=comment&inajax=1&cid='+id, function(s){
  550. newdl.innerHTML = s;
  551. });
  552. obj.insertBefore(newdl, obj.firstChild);
  553. if($('comment_message')) {
  554. $('comment_message').value= '';
  555. }
  556. showCreditPrompt();
  557. }
  558. function share_add(sid) {
  559. var obj = $('share_ul');
  560. var newli = document.createElement("li");
  561. newli.id = 'share_' + sid + '_li';
  562. var x = new Ajax();
  563. x.get('home.php?mod=misc&ac=ajax&op=share&inajax=1&sid='+sid, function(s){
  564. newli.innerHTML = s;
  565. });
  566. obj.insertBefore(newli, obj.firstChild);
  567. $('share_link').value = 'http://';
  568. $('share_general').value = '';
  569. showCreditPrompt();
  570. }
  571. function comment_add(id) {
  572. var obj = $('comment_ul');
  573. var newdl = document.createElement("dl");
  574. newdl.id = 'comment_'+id+'_li';
  575. newdl.className = 'bbda cl';
  576. var x = new Ajax();
  577. x.get('home.php?mod=misc&ac=ajax&op=comment&inajax=1&cid='+id, function(s){
  578. newdl.innerHTML = s;
  579. });
  580. if($('comment_prepend')){
  581. obj = obj.firstChild;
  582. while (obj && obj.nodeType != 1){
  583. obj = obj.nextSibling;
  584. }
  585. obj.parentNode.insertBefore(newdl, obj);
  586. } else {
  587. obj.appendChild(newdl);
  588. }
  589. if($('comment_message')) {
  590. $('comment_message').value= '';
  591. }
  592. if($('comment_replynum')) {
  593. var a = parseInt($('comment_replynum').innerHTML);
  594. var b = a + 1;
  595. $('comment_replynum').innerHTML = b + '';
  596. }
  597. showCreditPrompt();
  598. }
  599. function comment_edit(cid) {
  600. var obj = $('comment_'+ cid +'_li');
  601. var x = new Ajax();
  602. x.get('home.php?mod=misc&ac=ajax&op=comment&inajax=1&cid='+ cid, function(s){
  603. obj.innerHTML = s;
  604. var elems = selector('dd[class~=magicflicker]');
  605. for(var i=0; i<elems.length; i++){
  606. magicColor(elems[i]);
  607. }
  608. });
  609. }
  610. function comment_delete(cid) {
  611. var obj = $('comment_'+ cid +'_li');
  612. obj.style.display = "none";
  613. if($('comment_replynum')) {
  614. var a = parseInt($('comment_replynum').innerHTML);
  615. var b = a - 1;
  616. $('comment_replynum').innerHTML = b + '';
  617. }
  618. }
  619. function share_delete(sid) {
  620. var obj = $('share_'+ sid +'_li');
  621. obj.style.display = "none";
  622. }
  623. function friend_delete(uid) {
  624. var obj = $('friend_'+ uid +'_li');
  625. if(obj != null) obj.style.display = "none";
  626. var obj2 = $('friend_tbody_'+uid);
  627. if(obj2 != null) obj2.style.display = "none";
  628. }
  629. function friend_changegroup(id, result) {
  630. if(result) {
  631. var ids = explode('_', id);
  632. var uid = ids[1];
  633. var obj = $('friend_group_'+ uid);
  634. var x = new Ajax();
  635. x.get('home.php?mod=misc&ac=ajax&op=getfriendgroup&uid='+uid, function(s){
  636. obj.innerHTML = s;
  637. });
  638. }
  639. }
  640. function friend_changegroupname(group) {
  641. var obj = $('friend_groupname_'+ group);
  642. var x = new Ajax();
  643. x.get('home.php?mod=misc&ac=ajax&op=getfriendname&inajax=1&group='+group, function(s){
  644. obj.innerHTML = s;
  645. });
  646. }
  647. function post_add(pid, result) {
  648. if(result) {
  649. var obj = $('post_ul');
  650. var newli = document.createElement("div");
  651. var x = new Ajax();
  652. x.get('home.php?mod=misc&ac=ajax&op=post', function(s){
  653. newli.innerHTML = s;
  654. });
  655. obj.appendChild(newli);
  656. if($('message')) {
  657. $('message').value= '';
  658. newnode = $('quickpostimg').rows[0].cloneNode(true);
  659. tags = newnode.getElementsByTagName('input');
  660. for(i = 0;i < tags.length;i++) {
  661. if(tags[i].name == 'pics[]') {
  662. tags[i].value = 'http://';
  663. }
  664. }
  665. var allRows = $('quickpostimg').rows;
  666. while(allRows.length) {
  667. $('quickpostimg').removeChild(allRows[0]);
  668. }
  669. $('quickpostimg').appendChild(newnode);
  670. }
  671. if($('post_replynum')) {
  672. var a = parseInt($('post_replynum').innerHTML);
  673. var b = a + 1;
  674. $('post_replynum').innerHTML = b + '';
  675. }
  676. showCreditPrompt();
  677. }
  678. }
  679. function post_edit(id, result) {
  680. if(result) {
  681. var ids = explode('_', id);
  682. var pid = ids[1];
  683. var obj = $('post_'+ pid +'_li');
  684. var x = new Ajax();
  685. x.get('home.php?mod=misc&ac=ajax&op=post&pid='+ pid, function(s){
  686. obj.innerHTML = s;
  687. });
  688. }
  689. }
  690. function post_delete(id, result) {
  691. if(result) {
  692. var ids = explode('_', id);
  693. var pid = ids[1];
  694. var obj = $('post_'+ pid +'_li');
  695. obj.style.display = "none";
  696. if($('post_replynum')) {
  697. var a = parseInt($('post_replynum').innerHTML);
  698. var b = a - 1;
  699. $('post_replynum').innerHTML = b + '';
  700. }
  701. }
  702. }
  703. function poke_send(id, result) {
  704. if(result) {
  705. var ids = explode('_', id);
  706. var uid = ids[1];
  707. if($('poke_'+ uid)) {
  708. $('poke_'+ uid).style.display = "none";
  709. }
  710. showCreditPrompt();
  711. }
  712. }
  713. function myfriend_post(uid) {
  714. if($('friend_'+uid)) {
  715. $('friend_'+uid).innerHTML = '<p>你们现在是好友了,接下来,您还可以:<a href="home.php?mod=space&do=wall&uid='+uid+'" class="xi2" target="_blank">给TA留言</a> ,或者 <a href="home.php?mod=spacecp&ac=poke&op=send&uid='+uid+'&handlekey=propokehk_'+uid+'" id="a_poke_'+uid+'" class="xi2" onclick="showWindow(this.id, this.href, \'get\', 0, {\'ctrlid\':this.id,\'pos\':\'13\'});">打个招呼</a></p>';
  716. }
  717. showCreditPrompt();
  718. }
  719. function myfriend_ignore(id) {
  720. var ids = explode('_', id);
  721. var uid = ids[1];
  722. $('friend_tbody_'+uid).style.display = "none";
  723. }
  724. function mtag_join(tagid, result) {
  725. if(result) {
  726. location.reload();
  727. }
  728. }
  729. function resend_mail(mid) {
  730. if(mid) {
  731. var obj = $('sendmail_'+ mid +'_li');
  732. obj.style.display = "none";
  733. }
  734. }
  735. function userapp_delete(id, result) {
  736. if(result) {
  737. var ids = explode('_', id);
  738. var appid = ids[1];
  739. $('space_app_'+appid).style.display = "none";
  740. }
  741. }
  742. function docomment_get(doid, key) {
  743. var showid = key + '_' + doid;
  744. var opid = key + '_do_a_op_'+doid;
  745. $(showid).style.display = '';
  746. $(showid).className = 'cmt brm';
  747. ajaxget('home.php?mod=spacecp&ac=doing&op=getcomment&handlekey=msg_'+doid+'&doid='+doid+'&key='+key, showid);
  748. if($(opid)) {
  749. $(opid).innerHTML = '收起';
  750. $(opid).onclick = function() {
  751. docomment_colse(doid, key);
  752. }
  753. }
  754. showCreditPrompt();
  755. }
  756. function docomment_colse(doid, key) {
  757. var showid = key + '_' + doid;
  758. var opid = key + '_do_a_op_'+doid;
  759. $(showid).style.display = 'none';
  760. $(showid).style.className = '';
  761. $(opid).innerHTML = '回复';
  762. $(opid).onclick = function() {
  763. docomment_get(doid, key);
  764. }
  765. }
  766. function docomment_form(doid, id, key) {
  767. var showid = key + '_form_'+doid+'_'+id;
  768. var divid = key +'_'+ doid;
  769. var url = 'home.php?mod=spacecp&ac=doing&op=docomment&handlekey=msg_'+id+'&doid='+doid+'&id='+id+'&key='+key;
  770. if(parseInt(discuz_uid)) {
  771. ajaxget(url, showid);
  772. if($(divid)) {
  773. $(divid).style.display = '';
  774. }
  775. } else {
  776. showWindow(divid, url);
  777. }
  778. }
  779. function docomment_form_close(doid, id, key) {
  780. var showid = key + '_form_' + doid + '_' + id;
  781. var opid = key + '_do_a_op_' + doid;
  782. $(showid).innerHTML = '';
  783. $(showid).style.display = 'none';
  784. var liObj = $(key+'_'+doid).getElementsByTagName('li');
  785. if(!liObj.length) {
  786. $(key+'_'+doid).style.display = 'none';
  787. if($(opid)) {
  788. $(opid).innerHTML = '回复';
  789. $(opid).onclick = function () {
  790. docomment_get(doid, key);
  791. }
  792. }
  793. }
  794. }
  795. function feedcomment_get(feedid) {
  796. var showid = 'feedcomment_'+feedid;
  797. var opid = 'feedcomment_a_op_'+feedid;
  798. $(showid).style.display = '';
  799. ajaxget('home.php?mod=spacecp&ac=feed&op=getcomment&feedid='+feedid+'&handlekey=feedhk_'+feedid, showid);
  800. if($(opid) != null) {
  801. $(opid).innerHTML = '收起';
  802. $(opid).onclick = function() {
  803. feedcomment_close(feedid);
  804. }
  805. }
  806. }
  807. function feedcomment_add(cid, feedid) {
  808. var obj = $('comment_ol_'+feedid);
  809. var newdl = document.createElement("dl");
  810. newdl.id = 'comment_'+cid+'_li';
  811. newdl.className = 'bbda cl';
  812. var x = new Ajax();
  813. x.get('home.php?mod=misc&ac=ajax&op=comment&inajax=1&cid='+cid, function(s){
  814. newdl.innerHTML = s;
  815. });
  816. obj.appendChild(newdl);
  817. $('feedmessage_'+feedid).value= '';
  818. showCreditPrompt();
  819. }
  820. function feedcomment_close(feedid) {
  821. var showid = 'feedcomment_'+feedid;
  822. var opid = 'feedcomment_a_op_'+feedid;
  823. $(showid).style.display = 'none';
  824. $(showid).style.className = '';
  825. $(opid).innerHTML = '评论';
  826. $(opid).onclick = function() {
  827. feedcomment_get(feedid);
  828. }
  829. }
  830. function feed_post_result(feedid, result) {
  831. if(result) {
  832. location.reload();
  833. }
  834. }
  835. function feed_more_show(feedid) {
  836. var showid = 'feed_more_'+feedid;
  837. var opid = 'feed_a_more_'+feedid;
  838. $(showid).style.display = '';
  839. $(showid).className = 'sub_doing';
  840. $(opid).innerHTML = '&laquo; 收起列表';
  841. $(opid).onclick = function() {
  842. feed_more_close(feedid);
  843. }
  844. }
  845. function feed_more_close(feedid) {
  846. var showid = 'feed_more_'+feedid;
  847. var opid = 'feed_a_more_'+feedid;
  848. $(showid).style.display = 'none';
  849. $(opid).innerHTML = '&raquo; 更多动态';
  850. $(opid).onclick = function() {
  851. feed_more_show(feedid);
  852. }
  853. }
  854. function poll_post_result(id, result) {
  855. if(result) {
  856. var aObj = $('__'+id).getElementsByTagName("a");
  857. window.location.href = aObj[0].href;
  858. }
  859. }
  860. function show_click(idtype, id, clickid) {
  861. ajaxget('home.php?mod=spacecp&ac=click&op=show&clickid='+clickid+'&idtype='+idtype+'&id='+id, 'click_div');
  862. showCreditPrompt();
  863. }
  864. function feed_menu(feedid, show) {
  865. var obj = $('a_feed_menu_'+feedid);
  866. if(obj) {
  867. if(show) {
  868. obj.style.display='block';
  869. } else {
  870. obj.style.display='none';
  871. }
  872. }
  873. var obj = $('feedmagic_'+feedid);
  874. if(obj) {
  875. if(show) {
  876. obj.style.display='block';
  877. } else {
  878. obj.style.display='none';
  879. }
  880. }
  881. }
  882. function showbirthday(){
  883. var el = $('birthday');
  884. var birthday = el.value;
  885. el.length=0;
  886. el.options.add(new Option('日', ''));
  887. for(var i=0;i<28;i++){
  888. el.options.add(new Option(i+1, i+1));
  889. }
  890. if($('birthmonth').value!="2"){
  891. el.options.add(new Option(29, 29));
  892. el.options.add(new Option(30, 30));
  893. switch($('birthmonth').value){
  894. case "1":
  895. case "3":
  896. case "5":
  897. case "7":
  898. case "8":
  899. case "10":
  900. case "12":{
  901. el.options.add(new Option(31, 31));
  902. }
  903. }
  904. } else if($('birthyear').value!="") {
  905. var nbirthyear=$('birthyear').value;
  906. if(nbirthyear%400==0 || (nbirthyear%4==0 && nbirthyear%100!=0)) el.options.add(new Option(29, 29));
  907. }
  908. el.value = birthday;
  909. }
  910. function magicColor(elem, t) {
  911. t = t || 10;
  912. elem = (elem && elem.constructor == String) ? $(elem) : elem;
  913. if(!elem){
  914. setTimeout(function(){magicColor(elem, t-1);}, 400);
  915. return;
  916. }
  917. if(window.mcHandler == undefined) {
  918. window.mcHandler = {elements:[]};
  919. window.mcHandler.colorIndex = 0;
  920. window.mcHandler.run = function(){
  921. var color = ["#CC0000","#CC6D00","#CCCC00","#00CC00","#0000CC","#00CCCC","#CC00CC"][(window.mcHandler.colorIndex++) % 7];
  922. for(var i = 0, L=window.mcHandler.elements.length; i<L; i++)
  923. window.mcHandler.elements[i].style.color = color;
  924. }
  925. }
  926. window.mcHandler.elements.push(elem);
  927. if(window.mcHandler.timer == undefined) {
  928. window.mcHandler.timer = setInterval(window.mcHandler.run, 500);
  929. }
  930. }
  931. function passwordShow(value) {
  932. if(value==4) {
  933. $('span_password').style.display = '';
  934. $('tb_selectgroup').style.display = 'none';
  935. } else if(value==2) {
  936. $('span_password').style.display = 'none';
  937. $('tb_selectgroup').style.display = '';
  938. } else {
  939. $('span_password').style.display = 'none';
  940. $('tb_selectgroup').style.display = 'none';
  941. }
  942. }
  943. function getgroup(gid) {
  944. if(gid) {
  945. var x = new Ajax();
  946. x.get('home.php?mod=spacecp&ac=privacy&inajax=1&op=getgroup&gid='+gid, function(s){
  947. s = s + ' ';
  948. $('target_names').innerHTML += s;
  949. });
  950. }
  951. }
  952. function pmsendappend() {
  953. $('pm_append').style.display = '';
  954. $('pm_append').id = '';
  955. div = document.createElement('div');
  956. div.id = 'pm_append';
  957. div.style.display = 'none';
  958. $('pm_ul').appendChild(div);
  959. $('replymessage').value = '';
  960. showCreditPrompt();
  961. }
  962. function succeedhandle_pmsend(locationhref, message, param) {
  963. ajaxget('home.php?mod=spacecp&ac=pm&op=viewpmid&pmid=' + param['pmid'], 'pm_append', 'ajaxwaitid', '', null, 'pmsendappend()');
  964. }
  965. function getchatpmappendmember() {
  966. var users = document.getElementsByName('users[]');
  967. var appendmember = '';
  968. if(users.length) {
  969. var comma = '';
  970. for(var i = 0; i < users.length; i++) {
  971. appendmember += comma + users[i].value;
  972. if(!comma) {
  973. comma = ',';
  974. }
  975. }
  976. }
  977. if($('username').value) {
  978. appendmember = appendmember ? (appendmember + ',' + $('username').value) : $('username').value;
  979. }
  980. var href = $('a_appendmember').href + '&memberusername=' + appendmember;
  981. showWindow('a_appendmember', href, 'get', 0);
  982. }
  983. function markreadpm(markreadids) {
  984. var markreadidarr = markreadids.split(',');
  985. if(markreadidarr.length > 0) {
  986. for(var i = 0; i < markreadidarr.length; i++) {
  987. $(markreadidarr[i]).className = 'bbda cl';
  988. }
  989. }
  990. }
  991. function setpmstatus(form) {
  992. var ids_gpmid = new Array();
  993. var ids_plid = new Array();
  994. var type = '';
  995. var requesturl = '';
  996. var markreadids = new Array();
  997. for(var i = 0; i < form.elements.length; i++) {
  998. var e = form.elements[i];
  999. if(e.id && e.id.match('a_delete') && e.checked) {
  1000. var idarr = new Array();
  1001. idarr = e.id.split('_');
  1002. if(idarr[1] == 'deleteg') {
  1003. ids_gpmid.push(idarr[2]);
  1004. markreadids.push('gpmlist_' + idarr[2]);
  1005. } else if(idarr[1] == 'delete') {
  1006. ids_plid.push(idarr[2]);
  1007. markreadids.push('pmlist_' + idarr[2]);
  1008. }
  1009. }
  1010. }
  1011. if(ids_gpmid.length > 0) {
  1012. requesturl += '&gpmids=' + ids_gpmid.join(',');
  1013. }
  1014. if(ids_plid.length > 0) {
  1015. requesturl += '&plids=' + ids_plid.join(',');
  1016. }
  1017. if(requesturl) {
  1018. ajaxget('home.php?mod=spacecp&ac=pm&op=setpmstatus' + requesturl, '', 'ajaxwaitid', '', 'none', 'markreadpm(\''+ markreadids.join(',') +'\')');
  1019. }
  1020. }
  1021. function changedeletedpm(pmid) {
  1022. $('pmlist_' + pmid).style.display = 'none';
  1023. var membernum = parseInt($('membernum').innerHTML);
  1024. $('membernum').innerHTML = membernum - 1;
  1025. }
  1026. function changeOrderRange(id) {
  1027. if(!$(id)) return false;
  1028. var url = window.location.href;
  1029. var a = $(id).getElementsByTagName('a');
  1030. for(var i = 0; i < a.length; i++) {
  1031. a[i].onclick = function () {
  1032. if(url.indexOf("&orderby=") == -1) {
  1033. url += "&orderby=" + this.id;
  1034. } else {
  1035. url = url.replace(/orderby=.*/, "orderby=" + this.id);
  1036. }
  1037. window.location = url;
  1038. return false;
  1039. }
  1040. }
  1041. }
  1042. function addBlockLink(id, tag) {
  1043. if(!$(id)) return false;
  1044. var a = $(id).getElementsByTagName(tag);
  1045. var taglist = {'A':1, 'INPUT':1, 'IMG':1};
  1046. for(var i = 0, len = a.length; i < len; i++) {
  1047. a[i].onmouseover = function () {
  1048. if(this.className.indexOf(' hover') == -1) {
  1049. this.className = this.className + ' hover';
  1050. }
  1051. };
  1052. a[i].onmouseout = function () {
  1053. this.className = this.className.replace(' hover', '');
  1054. };
  1055. a[i].onclick = function (e) {
  1056. e = e ? e : window.event;
  1057. var target = e.target || e.srcElement;
  1058. if(!taglist[target.tagName]) {
  1059. window.location.href = $(this.id + '_a').href;
  1060. }
  1061. };
  1062. }
  1063. }
  1064. function checkSynSignature() {
  1065. if($('to_signhtml').value == '1') {
  1066. $('syn_signature').className = 'syn_signature';
  1067. $('to_signhtml').value = '0';
  1068. } else {
  1069. $('syn_signature').className = 'syn_signature_check';
  1070. $('to_signhtml').value = '1';
  1071. }
  1072. }
  1073. function searchpostbyusername(keyword, srchuname) {
  1074. window.location.href = 'search.php?mod=forum&srchtxt=' + keyword + '&srchuname=' + srchuname + '&searchsubmit=yes';
  1075. }
  1076. function removeVisitor(event, uid) {
  1077. window.location = 'home.php?mod=space&uid='+uid+'&do=index&view=admin&additional=removevlog';
  1078. event.preventDefault();
  1079. event.stopPropagation();
  1080. }