editingall.js
来自「一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG」· JavaScript 代码 · 共 44 行
JS
44 行
var editing=true;var edited=Array();var edT='Unsaved changes will not be saved.';function wbEdit(){}wbEdit.set=function(b){try{if(!shwnF||!shwnF.id){err('wbEdit.set error');return;}if(b){edited[shwnF.id]=true;}else{edited[shwnF.id]=false;}}catch(m){err(m,'wbEdit.set');}}wbEdit.check=function(e){e=getE(e);var warn=false;var t=edT;for(var i in edited){if(edited[i]){warn=true;}}if(warn){e.returnValue=t;return t;}}wbEdit.check2=function(a){try{if(!shwnF||!shwnF.id)return true;if(edited[shwnF.id]){var r=confirm('Are you sure you want to '+a+' this tab? \n\n'+edT+' \n\n Press OK to continue, or Cancel to keep the current tab.');if(r){wbEdit.set(false);}return r;}return true;}catch(m){err(m,'wbEdit.check2');return true;}}window.onbeforeunload=wbEdit.check;var tags;var tagT;function tagFocus(el,own){tags=null;tags=new tagSelector();tags.create(el,own);}function tagBlur(){if(!tags)return;tagT=setTimeout(function(){tags.end();tags=null;},200);}function tagChange(){if(tags)tags.show();}function tagUpdate(a){if(tags)tags.add(a);}function tagSelector(){}tagSelector.prototype.create=function(el,own){if(el.value==el.title){el.value='';}this.elmt=el;var c=dcg('WBautoSelectKeys');if(!c){c=dcc('div');c.id='WBautoSelectKeys';dcg('WBextras').appendChild(c);c.style.cssText='padding:5px;font-size:90%;position:absolute;z-index:1000;border:1px #cccccc solid;background-color:#f1f1f1;';}var txt=el.form.keyList.value;this.keys=txt.split(',');this.selectBox=c;this.show();}tagSelector.prototype.end=function(){if(this.elmt.value==''){this.elmt.value=this.elmt.title;}this.elmt=null;this.selectBox=null;var c=dcg('WBautoSelectKeys');if(c)c.parentNode.removeChild(c);}tagSelector.prototype.add=function(a){clearTimeout(tagT);var txt=this.elmt.value;var res='';while(txt.search(',')!=-1){var pos=txt.search(',');res+=txt.substr(0,pos+1)+' ';txt=txt.substr(pos+1);}var re=RegExp("\\s+",'g');if(a.search(':')==-1){res+=a;}else{res+=a+', ';}this.elmt.value=res.replace(re,' ');this.elmt.focus();this.show();}tagSelector.prototype.getList=function(simple){var txt=this.elmt.value.toLowerCase();var arr=txt.split(',');if(arr.length==0){arr=Array('');}txt=arr[(arr.length-1)];while(txt.substr(0,1)==' '){txt=txt.substr(1);}if(txt.search(':')!=-1){simple=false;}var len=txt.length;var prev;var curr;var lowKey;var lst=Array();for(var i=0;i<this.keys.length;i++){curr=this.keys[i];if((len>0)&&(curr.substr(0,len).toLowerCase()!=txt)){continue;}if(simple){pos=curr.search(':');if(pos !=-1){curr=curr.substr(0,pos);}if(curr==prev){continue;}}lst.push(curr);prev=curr;}if(simple && lst.length<3){return this.getList(false);}return lst;}tagSelector.prototype.show=function(){var lst=this.getList(true);var res='';for(var i=0;i<lst.length;i++){if(lst[i]==''){continue;}res+='<a href="javascript:void(0)" style="white-space:nowrap;font-size:90%;text-decoration:none;display:block" onclick="tagUpdate(\''+lst[i]+'\')">'+lst[i]+'</a>';}if(res==''){this.selectBox.innerHTML='';this.selectBox.style.display="none";return;}this.selectBox.style.display='';this.selectBox.innerHTML=res;var c=findLoc(this.elmt);var y=(c.y-this.selectBox.clientHeight);if(y<0){y=(c.y+this.elmt.clientHeight+6);}this.selectBox.style.top=(y-3)+'px';this.selectBox.style.left=c.x+'px';}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?