forked from 0x2620/oxjs
use native forEach
This commit is contained in:
parent
6aeb19bc81
commit
ddf22df242
5 changed files with 3741 additions and 4134 deletions
|
|
@ -969,7 +969,9 @@ Maps
|
||||||
height: 12px;
|
height: 12px;
|
||||||
border: 2px solid rgb(255, 255, 255);
|
border: 2px solid rgb(255, 255, 255);
|
||||||
background: rgba(0, 0, 0, 0.5);
|
background: rgba(0, 0, 0, 0.5);
|
||||||
z-index: 1000;
|
}
|
||||||
|
.OxMapLabel {
|
||||||
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -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
|
Array and Object functions
|
||||||
|
|
@ -227,31 +198,33 @@ Ox.avg = function(obj) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ox.clone = 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]; }())
|
>>> (function() { a = ['val']; b = Ox.clone(a); a[0] = null; return b[0]; }())
|
||||||
'val'
|
'val'
|
||||||
>>> (function() { a = {key: 'val'}; b = Ox.clone(a); a.key = null; return b.key; }())
|
>>> (function() { a = {key: 'val'}; b = Ox.clone(a); a.key = null; return b.key; }())
|
||||||
'val'
|
'val'
|
||||||
*/
|
***/
|
||||||
return Ox.isArray(obj) ? obj.slice() : Ox.extend({}, obj);
|
return Ox.isArray(obj) ? obj.slice() : Ox.extend({}, obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ox.compact = function(arr) {
|
Ox.compact = function(arr) {
|
||||||
/*
|
/***
|
||||||
returns an array without null or undefined values
|
returns an array without null or undefined values
|
||||||
>>> Ox.compact([null,,1,,2,,3])
|
>>> Ox.compact([null,,1,,2,,3])
|
||||||
[1, 2, 3]
|
[1, 2, 3]
|
||||||
*/
|
***/
|
||||||
return Ox.map(arr, function(val) {
|
return Ox.map(arr, function(val) {
|
||||||
return Ox.isUndefined(val) ? null : val;
|
return Ox.isUndefined(val) ? null : val;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ox.count = function(arr) {
|
Ox.count = function(arr) {
|
||||||
/*
|
/***
|
||||||
Ox.count(['foo', 'bar', 'foo']).foo
|
returns the number of occu
|
||||||
|
>>> Ox.count(['foo', 'bar', 'foo']).foo
|
||||||
2
|
2
|
||||||
*/
|
***/
|
||||||
var obj = {};
|
var obj = {};
|
||||||
arr.forEach(function(v) {
|
arr.forEach(function(v) {
|
||||||
obj[v] = (obj[v] || 0) + 1;
|
obj[v] = (obj[v] || 0) + 1;
|
||||||
|
|
@ -384,7 +357,7 @@ Ox.forEach = function(obj, fn) {
|
||||||
var isObject = Ox.isObject(obj), key;
|
var isObject = Ox.isObject(obj), key;
|
||||||
for (key in obj) {
|
for (key in obj) {
|
||||||
key = isObject ? key : parseInt(key);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,12 +88,12 @@ $(function() {
|
||||||
var counter = 0,
|
var counter = 0,
|
||||||
length = 0,
|
length = 0,
|
||||||
src = {};
|
src = {};
|
||||||
$.each(userAgents, function(name, link) {
|
Ox.forEach(userAgents, function(link, name) {
|
||||||
if (link) {
|
if (link) {
|
||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.each(userAgents, function(name, link) {
|
Ox.forEach(userAgents, function(link, name) {
|
||||||
var image;
|
var image;
|
||||||
if (link) {
|
if (link) {
|
||||||
image = new Image();
|
image = new Image();
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue