⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.js

📁 Bo-Blog v2.1.0 正式版: 2.1.0是2.0.3之后的又一个重大升级版本
💻 JS
📖 第 1 页 / 共 2 页
字号:
		document.getElementById('v_content').focus();
	}
}

// Show/Hide Sidebar
function showHideSidebar(){
  try{
    var objSidebar=document.getElementById("sidebar");
    var objContent=document.getElementById("content");
    if(objSidebar.className!="sidebar-hide"){
      objSidebar.className="sidebar-hide";
      objSidebar.style.display="none";
      objContent.className="content-wide";
	  setCookie('sidebaroff', 1,null, null, null, false);
    }else{
      objSidebar.className="sidebar";
      objSidebar.style.display="block";
      objContent.className="content";
	  setCookie('sidebaroff', 0,null, null, null, false);
    }
  }catch(e){}
}

function loadSidebar(){
  try{
    var objSidebar=document.getElementById("sidebar");
    var objContent=document.getElementById("content");
	var sidebaroff=getCookie ('sidebaroff');
    if(sidebaroff==1){
      objSidebar.className="sidebar-hide";
      objSidebar.style.display="none";
      objContent.className="content-wide";
    }else{
      objSidebar.className="sidebar";
      objSidebar.style.display="block";
      objContent.className="content";
    }
  }catch(e){}
}




//Media Link
function playmedia(strID,strType,strURL,intWidth,intHeight) {
	var objDiv=document.getElementById(strID);
	if (!objDiv) return false;
	if (objDiv.style.display!='none') {
		objDiv.innerHTML='';
		objDiv.style.display='none';
	} else {
		objDiv.innerHTML=makemedia(strType,strURL,intWidth,intHeight,strID);
		objDiv.style.display='block';
	}
}

//Media Build
function makemedia (strType,strURL,intWidth,intHeight,strID) {
	var strHtml;
	switch(strType) {
		case 'wmp':
			strHtml="<object width='"+intWidth+"' height='"+intHeight+"' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'><param name='url' value='"+strURL+"'/><embed width='"+intWidth+"' height='"+intHeight+"' type='application/x-mplayer2' src='"+strURL+"'></embed></object>";
			break;
		case 'swf':
			strHtml="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+intWidth+"' height='"+intHeight+"'><param name='movie' value='"+strURL+"'/><param name='quality' value='high' /><embed src='"+strURL+"' quality='high' type='application/x-shockwave-flash' width='"+intWidth+"' height='"+intHeight+"'></embed></object>";
			break;
		case 'flv':
			strHtml="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+intWidth+"' height='"+intHeight+"'><param name='movie' value='images/others/mediaplayer.swf?file="+strURL+"&bufferlength=10'/><param name='quality' value='high' /><embed src='images/others/mediaplayer.swf?file="+strURL+"&bufferlength=10' quality='high' type='application/x-shockwave-flash' width='"+intWidth+"' height='"+intHeight+"'></embed></object>";
			break;
		case 'real':
			strHtml="<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='"+intWidth+"' height='"+intHeight+"'><param name='src' value='"+absbaseurl+"inc/realplay.php?link="+strURL+"' /><param name='controls' value='Imagewindow' /><param name='console' value='clip1' /><param name='autostart' value='true' /><embed src='"+absbaseurl+"inc/realplay.php?link="+strURL+"' type='audio/x-pn-realaudio-plugin' autostart='true' console='clip1' controls='Imagewindow' width='"+intWidth+"' height='"+intHeight+"'></embed></object><br/><object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='"+intWidth+"' height='44'><param name='src' value='"+absbaseurl+"inc/realplay.php?link="+strURL+"' /><param name='controls' value='ControlPanel' /><param name='console' value='clip1' /><param name='autostart' value='true' /><embed src='"+absbaseurl+"inc/realplay.php?link="+strURL+"' type='audio/x-pn-realaudio-plugin' autostart='true' console='clip1' controls='ControlPanel' width='"+intWidth+"' height='44'></embed></object>";
			break;
	}
	return strHtml;
}

//Font size control
function doZoom(size) {
	document.getElementById('zoomtext').style.fontSize=size+'px';
}


//Cookie
function setCookie(name,value,expiry,path,domain,secure) {
	var nameString = name + "=" + value;
	var expiryString = (expiry == null) ? "" : " ;expires = "+ expiry.toGMTString();
	var pathString = (path == null) ? "" : " ;path = "+ path;
	var domainString = (path == null) ? "" : " ;domain = "+ domain;
	var secureString = (secure) ?";secure" :"";
	document.cookie = nameString + expiryString + pathString + domainString + secureString;
}

