朴灵的 EventProxy, README 里有个例子:
var proxy = new EventProxy();
var render = function (template, data, l10n){
_.template(template, data);
};
proxy.assign("template", "data", "l10n", render);
$.get("template", function (template) {
// something| /** | |
| * modified from http://gist.github.com/527683 | |
| * only improve slightly to get small | |
| */ | |
| var ie = function(v, p, needle, undef) { | |
| needle = p.getElementsByTagName('br'); | |
| while( | |
| p.innerHTML = '<!--[if gt IE ' + (++v) + ']><br><![endif]-->', |
| <script> | |
| ;(function(d, s, c, n, h) { | |
| c = d.getElementsByTagName(s); | |
| c = c[c.length - 1]; c.id = "t-a-{pid}"; | |
| n = d.createElement(s); | |
| n.async = 1; | |
| n.src = 'http://{host}/{path}?i={pid}'; | |
| h = d.getElementsByTagName('head')[0]; | |
| if(h) h.insertBefore(n, h.firstChild); | |
| })(document, 'script'); |
朴灵的 EventProxy, README 里有个例子:
var proxy = new EventProxy();
var render = function (template, data, l10n){
_.template(template, data);
};
proxy.assign("template", "data", "l10n", render);
$.get("template", function (template) {
// something| // oldj:设 A = $("#id a"),B = $("#id .c a"),求 A - B。要求: | |
| // 1、不能用 jQuery 等框架; | |
| // 2、兼容 IE6 在内的各大浏览器; | |
| // 3、尽可能高效; | |
| // 4、尽可能简短。 | |
| function getWanted() { | |
| var root = document.getElementById('id') | |
| var all = root.getElementsByTagName('*') |
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==
function xx() {
function hello(name) {
alert('Hello, ' + name);
}
eval('(hello("New user"))')
| for (var i = 0; a < 3; i++) { | |
| setTimeout(function() { | |
| console.log(a); | |
| }, 0); | |
| }; | |
| // 控制台中的输出结果是什么? |
| [ | |
| '{{repeat(5, 7)}}', | |
| { | |
| id: '{{index}}', | |
| guid: '{{guid}}', | |
| isActive: '{{bool}}', | |
| balance: '{{numeric(1000,4000,%=$0,0.00)}}', | |
| picture: 'http://placehold.it/32x32', | |
| age: '{{numeric(20,40)}}', | |
| name: '{{firstName}} {{surname}}', |