use native forEach

This commit is contained in:
rlx 2011-04-19 14:11:04 +00:00
parent 6aeb19bc81
commit ddf22df242
5 changed files with 3741 additions and 4134 deletions

View file

@ -969,7 +969,9 @@ Maps
height: 12px;
border: 2px solid rgb(255, 255, 255);
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
.OxMapLabel {
position: absolute;
}
/*

View file

@ -180,35 +180,6 @@ Ox.uid = (function() {
};
}());
Ox.user = function() {
// fixme: move to ox.ui
$.get("http://www.maxmind.com/app/locate_my_ip", function(data) {
var arr = data.split("tblProduct1"),
re = />(.+?)<\/td>\n<td class=output align="center">\n(.*?)\n/,
results = {};
arr.shift();
Ox.forEach(arr, function(v) {
var result = re(v);
results[result[1].replace(/Your |\*/, "")] = result[2];
});
Ox.print(results)
});
return {
document: {
referrer: document.referrer
},
history: {
length: history.length
},
navigator: navigator,
innerHeight: innerHeight,
innerWidth: innerWidth,
screen: screen,
outerHeight: outerHeight,
outerWidth: outerWidth
}
};
/*
================================================================================
Array and Object functions
@ -227,31 +198,33 @@ Ox.avg = function(obj) {
};
Ox.clone = function(obj) {
/*
/***
returns a copy of an array or object
>>> (function() { a = ['val']; b = Ox.clone(a); a[0] = null; return b[0]; }())
'val'
>>> (function() { a = {key: 'val'}; b = Ox.clone(a); a.key = null; return b.key; }())
'val'
*/
***/
return Ox.isArray(obj) ? obj.slice() : Ox.extend({}, obj);
};
Ox.compact = function(arr) {
/*
/***
returns an array without null or undefined values
>>> Ox.compact([null,,1,,2,,3])
[1, 2, 3]
*/
***/
return Ox.map(arr, function(val) {
return Ox.isUndefined(val) ? null : val;
});
}
Ox.count = function(arr) {
/*
Ox.count(['foo', 'bar', 'foo']).foo
/***
returns the number of occu
>>> Ox.count(['foo', 'bar', 'foo']).foo
2
*/
***/
var obj = {};
arr.forEach(function(v) {
obj[v] = (obj[v] || 0) + 1;
@ -384,7 +357,7 @@ Ox.forEach = function(obj, fn) {
var isObject = Ox.isObject(obj), key;
for (key in obj) {
key = isObject ? key : parseInt(key);
if (hasOwnProperty.call(obj, key) && fn(obj[key], key) === false) {
if (/*hasOwnProperty.call(obj, key) && */fn(obj[key], key) === false) {
break;
}
}

View file

@ -88,12 +88,12 @@ $(function() {
var counter = 0,
length = 0,
src = {};
$.each(userAgents, function(name, link) {
Ox.forEach(userAgents, function(link, name) {
if (link) {
length++;
}
});
$.each(userAgents, function(name, link) {
Ox.forEach(userAgents, function(link, name) {
var image;
if (link) {
image = new Image();

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff