page.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. [DESTOON B2B System] Copyright (c) 2008-2018 www.destoon.com
  3. This is NOT a freeware, use is subject to license.txt
  4. */
  5. function Print(i) {if(isIE) {window.print();} else {var i = i ? i : 'content'; var w = window.open('','',''); w.opener = null; w.document.write('<div style="width:630px;">'+Dd(i).innerHTML+'</div>'); w.window.print();}}
  6. function addFav(t) {document.write('<a href="'+window.location.href+'" title="'+document.title.replace(/<|>|'|"|&/g, '')+'" rel="sidebar" onclick="if(UA.indexOf(\'chrome\') != -1){alert(\''+L['chrome_fav_tip']+'\');return false;}window.external.addFavorite(this.href, this.title);return false;">'+t+'</a>');}
  7. function SendFav(mid, itemid) {
  8. mid = mid ? mid : 0;
  9. itemid = itemid ? itemid : 0;
  10. var htm = '<form method="post" action="'+MEPath+'favorite.php" id="dfavorite" target="_blank">';
  11. htm += '<input type="hidden" name="action" value="add"/>';
  12. htm += '<input type="hidden" name="title" value="'+$('#title').html()+'"/>';
  13. htm += '<input type="hidden" name="url" value="'+window.location.href+'"/>';
  14. htm += '<input type="hidden" name="mid" value="'+mid+'"/>';
  15. htm += '<input type="hidden" name="itemid" value="'+itemid+'"/>';
  16. htm += '</form>';
  17. $('#destoon_space').html(htm);
  18. Dd('dfavorite').submit();
  19. }
  20. function SendReport(c) {
  21. var c = c ? c : ($('#title').length > 0 ? $('#title').html() : document.title)+'\n'+window.location.href;
  22. var htm = '<form method="post" action="'+DTPath+'api/report.php" id="dreport" target="_blank">';
  23. htm += '<textarea style="display:none;" name="content">'+c+'</textarea>';
  24. htm += '</form>';
  25. $('#destoon_space').html(htm);
  26. Dd('dreport').submit();
  27. }
  28. function Dshare(mid, id) {Go(DTPath+'api/share.php?mid='+mid+'&itemid='+id);}
  29. function Dsearch(i) {
  30. if(Dd('destoon_kw').value.length < 1 || Dd('destoon_kw').value == L['keyword_message']) {
  31. Dd('destoon_kw').value = '';window.setTimeout(function(){Dd('destoon_kw').value = L['keyword_message'];}, 500);
  32. return false;
  33. }
  34. if(i && Dd('destoon_search').action.indexOf('/api/') == -1) {$('#destoon_moduleid').remove();$('#destoon_spread').remove();}
  35. return true;
  36. }
  37. function Dsearch_adv() {Go(Dd('destoon_search').action.indexOf('/api/') != -1 ? DTPath+'api/search.php?moduleid='+Dd('destoon_moduleid').value : Dd('destoon_search').action);}
  38. function Dsearch_top() {if(Dsearch(0)){Dd('destoon_search').action = DTPath+'api/search.php';Dd('destoon_spread').value=1;Dd('destoon_search').submit();}}
  39. function View(s) {window.open(DTPath+'api/view.php?img='+s);}
  40. function setModule(i, n) {Dd('destoon_search').action = DTPath+'api/search.php';Dd('destoon_moduleid').value = i;searchid = i;Dd('destoon_select').value = n;$('#search_module').fadeOut('fast');Dd('destoon_kw').focus();}
  41. function setTip(w) {Dh('search_tips'); Dd('destoon_kw').value = w; Dd('destoon_search').submit();}
  42. var tip_word = '';
  43. function STip(w) {
  44. if(w.length < 2) {Dd('search_tips').innerHTML = ''; Dh('search_tips'); return;}
  45. if(w == tip_word) {return;} else {tip_word = w;}
  46. $.post(AJPath, 'action=tipword&mid='+searchid+'&word='+w, function(data) {
  47. if(data) {
  48. Ds('search_tips'); Dd('search_tips').innerHTML = data + '<label onclick="Dh(\'search_tips\');">'+L['search_tips_close']+'&nbsp;&nbsp;</label>';
  49. } else {
  50. Dd('search_tips').innerHTML = ''; Dh('search_tips');
  51. }
  52. });
  53. }
  54. function SCTip(k) {
  55. var o = Dd('search_tips');
  56. if(o.style.display == 'none') {
  57. if(o.innerHTML != '') Ds('search_tips');
  58. } else {
  59. if(k == 13) {Dd('destoon_search').submit(); return;}
  60. Dd('destoon_kw').blur();
  61. var d = o.getElementsByTagName('div'); var l = d.length; var n, p; var c = w = -2;
  62. for(var i=0; i<l; i++) {if(d[i].className == 'search_t_div_2') c = i;}
  63. if(c == -2) {
  64. n = 0; p = l-1;
  65. } else if(c == 0) {
  66. n = 1; p = -1;
  67. } else if(c == l-1) {
  68. n = -1; p = l-2;
  69. } else {
  70. n = c+1; p = c-1;
  71. }
  72. w = k == 38 ? p : n;
  73. if(c >= 0) d[c].className = 'search_t_div_1';
  74. if(w >= 0) d[w].className = 'search_t_div_2';
  75. if(w >= 0) {var r = d[w].innerHTML.split('>'); Dd('destoon_kw').value = r[2];} else {Dd('destoon_kw').value = tip_word;}
  76. }
  77. }
  78. function user_login() {
  79. if(Dd('user_name').value.length < 2) {Dd('user_name').focus(); return false;}
  80. if(Dd('user_pass').value == 'password' || Dd('user_pass').value.length < 6) {Dd('user_pass').focus(); return false;}
  81. }
  82. function show_answer(u, i) {$("#s_answer").append('<iframe src="'+u+'answer.php?itemid='+i+'" name="destoon_answer" id="des'+'toon_answer" style="width:100%;height:380px;" scrolling="no" frameborder="0"></iframe>');}
  83. function show_task(s) {s=s===''?'':s+'&';document.write('<script type="text/javascript" src="'+DTPath+'api/task.js.php?'+s+'refresh='+Math.random()+'.js"></script>');}
  84. var sell_n = 0;
  85. function sell_tip(o, i) {
  86. if(o.checked) {sell_n++; Dd('item_'+i).style.backgroundColor='#F1F6FC';} else {Dd('item_'+i).style.backgroundColor='#FFFFFF'; sell_n--;}
  87. if(sell_n < 0) sell_n = 0;
  88. if(sell_n > 1) {
  89. var aTag = o; var leftpos = toppos = 0;
  90. do {aTag = aTag.offsetParent; leftpos += aTag.offsetLeft; toppos += aTag.offsetTop;
  91. } while(aTag.offsetParent != null);
  92. var X = o.offsetLeft + leftpos - 10;
  93. var Y = o.offsetTop + toppos - 70;
  94. Dd('sell_tip').style.left = X + 'px';
  95. Dd('sell_tip').style.top = Y + 'px';
  96. o.checked ? Ds('sell_tip') : Dh('sell_tip');
  97. } else {
  98. Dh('sell_tip');
  99. }
  100. }
  101. function img_tip(o, i) {
  102. if(i) {
  103. if(i.indexOf('nopic.gif') == -1) {
  104. if(i.indexOf('.thumb.') != -1) {var t = i.split('.thumb.');var s = t[0];} else {var s = i;}
  105. var aTag = o; var leftpos = toppos = 0;
  106. do {aTag = aTag.offsetParent; leftpos += aTag.offsetLeft; toppos += aTag.offsetTop;
  107. } while(aTag.offsetParent != null);
  108. var X = o.offsetLeft + leftpos + 90;
  109. var Y = o.offsetTop + toppos - 20;
  110. Dd('img_tip').style.left = X + 'px';
  111. Dd('img_tip').style.top = Y + 'px';
  112. Ds('img_tip');
  113. Inner('img_tip', '<img src="'+s+'" onload="if(this.width<200) {Dh(\'img_tip\');}else if(this.width>300){this.width=300;}Dd(\'img_tip\').style.width=this.width+\'px\';"/>')
  114. }
  115. } else {
  116. Dh('img_tip');
  117. }
  118. }
  119. function Dqrcode() {
  120. var url = $('meta[http-equiv=mobile-agent]').attr('content');
  121. url = url ? url.substr(17) : window.location.href;
  122. if($('#destoon_qrcode').length > 0) {
  123. if($('#destoon_qrcode').html().length < 10) {
  124. $('#destoon_qrcode').css({'position':'fixed','z-index':'99999','left':'50%','top':'0','margin-left':'-130px','width':'260px','background':'#FFFFFF','text-align':'center'});
  125. $('#destoon_qrcode').html('<div style="text-align:right;color:#555555;font-size:16px;font-family:Verdana;font-weight:100;padding-right:6px;cursor:pointer;">x</div><img src="'+DTPath+'api/qrcode.png.php?auth='+encodeURIComponent(url)+'" width="140" height="140"/><div style="padding:10px 0;font-size:14px;font-weight:bold;color:#555555;">扫一扫,直接在手机上打开</div><div style="padding-bottom:20px;color:#999999;">推荐微信、QQ扫一扫等扫码工具</div>');
  126. $('#destoon_qrcode').click(function(){$('#destoon_qrcode').fadeOut('fast');});
  127. }
  128. $('#destoon_qrcode').fadeIn('fast');
  129. }
  130. }
  131. function Dmobile() {
  132. var url = $('meta[http-equiv=mobile-agent]').attr('content');
  133. Go(DTPath+'api/mobile.php'+(url ? '?uri='+encodeURIComponent(url.substr(17)) : ''));
  134. }
  135. function oauth_logout() {
  136. set_cookie('oauth_site', '');
  137. set_cookie('oauth_user', '');
  138. window.location.reload();
  139. }