Skip to content

Commit 044ecb9

Browse files
committed
clean up for better obfuscation
1 parent 3d5719c commit 044ecb9

6 files changed

Lines changed: 44 additions & 56 deletions

File tree

perf/startup.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
</script>
2626
</head>
2727
<body ng:init="$window.$scope = this; $window.browser.lap('ready')" style="display:none;" ng:show="true">
28+
<a href="startup.html">reload</a>
29+
<hr/>
2830
READY
2931
</body>
3032
</html>

src/JSON.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
array = [].constructor;
1+
var array = [].constructor;
22

33
function toJson(obj, pretty){
44
var buf = [];
55
toJsonArray(buf, obj, pretty ? "\n " : null, []);
66
return buf.join('');
77
}
88

9-
function toPrettyJson(obj) {
10-
return toJson(obj, true);
11-
}
12-
139
function fromJson(json) {
1410
if (!json) return json;
1511
try {

src/Scope.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ function setter(instance, path, value){
4444
}
4545

4646
///////////////////////////////////
47-
48-
var getterFnCache = {};
49-
var JS_KEYWORDS = {};
47+
var scopeId = 0;
48+
getterFnCache = {},
49+
compileCache = {},
50+
JS_KEYWORDS = {};
5051
foreach(
5152
["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default",
5253
"delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto",
@@ -88,7 +89,6 @@ function getterFn(path){
8889

8990
///////////////////////////////////
9091

91-
var compileCache = {};
9292
function expressionCompile(exp){
9393
if (typeof exp === 'function') return exp;
9494
var fn = compileCache[exp];
@@ -108,7 +108,6 @@ function errorHandlerFor(element, error) {
108108
elementError(element, NG_EXCEPTION, isDefined(error) ? toJson(error) : error);
109109
}
110110

111-
var scopeId = 0;
112111
function createScope(parent, services, existing) {
113112
function Parent(){}
114113
function API(){}

src/formatters.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,28 @@ function toString(obj) {return (isDefined(obj) && obj !== null) ? "" + obj : obj
33

44
var NUMBER = /^\s*[-+]?\d*(\.\d*)?\s*$/;
55

6-
extend(angularFormatter, {
7-
'noop':formatter(identity, identity),
8-
'json':formatter(toJson, fromJson),
9-
'boolean':formatter(toString, toBoolean),
10-
'number':formatter(toString,
11-
function(obj){
12-
if (isString(obj) && NUMBER.exec(obj)) {
13-
return obj ? 1*obj : null;
14-
}
15-
throw "Not a number";
16-
}),
6+
angularFormatter.noop = formatter(identity, identity);
7+
angularFormatter.json = formatter(toJson, fromJson);
8+
angularFormatter['boolean'] = formatter(toString, toBoolean);
9+
angularFormatter.number = formatter(toString, function(obj){
10+
if (isString(obj) && NUMBER.exec(obj)) {
11+
return obj ? 1*obj : null;
12+
}
13+
throw "Not a number";
14+
});
1715

18-
'list':formatter(
19-
function(obj) { return obj ? obj.join(", ") : obj; },
20-
function(value) {
21-
var list = [];
22-
foreach((value || '').split(','), function(item){
23-
item = trim(item);
24-
if (item) list.push(item);
25-
});
26-
return list;
27-
}
28-
),
16+
angularFormatter.list = formatter(
17+
function(obj) { return obj ? obj.join(", ") : obj; },
18+
function(value) {
19+
var list = [];
20+
foreach((value || '').split(','), function(item){
21+
item = trim(item);
22+
if (item) list.push(item);
23+
});
24+
return list;
25+
}
26+
);
2927

30-
'trim':formatter(
31-
function(obj) { return obj ? trim("" + obj) : ""; }
32-
)
33-
});
28+
angularFormatter.trim = formatter(
29+
function(obj) { return obj ? trim("" + obj) : ""; }
30+
);

src/jqLite.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@
22
//JQLite
33
//////////////////////////////////
44

5-
var jqCache = {};
6-
var jqName = 'ng-' + new Date().getTime();
7-
var jqId = 1;
8-
function jqNextId() { return (jqId++); }
9-
10-
var addEventListener = window.document.attachEvent ?
11-
function(element, type, fn) {
12-
element.attachEvent('on' + type, fn);
13-
} : function(element, type, fn) {
14-
element.addEventListener(type, fn, false);
15-
};
5+
var jqCache = {},
6+
jqName = 'ng-' + new Date().getTime(),
7+
jqId = 1,
8+
addEventListener = (window.document.attachEvent ?
9+
function(element, type, fn) {element.attachEvent('on' + type, fn);} :
10+
function(element, type, fn) {element.addEventListener(type, fn, false);}),
11+
removeEventListener = (window.document.detachEvent ?
12+
function(element, type, fn) {element.detachEvent('on' + type, fn); } :
13+
function(element, type, fn) { element.removeEventListener(type, fn, false); });
1614

17-
var removeEventListener = window.document.detachEvent ?
18-
function(element, type, fn) {
19-
element.detachEvent('on' + type, fn);
20-
} : function(element, type, fn) {
21-
element.removeEventListener(type, fn, false);
22-
};
15+
function jqNextId() { return (jqId++); }
2316

2417
function jqClearData(element) {
2518
var cacheId = element[jqName],

src/services.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?(#(.*))?$/,
2+
HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/,
3+
DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21};
4+
15
angularService("$window", bind(window, identity, window));
26
angularService("$document", function(window){
37
return jqLite(window.document);
48
}, {inject:['$window']});
59

6-
var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?(#(.*))?$/;
7-
var HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/;
8-
var DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21};
910
angularService("$location", function(browser){
1011
var scope = this,
1112
location = {parse:parseUrl, toString:toString, update:update},

0 commit comments

Comments
 (0)