OLD | NEW |
| (Empty) |
1 ;(function() { | |
2 | |
3 var console = {} | |
4 , files = __TESTS__; | |
5 | |
6 console.log = function(text) { | |
7 var args = Array.prototype.slice.call(arguments, 1) | |
8 , i = 0; | |
9 | |
10 text = text.replace(/%\w/g, function() { | |
11 return args[i++] || ''; | |
12 }); | |
13 | |
14 if (window.console) window.console.log(text); | |
15 document.body.innerHTML += '<pre>' + escape(text) + '</pre>'; | |
16 }; | |
17 | |
18 if (!Object.keys) { | |
19 Object.keys = function(obj) { | |
20 var out = [] | |
21 , key; | |
22 | |
23 for (key in obj) { | |
24 if (Object.prototype.hasOwnProperty.call(obj, key)) { | |
25 out.push(key); | |
26 } | |
27 } | |
28 | |
29 return out; | |
30 }; | |
31 } | |
32 | |
33 if (!Array.prototype.forEach) { | |
34 Array.prototype.forEach = function(callback, context) { | |
35 for (var i = 0; i < this.length; i++) { | |
36 callback.call(context || null, this[i], i, obj); | |
37 } | |
38 }; | |
39 } | |
40 | |
41 if (!String.prototype.trim) { | |
42 String.prototype.trim = function() { | |
43 return this.replace(/^\s+|\s+$/g, ''); | |
44 }; | |
45 } | |
46 | |
47 function load() { | |
48 return files; | |
49 } | |
50 | |
51 function escape(html, encode) { | |
52 return html | |
53 .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') | |
54 .replace(/</g, '<') | |
55 .replace(/>/g, '>') | |
56 .replace(/"/g, '"') | |
57 .replace(/'/g, '''); | |
58 } | |
59 | |
60 (__MAIN__)(); | |
61 | |
62 }).call(this); | |
OLD | NEW |