javascript里的类思想
来源:互联网 发布:国内烘焙食品行业数据 编辑:程序博客网 时间:2024/04/30 11:06
<script language="javascript" runat="server">
function MyFile(filename, filesize, type, datelastaccessed)
{
this.filename = filename;
this.filesize = filesize;
this.type = type;
this.datelastaccessed = datelastaccessed;
}
function ArrayFile()
{
this.f = new Array();
this.count = 0;
this.add=function(file)
{
this.f.push( file );
this.count+=1;
}
this.max=function(f1, f2, field)
{
switch( field )
{
case "filename":
return f1.filename>f2.filename? true:false;
case "filesize":
return f1.filesize>f2.filesize? true:false;
case "type":
return f1.type>f2.type? true:false;
case "datelastaccessed":
return f1.datelastaccessed>f2.datelastaccessed? true:false;
default:
return false;
}
}
this.sort=function(field, order)
{
//order:desc asc
//field:filename filesize
var len = this.f.length;
if( len < 2 ) return;
var tmp;
for(var i=0; i<len-1; i++)
{
for(var j=i+1; j<len; j++)
{
if( order == "desc")
{
if( !this.max( this.f[i], this.f[j], field ) )
{
tmp = this.f[i];
this.f[i] = this.f[j];
this.f[j] = tmp;
}
}
else if ( order == "asc")
{
if( this.max( this.f[i], this.f[j], field ) )
{
tmp = this.f[i];
this.f[i] = this.f[j];
this.f[j] = tmp;
}
}
}
}
}
}
</script>
function MyFile(filename, filesize, type, datelastaccessed)
{
this.filename = filename;
this.filesize = filesize;
this.type = type;
this.datelastaccessed = datelastaccessed;
}
function ArrayFile()
{
this.f = new Array();
this.count = 0;
this.add=function(file)
{
this.f.push( file );
this.count+=1;
}
this.max=function(f1, f2, field)
{
switch( field )
{
case "filename":
return f1.filename>f2.filename? true:false;
case "filesize":
return f1.filesize>f2.filesize? true:false;
case "type":
return f1.type>f2.type? true:false;
case "datelastaccessed":
return f1.datelastaccessed>f2.datelastaccessed? true:false;
default:
return false;
}
}
this.sort=function(field, order)
{
//order:desc asc
//field:filename filesize
var len = this.f.length;
if( len < 2 ) return;
var tmp;
for(var i=0; i<len-1; i++)
{
for(var j=i+1; j<len; j++)
{
if( order == "desc")
{
if( !this.max( this.f[i], this.f[j], field ) )
{
tmp = this.f[i];
this.f[i] = this.f[j];
this.f[j] = tmp;
}
}
else if ( order == "asc")
{
if( this.max( this.f[i], this.f[j], field ) )
{
tmp = this.f[i];
this.f[i] = this.f[j];
this.f[j] = tmp;
}
}
}
}
}
}
</script>
- javascript里的类思想
- javascript里的类思想
- javascript里的"类"
- Javascript的一些思想
- javascript 和 CoffeeScript 里的类
- JavaScript里的类和继承
- JavaScript里类的相关知识
- javascript里的StringBuilder
- javascript里的this
- javascript 里的 in
- javascript里的prototype
- Javascript 里的 in
- JavaScript里的Boolean
- Javascript 里的 in
- Web设计里的软件工程思想
- 一个软件里透露的一种思想
- Django框架里的MVC思想
- Django框架里的MVC思想
- 执行SP一例
- 表单身份验证
- 刷新SP到一数据库方便制作XSD文件
- GetIdeDiskSerialNumber
- XML VS. CSV
- javascript里的类思想
- 2005年在IT领域创业干点啥?
- Spring 编程入门十大问题解答
- 用 NASM 编写代码(转自http://www.codingnow.com/text/nasm.htm)
- Open question (2:)
- 想搞一个程序员的wiki
- asp.net常用函数
- 试了一天,trackback 终于成功了(同时发现,csdn 的帮助系统 和 blog 是最烂的帮助和最烂的 blog 之一)
- Struts入门经验