国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > JS > 正文

基于邏輯運算的簡單權(quán)限系統(tǒng)(實現(xiàn)) JS 版

2024-09-06 12:42:55
字體:
供稿:網(wǎng)友
作者: slightboy, 時間: 2006-10-17
此篇為 JS 實現(xiàn)版本, 以前作已交待原理 故不在此多做解釋
如需原理介紹 請查看 VBS 版.
var PermissionType =
{
    Read : 1,
    Write : 2,
    Delete : 4
}
function PermissionSetComponent(value)
{
    this.Value = value;
    this.getRead = function()
    {
        return this.getValue(PermissionType.Read);
    }
    this.setRead = function(value)
    {
        this.setValue(PermissionType.Read, value);
    }
    this.Read = function()
    {
        if (arguments.length > 0)
            this.setValue(PermissionType.Read, arguments[0]);
        else
            return this.getValue(PermissionType.Read);
    }
    this.Write = function()
    {
        if (arguments.length > 0)
            this.setValue(PermissionType.Write, arguments[0]);
        else
            return this.getValue(PermissionType.Write);
    }
    this.Delete = function()
    {
        if (arguments.length > 0)
            this.setValue(PermissionType.Delete, arguments[0]);
        else
            return this.getValue(PermissionType.Delete);
    }
    this.getValue = function(permissionType)
    {
        return (this.Value & permissionType) == permissionType;
    }
    this.setValue = function(permissionType, value)
    {
        if (value)
            this.Value |= permissionType;
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 玛纳斯县| 梨树县| 锦州市| 麻江县| 郸城县| 安丘市| 玉山县| 汤原县| 会昌县| 师宗县| 榕江县| 万州区| 仁寿县| 淮滨县| 湖南省| 保亭| 灵宝市| 东城区| 田林县| 嘉定区| 红原县| 东城区| 许昌县| 庆城县| 庆元县| 遵义县| 扎兰屯市| 阿克苏市| 本溪市| 洪洞县| 肃宁县| 尉犁县| 鄯善县| 金塔县| 崇左市| 丁青县| 平定县| 琼中| 宽城| 玉龙| 西乡县|