function getCookie (name) {
	var CookieFound = false;
	var start = 0;
	var end = 0;
	var CookieString = document.cookie;
	var i = 0;

	while (i <= CookieString.length) {
		start = i ;
		end = start + name.length;
		if (CookieString.substring(start, end) == name){
			CookieFound = true;
			break;
		}
		i++;
	}

	if (CookieFound){
		start = end + 1;
		end = CookieString.indexOf(";",start);
		if (end < start) end = CookieString.length;
		return unescape(CookieString.substring(start, end));
	}
	return "";
}

function deleteCookie(name) {
	var expires = new Date();
	expires.setTime (expires.getTime() - 1);
	setCookie( name , "Delete Cookie", expires,null,null,false);
}

function refreshsecuritycode(areaid, inputid) {
	if (document.getElementById(areaid)) {
		var rnds=Math.random();
		document.getElementById(areaid).innerHTML="<img src='inc/securitycode.php?rand="+rnds+"' alt=''/>";
	}
	if (document.getElementById(inputid)) document.getElementById(inputid).value='';
}

function ajax_login () {
	if (shutajax==0) {
		var username = blogencode(document.getElementById('username').value);
		var password = blogencode(document.getElementById('password').value);
		var tmpSavecookie;
		for (var i=1; i<=5; i++) {
			tmpSavecookie='savecookie'+i;
			if (document.getElementById(tmpSavecookie).checked) {
				var savecookie = blogencode(document.getElementById(tmpSavecookie).value);
				break;
			}
		}
		var postData = "unuse=unuse&username="+username+"&password="+password+"&savecookie="+savecookie;
		if (document.getElementById('securitycode')) postData+="&securitycode="+blogencode(document.getElementById('securitycode').value);
		var gourl=absbaseurl+"login.php?ajax=on&job=ajaxverify";
		makeRequest(gourl, 'quicklogin', 'POST', postData);
	}
}

function quicklogout() {
	setCookie ('userid','',null,null, null, false);
	setCookie ('userpsw','',null,null, null, false);
}

function quickremember() {
	var v_replier = blogencode(document.getElementById('v_replier').value);
	var v_repurl = blogencode(document.getElementById('v_repurl').value);
	var v_repemail = blogencode(document.getElementById('v_repemail').value);
	var dateObjexp= new Date();
	dateObjexp.setSeconds(3600*24*365);
	if (document.getElementById('stat_rememberme').checked) {
		setCookie ('rem_v_replier', v_replier, dateObjexp, null, null, false);
		setCookie ('rem_v_repurl', v_repurl, dateObjexp, null, null, false);
		setCookie ('rem_v_repemail', v_repemail, dateObjexp, null, null, false);
		setCookie ('rem_v_rememberme', '1', dateObjexp, null, null, false);
	} else {
		setCookie ('rem_v_replier', '', dateObjexp, null, null, false);
		setCookie ('rem_v_repurl', '', dateObjexp, null, null, false);
		setCookie ('rem_v_repemail', '', dateObjexp, null, null, false);
		setCookie ('rem_v_rememberme', '0', dateObjexp, null, null, false);
	}
}

function decodetburl (str, ishidden, uniqueid) {
	var resultstr='';
	if (ishidden==1) { //Hidden!
		var randomnumber1=Math.floor(Math.random()*10+1);
		var randomnumber2=Math.floor(Math.random()*10+1);
		resultstr="<span id=\"showtbq"+uniqueid+"\">"+jslang[66]+" <span id=\"qa"+uniqueid+"\">"+randomnumber1+"</span> <strong>+</strong> <span id=\"qb"+uniqueid+"\">"+randomnumber2+"</span> <strong>=</strong> <input type='text' id='ans"+uniqueid+"' maxlength='2' size='2'/> <input type='button' onclick='submithiddentbanswer(\""+uniqueid+"\");' value='"+jslang[1]+"'/><span id=\"answertb"+uniqueid+"\" style=\"display: none;\">"+str+"</span></span>";
	}
	else {
		resultstr="<span id=\"showtbfinal"+uniqueid+"\">"
		var codestr;
		codestr=str.split('%');
		var seed=codestr[0];
		for (var i=1; i<codestr.length; i++) {
			resultstr+=String.fromCharCode(codestr[i]-seed);
		}
		resultstr+="</span> <span onclick=\"CopyText('showtbfinal"+uniqueid+"');\" style=\"cursor: pointer;\">["+jslang[71]+"]</span>";
	}
	return resultstr;
}

