asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0

类:
function DelegateObject(){
    var obj = new Object();

类:
function DelegateObject(){
    var obj = new Object();
    obj.value = "";
    obj.FormatString = null;
    obj.toString = function _toString(){
        if(obj.FormatString != null)
            return this.FormatString(this.Value);
        else
            return this.Value;
    }  
    return obj;
}
var obj = new DelegateObject();

委托:
function DelegateObject(){
    var obj = new Object();
    obj.value = "";
    obj.FormatString = null;
    obj.toString = function _toString(){
        if(obj.FormatString != null)
            return this.FormatString(this.Value);
        else
            return this.Value;
    }  
    return obj;
}

function ConvertToString(value){
    return "Result:" + value;
}
var obj = new DelegateObject();
obj.Value = "Hello World!";
obj.FormatString = ConvertToString;
document.write(obj.toString());

重写:
function DelegateObject(){
    var obj = new Object();
    obj.toString = function _toString(){
        if(obj.FormatString != null)
            return this.FormatString(this.Value);
        else
            return this.Value;
    }  
    return obj;
}

继承:
function DelegateObject(){
    var obj = new Object();
    obj.value = "";
    obj.FormatString = null;
    obj.toString = function _toString(){
        if(obj.FormatString != null)
            return this.FormatString(this.Value);
        else
            return this.Value;
    }  
    return obj;
}

function Class2(){
    var obj = new DelegateObject();
    return obj;
}

function ConvertTOString(value){
    return "Result:" + value;
}

var obj = new Class2();
obj.Value  = "Hello World!";
obj.FormatString = ConvertTOString;
document.write(obj.toString());

事件:
function EventHandler(){
    var eventobj = new Object();
    eventobj._eventHandler = null;
    eventobj.Activate = function _activate(){
        if(eventobj._eventHandler != null)
            eventobj._eventHandler();
    }
    eventobj.Add = function _add(eventHandler){
        eventobj._eventHandler = EventHandler;
    }
    eventobj.Remove = function _remove(){
        eventobj._eventHandler = null;
    }
    return eventobj;
}

function mouseClick(){
    alert("Hello World!");
}

var obj = new EventHandler();
obj.Add(mouseClick());
obj.Activate();

枚举:
function _StatusList(){
    var object = new Object();
    object.正常= "Normal";
    object.删除= "Delete";
    object.审核通过= "Auditing";
    object.驳回 = "OverRule";
    return object;
}
Object.prototype.StatusList = new _StatusList();
function TObject(){
    var obj = new Object();
    obj.Type = "YiZhu";
    obj.Status = Object.StatusList.审核通过;
}
alert(obj.Status);

posted on 2006-04-03 14:33 汪杰 阅读(141) 评论(0)  编辑 收藏 引用 所属分类: hengxing网站jsjavascript
只有注册用户登录后才能发表评论。

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 467659
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