js客户端数据库的对象与函数
[入库:2005年8月18日] [更新:2007年3月24日]
|
作者:小馄饨_奋斗 发表日期:2000年12月29日
有时候想在网页上使用客户端数据库,但为了兼容第版本的浏览器不支持xml技术,所以在此编了一些js的dml函数希望有兴趣的朋友一起讨论 function trform() { this.trrc=new array(); this.qrc=new array();//结果
this.currentrc=1;//当前纪录指针 this.lastrc=0;//最后纪录 this.rclength=arguments.length;//字段数
this.trrc[0]=new array();//字段名
for(i=0;i<this.rclength;i++) this.trrc[0][i]=arguments[i];
this.addrc=addrc; //加一条纪录 this.showrc=showrc;//打印当前纪录 this.showprevious=showprevious; this.shownext=shownext;
this.preload=preload; //预装载图像 this.item2index=item2index;//使字段名到数组的索引 this.showthis=showthis; this.isright=isright; this.seek=seek;
}
function addrc() { this.trrc[++this.lastrc]=new array(); for(i=0;i<this.rclength;i++) this.trrc[this.lastrc][i]=arguments[i];
return true;
}
function showrc(){ for(rc=0;rc<this.qrc[0].length;rc++) { theel=eval(this.qrc[0][rc]); if(this.qrc[0][rc].indexof("image")==-1){ theel.innertext=this.qrc[this.currentrc][rc] } else{ theel.src=this.qrc[this.currentrc][rc]; } } return true;
}
function shownext(){ this.seek("all","all") if(++this.currentrc>this.lastrc) this.currentrc=this.lastrc; this.showrc();
}
function showthis(){ this.seek("all","all") this.showrc();
}
function showprevious(){ this.seek("all","all"); if(--this.currentrc==0) this.currentrc=1; this.showrc();
}
function preload(){ if(confirm('您需要先将图片载入内存吗,这样可以提高浏览时的平滑度.如果您的网络速度较慢的话,建议不要载入','明暗界限')){ status='图片装入中'; var imageindex=new array(); var n=0; for(i=0;i<this.rclength;i++){ if(this.trrc[0][i].indexof("image")!=-1) imageindex[n++]=i; } for (i=1;i<=this.lastrc;i++){ for(var ii in imageindex){ var preimage=new image(); preimage.src=this.trrc[i][ii]; status+='.' } } } status=''; return true;
}
function item2index(item) { val=-1 for(i=0;i<this.rclength;i++) if(this.trrc[0][i]==item) val=i;
return val;
}
function isright(rc,item,oper,exp) {
id=this.item2index(item);
ends=false; if(eval("this.trrc[rc][id]"+oper+"exp")) ends=true;
return ends;
}
function seek(exp1,item1) {
var getexp=exp1.split("@");
this.qrc=new array();
var n=0; var showitems=new array();
if(item1=='all') for(i=0;i<this.trrc[0].length;i++) showitems[i]=this.trrc[0][i]; else{ for(i=1;i<arguments.length;i++) showitems[n++]=arguments[i]; }
this.qrc[0]=new array(); for(m=0;m<showitems.length;m++) { this.qrc[0][m]=showitems[m]; }
for(m=0;m<showitems.length;m++) { showitems[m]=this.item2index(showitems[m]); }
temp=1;
if(getexp[0]=='all'){ for(k=1;k<=this.lastrc;k++) { this.qrc[temp++]=new array(); for(i=0;i<showitems.length;i++) { this.qrc[temp-1][i]=this.trrc[k][showitems[i]]; } }
} else { for(k=1;k<=this.lastrc;k++) { if(this.isright(k,getexp[0],getexp[1],getexp[2])) { this.qrc[temp++]=new array(); for(i=0;i<showitems.length;i++) { this.qrc[temp-1][i]=this.trrc[k][showitems[i]]; } } }
}
return this.qrc;
}
|
| 【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】 |
|
本文关键:js客户端数据库的对象与函数
本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)