//Examine the browser 检测浏览器的函数 var userAgent = navigator.userAgent.toLowerCase(); var is_opera = (userAgent.indexOf('opera') != -1); var is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.')); var is_webtv = (userAgent.indexOf('webtv') != -1); var is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv)); var is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1)); var is_moz = ((navigator.product == 'Gecko') && (!is_saf)); var is_kon = (userAgent.indexOf('konqueror') != -1); var is_ns = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf)); var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4)); var is_mac = (userAgent.indexOf('mac') != -1);
//Global registers var currentblogid; var currentstarid; var currentcommentid; var switchcomandmes; var securitycodejs=null; var onetimecounter=1;
//Get absolute path, fix bug of IE when base path is set var gotourl = location.href; var absbaseurl; var abspath; var r_identifier=gotourl.lastIndexOf("/read.php/"); var r_identifier2=gotourl.lastIndexOf("/post/"); var r_identifier3=gotourl.lastIndexOf("/tag/"); if (r_identifier==-1) { r_identifier=r_identifier2; } if (r_identifier==-1) { r_identifier=r_identifier3; } if (r_identifier!=-1) { absbaseurl = gotourl.substr(0, r_identifier)+"/"; var simplegotourl=absbaseurl.replace("http://", ''); r_identifier2=simplegotourl.indexOf("/"); abspath=simplegotourl.substr(r_identifier2+1); } else { absbaseurl=''; abspath=null; } //Is Ajax supported? if ((is_ie & !is_ie4) || is_moz || is_saf || is_opera) var shutajax=0; else var shutajax=1;
//For firefox, tell Firefox not to display the content you input in last session if (is_moz) { var tmp_c=document.getElementById('v_content'); if (tmp_c) tmp_c.value=''; }
//Show/Hide a DIV function showhidediv(id){ try{ var panel=document.getElementById(id); if(panel){ if(panel.style.display=='none'){ panel.style.display='block'; }else{ panel.style.display='none'; } } }catch(e){} }
function addhtml (id, htmlcode, uniqueid) { var panel=document.getElementById(id); var hiddenpannel=document.getElementById(uniqueid); if(panel){ hiddenpannel.value=''; hiddenpannel.value=panel.innerHTML; panel.innerHTML=hiddenpannel.value+htmlcode; hiddenpannel.value+=htmlcode; } }
//Admin reply function ajax_adminreply (commentid) { if (shutajax==0) { var admid='adminreplycontent'+commentid; var adminreplycontent = blogencode(document.getElementById(admid).value); var postData = "unuse=unuse&adminreplycontent="+adminreplycontent; var gourl=absbaseurl+"admin.php?ajax=on&go="+switchcomandmes+"_addadminreply_"+commentid; currentcommentid=commentid; makeRequest(gourl, 'quickadminreply', 'POST', postData); } else { var admid='formadminreply'+commentid; document.getElementById(admid).submit(); } }
function ajax_adminreply_edit (commentid, rptype) { switchcomandmes=rptype; ajax_adminreply(commentid); }