js客户端数据库的对象与函数
2000-12-31 14:10
831 查看
作者:小馄饨_奋斗 发表日期: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客户端数据库的对象与函数
- js客户端数据库的对象与函数
- js中被调用的函数获取调用者对象
- 页面内调用js函数出错:“缺少对象”的解决方法
- js判断对象的某个属性是否为函数
- 对JS克隆以及相关属性,数组,对象,函数的实例分析
- js 获取函数的所有参数和遍历JavaScript某个对象所有的属性名称和值的方法
- js入门·循环与判断/利用函数的简单实例/使用对象/列举对象属性的名称
- JavaScript init 静态方法 对象语言 JS 值传递 函数 Archive Boolean for
- C#代码调用js函数,js函数中的document.getElementById("对象ID")得null值解决办法
- Js整理备忘(07)——函数与对象间的微妙关系(intanceof、constructor)
- js函数中this是全局变量还是当前对象
- js对象内部访问this修饰的成员函数示例
- JS对象的选取函数
- js 多种变量定义(对象直接量,数组直接量和函数直接量)
- js笔记之函数的arguments对象的学习
- js中每个函数中隐含的arguments对象,用语表示调用时实际传递的参数
- 用prototype给JS中的String对象追加函数
- WEB前端-HF-HTML5Programming-笔记-CH4 JS对象与函数
- js对象工厂函数与构造函数