Last active
August 29, 2015 14:02
-
-
Save jixunmoe/7befaa57d8f65a1ced0e to your computer and use it in GitHub Desktop.
Chinese JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var 中文 = (function () { | |
var _ = window; | |
_.真 = true; | |
_.假 = false; | |
[{ | |
源: document, | |
中文: '文档', | |
映射: { | |
createTextNode: '创建文本节点', | |
createElement: '创建元素', | |
body: '页面' | |
}, | |
目标为类: false | |
}, { | |
源: Array, | |
中文: '数组', | |
映射: { | |
push: '加入' | |
}, | |
目标为类: true | |
}, { | |
源: Element, | |
中文: '元素', | |
映射: { | |
appendChild: '插入元素' | |
}, | |
目标为类: true | |
}].map (function (枚举项) { | |
if (!_[枚举项.中文]) _[枚举项.中文] = {}; | |
for (var 映射项 in 枚举项.映射) | |
if (枚举项.映射.hasOwnProperty(映射项)) | |
if (枚举项.目标为类) | |
枚举项.源.prototype[枚举项.映射[映射项]] = 枚举项.源.prototype[映射项]; | |
else | |
_[枚举项.中文][枚举项.映射[映射项]] = 枚举项.源[映射项].bind ? 枚举项.源[映射项].bind(枚举项.源) : 枚举项.源[映射项]; | |
}); | |
return _; | |
})(); | |
文档.页面.插入元素 (文档.创建文本节点('用中文写代码 2333')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment