clean up for better obfuscation

This commit is contained in:
Misko Hevery 2010-08-11 12:04:02 -07:00
parent 3d5719cd44
commit 044ecb91c1
6 changed files with 45 additions and 57 deletions

View file

@ -25,6 +25,8 @@
</script>
</head>
<body ng:init="$window.$scope = this; $window.browser.lap('ready')" style="display:none;" ng:show="true">
<a href="startup.html">reload</a>
<hr/>
READY
</body>
</html>

View file

@ -1,4 +1,4 @@
array = [].constructor;
var array = [].constructor;
function toJson(obj, pretty){
var buf = [];
@ -6,10 +6,6 @@ function toJson(obj, pretty){
return buf.join('');
}
function toPrettyJson(obj) {
return toJson(obj, true);
}
function fromJson(json) {
if (!json) return json;
try {

View file

@ -44,9 +44,10 @@ function setter(instance, path, value){
}
///////////////////////////////////
var getterFnCache = {};
var JS_KEYWORDS = {};
var scopeId = 0;
getterFnCache = {},
compileCache = {},
JS_KEYWORDS = {};
foreach(
["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default",
"delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto",
@ -88,7 +89,6 @@ function getterFn(path){
///////////////////////////////////
var compileCache = {};
function expressionCompile(exp){
if (typeof exp === 'function') return exp;
var fn = compileCache[exp];
@ -108,7 +108,6 @@ function errorHandlerFor(element, error) {
elementError(element, NG_EXCEPTION, isDefined(error) ? toJson(error) : error);
}
var scopeId = 0;
function createScope(parent, services, existing) {
function Parent(){}
function API(){}

View file

@ -3,31 +3,28 @@ function toString(obj) {return (isDefined(obj) && obj !== null) ? "" + obj : obj
var NUMBER = /^\s*[-+]?\d*(\.\d*)?\s*$/;
extend(angularFormatter, {
'noop':formatter(identity, identity),
'json':formatter(toJson, fromJson),
'boolean':formatter(toString, toBoolean),
'number':formatter(toString,
function(obj){
if (isString(obj) && NUMBER.exec(obj)) {
return obj ? 1*obj : null;
}
throw "Not a number";
}),
'list':formatter(
function(obj) { return obj ? obj.join(", ") : obj; },
function(value) {
var list = [];
foreach((value || '').split(','), function(item){
item = trim(item);
if (item) list.push(item);
});
return list;
}
),
'trim':formatter(
function(obj) { return obj ? trim("" + obj) : ""; }
)
angularFormatter.noop = formatter(identity, identity);
angularFormatter.json = formatter(toJson, fromJson);
angularFormatter['boolean'] = formatter(toString, toBoolean);
angularFormatter.number = formatter(toString, function(obj){
if (isString(obj) && NUMBER.exec(obj)) {
return obj ? 1*obj : null;
}
throw "Not a number";
});
angularFormatter.list = formatter(
function(obj) { return obj ? obj.join(", ") : obj; },
function(value) {
var list = [];
foreach((value || '').split(','), function(item){
item = trim(item);
if (item) list.push(item);
});
return list;
}
);
angularFormatter.trim = formatter(
function(obj) { return obj ? trim("" + obj) : ""; }
);

View file

@ -2,25 +2,18 @@
//JQLite
//////////////////////////////////
var jqCache = {};
var jqName = 'ng-' + new Date().getTime();
var jqId = 1;
var jqCache = {},
jqName = 'ng-' + new Date().getTime(),
jqId = 1,
addEventListener = (window.document.attachEvent ?
function(element, type, fn) {element.attachEvent('on' + type, fn);} :
function(element, type, fn) {element.addEventListener(type, fn, false);}),
removeEventListener = (window.document.detachEvent ?
function(element, type, fn) {element.detachEvent('on' + type, fn); } :
function(element, type, fn) { element.removeEventListener(type, fn, false); });
function jqNextId() { return (jqId++); }
var addEventListener = window.document.attachEvent ?
function(element, type, fn) {
element.attachEvent('on' + type, fn);
} : function(element, type, fn) {
element.addEventListener(type, fn, false);
};
var removeEventListener = window.document.detachEvent ?
function(element, type, fn) {
element.detachEvent('on' + type, fn);
} : function(element, type, fn) {
element.removeEventListener(type, fn, false);
};
function jqClearData(element) {
var cacheId = element[jqName],
cache = jqCache[cacheId];

View file

@ -1,11 +1,12 @@
var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?(#(.*))?$/,
HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/,
DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21};
angularService("$window", bind(window, identity, window));
angularService("$document", function(window){
return jqLite(window.document);
}, {inject:['$window']});
var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?(#(.*))?$/;
var HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/;
var DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21};
angularService("$location", function(browser){
var scope = this,
location = {parse:parseUrl, toString:toString, update:update},