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

📄 skytree.asp

📁 Absolutely wonderful features you may never imagine before, Skytree v2.0 takes you into a new era of
💻 ASP
字号:
<%
ST_NEW_NODE_TEXT='New Node';function cSkyTree(){this.instanceName='';this.connectionString='';this.tableName='';this.hasQuote=false;this.fldId='';this.fldPrtId='';this.fldText='';this.fldHint='';this.fldOrder='';this.fldIcoLeaf='';this.fldIcoExp='';this.fldIcoCol='';this.filter='';this.fldAddition='';this.iconPath='';this.allowAdd=false;this.allowEdit=false;this.allowDelete=false;this.allowMove=false;this.getNewId=null;this.onGetJSON=null;this.method='';this.expandLevel=0;this.initialized=false;this.rootValue=null;this.rootId=0;this.selFields='';this.connection=Server.CreateObject("ADODB.Connection");this.curDepth=0;this._q='';};cSkyTree.prototype.connectDB=function(){try{this.connection.ConnectionString=this.connectionString;this.connection.Open();return true;}catch(e){this.printErr(e.message);return false;}};cSkyTree.prototype.getJSON=function(prtId){var _l='';var _n,_p,_h;if(prtId==null||prtId==''){_n=this.fldPrtId+' Is Null';}else{_n=this.fldPrtId+' = '+(this.hasQuote?('"'+prtId+'"'):prtId);}_n='SELECT '+this.selFields+' FROM '+this.tableName+' WHERE '+_n+((this.filter=='')?'':'AND ('+this.filter+')')+((this.fldOrder=='')?'':' ORDER BY '+this.fldOrder);_h=this.connection.Execute(_n);this.curDepth++;if(_h.Eof){_l='';}else if((!this.initialized&&this.curDepth<=this.expandLevel)||(this.initialized&&this.curDepth==1)||(this.expandLevel==0)){while(!_h.Eof){_p=this.getJSON(_h(this.fldId));if(_l!=''){_l+=',';}_l+='{';if(this.fldText!=''){_l+='text:\''+_h(this.fldText).Value.replace(/\'/g,'\\\'')+'\',';}if(this.fldHint!=''){_l+='hint:\''+_h(this.fldHint).Value.replace(/\'/g,'\\\'')+'\',';}if(this.fldIcoLeaf!=''&&_h(this.fldIcoLeaf).Value!=null){_l+='iLeaf:\''+this.iconPath+_h(this.fldIcoLeaf).Value+'\',';}if(this.fldIcoExp!=''&&_h(this.fldIcoExp).Value!=null){_l+='iExp:\''+this.iconPath+_h(this.fldIcoExp).Value+'\',';}if(this.fldIcoCol!=''&&_h(this.fldIcoCol).Value!=null){_l+='iCol:\''+this.iconPath+_h(this.fldIcoCol).Value+'\',';}if(this.method!=''){_l+='method:\''+this.getMethodString(_h)+'\',';}if(typeof(this.onGetJSON)=='function'){_l+=this.onGetJSON(_h);}if(_p!=''){_l+=_p+',';}_l+='value:\''+_h(this.fldId).Value+'\'';_l+='}';_h.Movenext();}_l='items:['+_l+']';}else{_l='items:[]';}this.curDepth--;return _l;};cSkyTree.prototype.getMethodString=function(_b){var _j=this.method;var _a;if(_j==''){return '';}else{arr=_j.match(/{@.+}/);if(arr){for(var i=0;i<arr.length;i++){_a=arr[i].replace(/{@(.+)}/g,'$1');_j=_j.replace(arr[i],_b(_a));}}_j=_j.replace(/\'/g,'\\\'');return _j;}};cSkyTree.prototype.getData=function(){var _k;if(this.connection.ConnectionString==''){this.connectDB();}if(this.selFields==''){this.selFields=this.fldId+','+this.fldPrtId;if(this.fldText!=''){this.selFields+=','+this.fldText;}if(this.fldHint!=''){this.selFields+=','+this.fldHint;}if(this.fldIcoLeaf!=''){this.selFields+=','+this.fldIcoLeaf;}if(this.fldIcoExp!=''){this.selFields+=','+this.fldIcoExp;}if(this.fldIcoCol!=''){this.selFields+=','+this.fldIcoCol;}if(this.fldAddition!=''){this.selFields+=','+this.fldAddition;}}_k=this.getJSON(this.rootValue);return _k;};cSkyTree.prototype.putData=function(){var _o=this.getData();_o='<script>'+'var d={'+_o+'};'+'with(parent.'+this.instanceName+'){'+'if(!getNode('+this.rootId+').firstChild){'+'getNode('+this.rootId+').eleSub.innerHTML="";'+'transData('+this.rootId+',d);'+'loaded=true;'+'}'+'}'+'</script>';return _o;};cSkyTree.prototype.del=function(idx,_d){var _o;if(!this.allowDelete){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("DeleteNotAllowed"),"I_WARNING",2000);'+'getNode('+idx+').removeTag();'+'}'+'</script>';}else{if(this.connection.ConnectionString==''){this.connectDB();}var _d=_d.replace(/\'/g,'');this._q=(this.hasQuote?('\''+_d+'\''):_d);this.recursionValues(_d);var _n='DELETE FROM '+this.tableName+' WHERE '+this.fldId+' IN ('+this._q+')';try{this.connection.Execute(_n);_o='<script>'+'with(parent.'+this.instanceName+'){'+'clientRemoveNode('+idx+');'+'}'+'</script>';}catch(e){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("DeleteFail"),"I_ERROR",2000);'+'getNode('+idx+').removeTag();'+'}'+'</script>';}}return _o;};cSkyTree.prototype.recursionValues=function(_d){var _n,_h;if(_d==null||_d==''){_n=this.fldPrtId+' Is Null';}else{_n=this.fldPrtId+' = '+(this.hasQuote?('\''+_d+'\''):_d);}_n='SELECT '+this.fldId+' FROM '+this.tableName+' WHERE '+_n;_h=this.connection.Execute(_n);while(!_h.Eof){this.recursionValues(_h(this.fldId).Value);this._q+=','+(this.hasQuote?('\''+_h(this.fldId)+'\''):_h(this.fldId));_h.Movenext();}};cSkyTree.prototype.edit=function(idx,_d,_c){var _o;if(!this.allowEdit){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("EditNotAllowed"),"I_WARNING",2000);'+'getNode('+idx+').removeTag();'+'}'+'</script>';}else if(this.fldText==''){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("NoTextField"),"I_WARNING",2000);'+'getNode('+idx+').removeTag();'+'}'+'</script>';}else{if(this.connection.ConnectionString==''){this.connectDB();}var _d=_d.replace(/\'/g,'');var _c=_c.replace(/\'/g,'\'\'');var _n='UPDATE '+this.tableName+' SET '+this.fldText+' = \''+_c+'\''+' WHERE '+this.fldId+' = '+(this.hasQuote?('\''+_d+'\''):_d);try{this.connection.Execute(_n);_o='<script>'+'with(parent.'+this.instanceName+'){'+'getNode('+idx+').setText("'+_c.replace(/\"/g,'\\\"').replace(/\'\'/g,'\'')+'");'+'getNode('+idx+').setTag("I_INFO",getStr("EditSuccess"),1000);'+'}'+'</script>';}catch(e){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("EditFail"),"I_ERROR",2000);'+'getNode('+idx+').removeTag();'+'}'+'</script>';}}return _o;};cSkyTree.prototype.move=function(srcIdx,srcValue,_i,pValue,oIdx){var _o;if(!this.allowMove){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("MoveNotAllowed"),"I_WARNING",2000);'+'getNode('+srcIdx+').removeTag();'+'}'+'</script>';}else{if(this.connection.ConnectionString==''){this.connectDB();}srcValue=srcValue.replace(/\'/g,'');pValue=pValue.replace(/\'/g,'\\\'');if(pValue==''){pValue='Null';}var _f=this.resetOrder(pValue,oIdx);_n='UPDATE '+this.tableName+' SET '+this.fldPrtId+' = '+(this.hasQuote?('\''+pValue+'\''):pValue)+(_f?','+this.fldOrder+' = '+_f:'')+' WHERE '+this.fldId+' = '+(this.hasQuote?('\''+srcValue+'\''):srcValue);try{this.connection.Execute(_n);_o='<script>'+'with(parent.'+this.instanceName+'){'+'clientPlaceNode('+srcIdx+','+_i+','+oIdx+');'+'getNode('+srcIdx+').setTag("I_INFO",getStr("MoveSuccess"),1000);'+'}'+'</script>';}catch(e){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("MoveFail"),"I_ERROR",10000);'+'getNode('+srcIdx+').removeTag();'+'}'+'</script>';}}return _o;};cSkyTree.prototype.add=function(idx,_d){var _o,_e;if(!this.allowAdd||(this.getNewId=='')){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("AddNotAllowed"),"I_WARNING",2000);'+'}'+'</script>';}else{if(this.connection.ConnectionString==''){this.connectDB();}if(this.getNewId==null){_e=null}else{_e=eval(this.getNewId+"(this.connection,_d)");}var _f=this.getNewOrder(_d);_n='INSERT INTO '+this.tableName+' ('+(_e?(this.fldId+','):'')+this.fldPrtId+','+this.fldText+(_f?','+this.fldOrder:'')+')'+' VALUES ('+(_e?((this.hasQuote?('\''+_e+'\''):_e))+',':'')+((_d=='')?'Null':(this.hasQuote?('\''+_d+'\''):_d))+',\''+ST_NEW_NODE_TEXT+'\''+(_f?','+_f:'')+')';try{this.connection.Execute(_n);if(_e==null){_n="SELECT MAX("+this.fldId+") AS LasID FROM "+this.tableName;var _g=this.connection.Execute(_n);if(!_g.Eof){_e=_g("LastID").Value;}else{_e='';}}_o='<script>'+'with(parent.'+this.instanceName+'){'+'var aNode=clientAddNode('+idx+',true,3);'+'aNode.setValue('+(this.hasQuote?('"'+_e+'"'):_e)+');'+'aNode.editText();'+'}'+'</script>';}catch(e){_o='<script>'+'with(parent.'+this.instanceName+'){'+'showInfo(getStr("InsertFail"),"I_ERROR",2000);'+'}'+'</script>';}}return _o;};cSkyTree.prototype.getNewOrder=function(prtId){var _n,_h;if(this.fldOrder==''){return null;}if(prtId==null||prtId==''){_n=this.fldPrtId+' Is Null';}else{_n=this.fldPrtId+' = '+(this.hasQuote?('\''+prtId+'\''):prtId);}_n='SELECT MAX('+this.fldOrder+') AS MaxID FROM '+this.tableName+' WHERE '+_n;_h=this.connection.Execute(_n);if(_h('MaxID').Value==null){return 1;}else{return _h('MaxID').Value+1;}};cSkyTree.prototype.resetOrder=function(prtId,oIdx){var _n,_h;var maxOrder;if(this.fldOrder==''){return false;}if(prtId==null||prtId==''){_m=this.fldPrtId+' Is Null';}else{_m=this.fldPrtId+' = '+(this.hasQuote?('\''+prtId+'\''):prtId);}if(oIdx!=0){_n="SELECT MAX("+this.fldOrder+") AS MaxOrder FROM "+"( SELECT TOP "+oIdx+" "+this.fldOrder+" FROM "+this.tableName+" WHERE "+_m+" ORDER BY "+this.fldOrder+") AS Temp";_h=this.connection.Execute(_n);maxOrder=_h('MaxOrder').Value?_h('MaxOrder').Value:0;}else{maxOrder=0;}_n="UPDATE "+this.tableName+" SET "+this.fldOrder+" = "+this.fldOrder+" + 1"+" WHERE "+_m+" AND "+this.fldOrder+" > "+maxOrder;this.connection.Execute(_n);if(oIdx!=0){_n="SELECT TOP 1 "+this.fldOrder+" FROM (SELECT TOP "+oIdx+" "+this.fldOrder+" FROM "+this.tableName+" WHERE "+_m+" ORDER BY "+this.fldOrder+") AS Temp ORDER BY "+this.fldOrder+" DESC";_h=this.connection.Execute(_n);if(_h.Eof){return 1;}else{return _h(this.fldOrder).Value+1;}}else{return 1;}};cSkyTree.prototype.printErr=function(e){Response.Write('<script>'+'with(parent.'+this.instanceName+'){'+'showInfo("'+e.replace(/\"/g,'\\\"')+'","I_ERROR",2000);'+'}'+'</script>');Response.End();}
%>

⌨️ 快捷键说明

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