function submithiddentbanswer(uniqueid) {
	var randomnumber1=(document.getElementById("qa"+uniqueid)) ? parseInt(document.getElementById("qa"+uniqueid).innerHTML) : 0;
	var randomnumber2=(document.getElementById("qb"+uniqueid)) ? parseInt(document.getElementById("qb"+uniqueid).innerHTML) : 0;
	var anssubmited=(document.getElementById("ans"+uniqueid)) ? parseInt(document.getElementById("ans"+uniqueid).value) : 0;
	if (randomnumber1+randomnumber2!=anssubmited) alert (jslang[67]);
	else {
		var resultstr=(document.getElementById("answertb"+uniqueid)) ? document.getElementById("answertb"+uniqueid).innerHTML : null;
		resultstr=decodetburl (resultstr, 0, 0);
		if (document.getElementById("showtbq"+uniqueid)) document.getElementById("showtbq"+uniqueid).innerHTML=resultstr;
	}
}

function getprotectedblog (blogid, way) {
	var blogpsw=blogencode(document.getElementById('entrypsw'+blogid).value);
	currentblogid=blogid;
	var postData = "unuse=unuse&job=getcontentonly&way="+way+"&blogid="+blogid+"&blogpsw="+blogpsw;
	if (shutajax==0) {
		var gourl=absbaseurl+"visit.php?ajax=on";
		makeRequest(gourl, 'quickgetprotectedblog', 'POST', postData);
	}
}

function promptreppsw () {
	var pswproperty=document.getElementById('stat_property');
	if (!pswproperty) return;
	else if (pswproperty.checked) {
		var pswtxt=prompt(jslang[69],'');
		if (pswtxt==null || pswtxt=='') {
			pswproperty.checked='';
			return;
		} else {
			if (pswtxt.length>12) {
				alert(jslang[70]);
				promptreppsw();
			}
			document.getElementById('v_reppsw').value=pswtxt;
		}
	} else {
		document.getElementById('v_reppsw').value='';
	}
}

function getprotectedreply (repid, way, onetimecounter) {
	var reppsw=blogencode(document.getElementById('reppsw'+repid).value);
	currentcommentid=repid;
	var postData = "unuse=unuse&job=getreplyonly&way="+way+"&reppsw="+reppsw+"&repid="+currentcommentid+"&onetimecounter"+onetimecounter;
	if (shutajax==0) {
		var gourl=absbaseurl+"visit.php?ajax=on";
		makeRequest(gourl, 'quickeditcomment', 'POST', postData);
	}
}


function turnsmileygroup (id) {
	if (document.getElementById('smileygroup')) document.getElementById('smileygroup').innerHTML=emotgroup[id];
}

function smileypreview(ctrl) {

}


//===============================Copy to clipboard=================================//

function CopyText(id) { 
	//copyToClipboard(document.getElementById(id).value); 
	if (document.getElementById(id)) 	{
		var tocopy=document.getElementById(id).innerHTML;
		tocopy=tocopy.replace(/&amp;/g, "&"); 
		copy(tocopy);
	}
}

function copy(text2copy) {
	if (window.clipboardData) { 
		window.clipboardData.setData("Text",text2copy); 
	} else {
		var flashcopier = 'flashcopier'; 
		if(!document.getElementById(flashcopier)) { 
			var divholder = document.createElement('div'); divholder.id = flashcopier; 
			document.body.appendChild(divholder); 
		} 
		document.getElementById(flashcopier).innerHTML = ''; 
		var divinfo = '<embed src="'+absbaseurl+'images/others/_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>'; 
		document.getElementById(flashcopier).innerHTML = divinfo;
		alert(jslang[72]);
	} 
}


function copyToClipboard(meintext)
{
     if (window.clipboardData) 
       {
       alert("ie");
       // the IE-manier
       window.clipboardData.setData("Text", meintext);
       
       // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
       // het is mij echter onbekend vanaf welke versie dit precies werkt:
       }
       else if (window.netscape) 
       { 
       
       // dit is belangrijk maar staat nergens duidelijk vermeld:
       // you have to sign the code to enable this, or see notes below 
       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
       
       // maak een interface naar het clipboard
       var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
       if (!clip) return;
       alert("mozilla");
       // maak een transferable
       var trans = Components.classes['@mozilla.org/widget/transferable;1']
                      .createInstance(Components.interfaces.nsITransferable);
       if (!trans) return;
       
       // specificeer wat voor soort data we op willen halen; text in dit geval
       trans.addDataFlavor('text/unicode');
       
       // om de data uit de transferable te halen hebben we 2 nieuwe objecten 
       // nodig om het in op te slaan
       var str = new Object();
       var len = new Object();
       
       var str = Components.classes["@mozilla.org/supports-string;1"]
                    .createInstance(Components.interfaces.nsISupportsString);
       
       var copytext=meintext;
       
       str.data=copytext;
       
       trans.setTransferData("text/unicode",str,copytext.length*2);
       
       var clipid=Components.interfaces.nsIClipboard;
       
       if (!clip) return false;
       
       clip.setData(trans,null,clipid.kGlobalClipboard);
       
       }
       alert("Following info was copied to your clipboard:\n\n" + meintext);
       return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -