merging changes
This commit is contained in:
parent
94fb1b4d1d
commit
221355f8ba
8 changed files with 8989 additions and 672 deletions
8176
build/js/jquery-1.5.js
vendored
Normal file
8176
build/js/jquery-1.5.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
16
build/js/jquery-1.5.min.js
vendored
Normal file
16
build/js/jquery-1.5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,479 +0,0 @@
|
|||
/*
|
||||
http://www.JSON.org/json2.js
|
||||
2009-09-29
|
||||
|
||||
Public Domain.
|
||||
|
||||
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
|
||||
See http://www.JSON.org/js.html
|
||||
|
||||
This file creates a global JSON object containing two methods: stringify
|
||||
and parse.
|
||||
|
||||
JSON.stringify(value, replacer, space)
|
||||
value any JavaScript value, usually an object or array.
|
||||
|
||||
replacer an optional parameter that determines how object
|
||||
values are stringified for objects. It can be a
|
||||
function or an array of strings.
|
||||
|
||||
space an optional parameter that specifies the indentation
|
||||
of nested structures. If it is omitted, the text will
|
||||
be packed without extra whitespace. If it is a number,
|
||||
it will specify the number of spaces to indent at each
|
||||
level. If it is a string (such as '\t' or ' '),
|
||||
it contains the characters used to indent at each level.
|
||||
|
||||
This method produces a JSON text from a JavaScript value.
|
||||
|
||||
When an object value is found, if the object contains a toJSON
|
||||
method, its toJSON method will be called and the result will be
|
||||
stringified. A toJSON method does not serialize: it returns the
|
||||
value represented by the name/value pair that should be serialized,
|
||||
or undefined if nothing should be serialized. The toJSON method
|
||||
will be passed the key associated with the value, and this will be
|
||||
bound to the value
|
||||
|
||||
For example, this would serialize Dates as ISO strings.
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
|
||||
You can provide an optional replacer method. It will be passed the
|
||||
key and value of each member, with this bound to the containing
|
||||
object. The value that is returned from your method will be
|
||||
serialized. If your method returns undefined, then the member will
|
||||
be excluded from the serialization.
|
||||
|
||||
If the replacer parameter is an array of strings, then it will be
|
||||
used to select the members to be serialized. It filters the results
|
||||
such that only members with keys listed in the replacer array are
|
||||
stringified.
|
||||
|
||||
Values that do not have JSON representations, such as undefined or
|
||||
functions, will not be serialized. Such values in objects will be
|
||||
dropped; in arrays they will be replaced with null. You can use
|
||||
a replacer function to replace those with JSON values.
|
||||
JSON.stringify(undefined) returns undefined.
|
||||
|
||||
The optional space parameter produces a stringification of the
|
||||
value that is filled with line breaks and indentation to make it
|
||||
easier to read.
|
||||
|
||||
If the space parameter is a non-empty string, then that string will
|
||||
be used for indentation. If the space parameter is a number, then
|
||||
the indentation will be that many spaces.
|
||||
|
||||
Example:
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
// text is '["e",{"pluribus":"unum"}]'
|
||||
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
||||
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
||||
|
||||
text = JSON.stringify([new Date()], function (key, value) {
|
||||
return this[key] instanceof Date ?
|
||||
'Date(' + this[key] + ')' : value;
|
||||
});
|
||||
// text is '["Date(---current time---)"]'
|
||||
|
||||
|
||||
JSON.parse(text, reviver)
|
||||
This method parses a JSON text to produce an object or array.
|
||||
It can throw a SyntaxError exception.
|
||||
|
||||
The optional reviver parameter is a function that can filter and
|
||||
transform the results. It receives each of the keys and values,
|
||||
and its return value is used instead of the original value.
|
||||
If it returns what it received, then the structure is not modified.
|
||||
If it returns undefined then the member is deleted.
|
||||
|
||||
Example:
|
||||
|
||||
// Parse the text. Values that look like ISO date strings will
|
||||
// be converted to Date objects.
|
||||
|
||||
myData = JSON.parse(text, function (key, value) {
|
||||
var a;
|
||||
if (typeof value === 'string') {
|
||||
a =
|
||||
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
||||
if (a) {
|
||||
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
||||
+a[5], +a[6]));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
||||
var d;
|
||||
if (typeof value === 'string' &&
|
||||
value.slice(0, 5) === 'Date(' &&
|
||||
value.slice(-1) === ')') {
|
||||
d = new Date(value.slice(5, -1));
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
|
||||
This is a reference implementation. You are free to copy, modify, or
|
||||
redistribute.
|
||||
|
||||
This code should be minified before deployment.
|
||||
See http://javascript.crockford.com/jsmin.html
|
||||
|
||||
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
||||
NOT CONTROL.
|
||||
*/
|
||||
|
||||
/*jslint evil: true, strict: false */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
if (!this.JSON) {
|
||||
this.JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return isFinite(this.valueOf()) ?
|
||||
this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z' : null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
gap,
|
||||
indent,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
rep;
|
||||
|
||||
|
||||
function quote(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ?
|
||||
'"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string' ? c :
|
||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' :
|
||||
'"' + string + '"';
|
||||
}
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
k, // The member key.
|
||||
v, // The member value.
|
||||
length,
|
||||
mind = gap,
|
||||
partial,
|
||||
value = holder[key];
|
||||
|
||||
// If the value has a toJSON method, call it to obtain a replacement value.
|
||||
|
||||
if (value && typeof value === 'object' &&
|
||||
typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
|
||||
// If we were called with a replacer function, then call the replacer to
|
||||
// obtain a replacement value.
|
||||
|
||||
if (typeof rep === 'function') {
|
||||
value = rep.call(holder, key, value);
|
||||
}
|
||||
|
||||
// What happens next depends on the value's type.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return quote(value);
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
|
||||
// If the value is a boolean or null, convert it to a string. Note:
|
||||
// typeof null does not produce 'null'. The case is included here in
|
||||
// the remote chance that this gets fixed someday.
|
||||
|
||||
return String(value);
|
||||
|
||||
// If the type is 'object', we might be dealing with an object or an array or
|
||||
// null.
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
||||
// so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// Make an array to hold the partial results of stringifying this object value.
|
||||
|
||||
gap += indent;
|
||||
partial = [];
|
||||
|
||||
// Is the value an array?
|
||||
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
|
||||
// The value is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
length = value.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
partial[i] = str(i, value) || 'null';
|
||||
}
|
||||
|
||||
// Join all of the elements together, separated with commas, and wrap them in
|
||||
// brackets.
|
||||
|
||||
v = partial.length === 0 ? '[]' :
|
||||
gap ? '[\n' + gap +
|
||||
partial.join(',\n' + gap) + '\n' +
|
||||
mind + ']' :
|
||||
'[' + partial.join(',') + ']';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
|
||||
// If the replacer is an array, use it to select the members to be stringified.
|
||||
|
||||
if (rep && typeof rep === 'object') {
|
||||
length = rep.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
k = rep[i];
|
||||
if (typeof k === 'string') {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (Object.hasOwnProperty.call(value, k)) {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together, separated with commas,
|
||||
// and wrap them in braces.
|
||||
|
||||
v = partial.length === 0 ? '{}' :
|
||||
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
|
||||
mind + '}' : '{' + partial.join(',') + '}';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
// A default replacer method can be provided. Use of the space parameter can
|
||||
// produce text that is more easily readable.
|
||||
|
||||
var i;
|
||||
gap = '';
|
||||
indent = '';
|
||||
|
||||
// If the space parameter is a number, make an indent string containing that
|
||||
// many spaces.
|
||||
|
||||
if (typeof space === 'number') {
|
||||
for (i = 0; i < space; i += 1) {
|
||||
indent += ' ';
|
||||
}
|
||||
|
||||
// If the space parameter is a string, it will be used as the indent string.
|
||||
|
||||
} else if (typeof space === 'string') {
|
||||
indent = space;
|
||||
}
|
||||
|
||||
// If there is a replacer, it must be a function or an array.
|
||||
// Otherwise, throw an error.
|
||||
|
||||
rep = replacer;
|
||||
if (replacer && typeof replacer !== 'function' &&
|
||||
(typeof replacer !== 'object' ||
|
||||
typeof replacer.length !== 'number')) {
|
||||
throw new Error('JSON.stringify');
|
||||
}
|
||||
|
||||
// Make a fake root object containing our value under the key of ''.
|
||||
// Return the result of stringifying the value.
|
||||
|
||||
return str('', {'': value});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
// a JavaScript value if the text is a valid JSON text.
|
||||
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
|
||||
// The walk method is used to recursively walk the resulting structure so
|
||||
// that modifications can be made.
|
||||
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in four stages. In the first stage, we replace certain
|
||||
// Unicode characters with escape sequences. JavaScript handles many characters
|
||||
// incorrectly, either silently deleting them, or treating them as line endings.
|
||||
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// In the second stage, we run the text against regular expressions that look
|
||||
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
||||
// because they can cause invocation, and '=' because it can cause mutation.
|
||||
// But just to be safe, we want to reject all unexpected forms.
|
||||
|
||||
// We split the second stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/.
|
||||
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
|
||||
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
||||
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the third stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional fourth stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a reviver function for possible transformation.
|
||||
|
||||
return typeof reviver === 'function' ?
|
||||
walk({'': j}, '') : j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
631
build/js/ox.js
631
build/js/ox.js
|
@ -1,15 +1,8 @@
|
|||
// todo: check http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
|
||||
|
||||
/*
|
||||
Ox = function(val) {
|
||||
|
||||
var Ox = {
|
||||
version: '0.1.2'
|
||||
};
|
||||
*/
|
||||
if (!window.Ox) {
|
||||
Ox = {
|
||||
version: '0.1.2'
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
@ -18,16 +11,72 @@ Constants
|
|||
*/
|
||||
|
||||
Ox.AMPM = ['AM', 'PM'];
|
||||
Ox.DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
//Ox.DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
Ox.DURATIONS = ['year', 'month', 'day', 'minute', 'second'];
|
||||
Ox.EARTH_RADIUS = 6378137;
|
||||
Ox.EARTH_CIRCUMFERENCE = Ox.EARTH_RADIUS * 2 * Math.PI;
|
||||
Ox.HTML_ENTITIES = {'"': '"', '&': '&', "'": ''',
|
||||
'<': '<', '>': '>'};
|
||||
Ox.MONTHS = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
Ox.HTML_ENTITIES = {
|
||||
'"': '"', '&': '&', "'": ''', '<': '<', '>': '>'
|
||||
};
|
||||
Ox.KEYS = {
|
||||
SECTION: 0, BACKSPACE: 8, TAB: 9, CLEAR: 12, ENTER: 13,
|
||||
SHIFT: 16, CONTROL: 17, OPTION: 18, PAUSE: 19, CAPSLOCK: 20,
|
||||
ESCAPE: 27, SPACE: 32, PAGEUP: 33, PAGEDOWN: 34, END: 35, HOME: 36,
|
||||
LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, INSERT: 45, DELETE: 46, HELP: 47,
|
||||
0: 48, 1: 49, 2: 50, 3: 51, 4: 52, 5: 53, 6: 54, 7: 55, 8: 56, 9: 57,
|
||||
A: 65, B: 66, C: 67, D: 68, E: 69, F: 70, G: 71, H: 72, I: 73, J: 74,
|
||||
K: 75, L: 76, M: 77, N: 78, O: 79, P: 80, Q: 81, R: 82, S: 83, T: 84,
|
||||
U: 85, V: 86, W: 87, X: 88, Y: 89, Z: 90,
|
||||
META_LEFT: 91, META_RIGHT: 92, SELECT: 93,
|
||||
'0_NUMPAD': 96, '1_NUMPAD': 97, '2_NUMPAD': 98, '3_NUMPAD': 99,
|
||||
'4_NUMPAD': 100, '5_NUMPAD': 101, '6_NUMPAD': 102, '7_NUMPAD': 103,
|
||||
'8_NUMPAD': 104, '9_NUMPAD': 105, '*_NUMPAD': 106, '+_NUMPAD': 107,
|
||||
'\n_NUMPAD': 108, '-_NUMPAD': 109, '._NUMPAD': 110, '/_NUMPAD': 111,
|
||||
F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118,
|
||||
F8: 110, F9: 120, F10: 121, F11: 122, F12: 123, F13: 124, F14: 125,
|
||||
F15: 126, F16: 127, NUMLOCK: 144, SCROLLLOCK: 145,
|
||||
';': 186, '=': 187, ',': 188, '-': 189, '.': 190, '/': 191, '`': 192,
|
||||
'(': 219, '\\': 220, ')': 221, '\'': 222
|
||||
};
|
||||
//Ox.MAX_LATITUDE = Ox.deg(Math.atan(Ox.sinh(Math.PI)));
|
||||
//Ox.MIN_LATITUDE = -Ox.MAX_LATITUDE;
|
||||
Ox.MONTHS = [
|
||||
'January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December'
|
||||
];
|
||||
Ox.PREFIXES = ['K', 'M', 'G', 'T', 'P'];
|
||||
Ox.WEEKDAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
|
||||
'Friday', 'Saturday', 'Sunday'];
|
||||
Ox.SYMBOLS = {
|
||||
DOLLAR: '\u0024',
|
||||
CENT: '\u00A2', POUND: '\u00A3', CURRENCY: '\u00A4', YEN: '\u00A5',
|
||||
BULLET: '\u2022', ELLIPSIS: '\u2026', PERMILLE: '\u2030',
|
||||
COLON: '\u20A1', CRUZEIRO: '\u20A2', FRANC: '\u20A3', LIRA: '\u20A4',
|
||||
NAIRA: '\u20A6', PESETA: '\u20A7', WON: '\u20A9', SHEQEL: '\u20AA',
|
||||
DONG: '\u20AB', EURO: '\u20AC', KIP: '\u20AD', TUGRIK: '\u20AE',
|
||||
DRACHMA: '\u20AF', PESO: '\u20B1', GUARANI: '\u20B2', AUSTRAL: '\u20B3',
|
||||
HRYVNIA: '\u20B4', CEDI: '\u20B5', TENGE: '\u20B8', RUPEE: '\u20B9',
|
||||
CELSIUS: '\u2103', FAHRENHEIT: '\u2109', POUNDS: '\u2114', OUNCE: '\u2125',
|
||||
OHM: '\u2126', KELVIN: '\u212A', ANGSTROM: '\u212B', INFO: '\u2139',
|
||||
LEFT: '\u2190', UP: '\u2191', RIGHT: '\u2192', DOWN: '\u2193',
|
||||
HOME: '\u2196', END: '\u2198', RETURN: '\u21A9',
|
||||
REDO: '\u21BA', UNDO: '\u21BB', PAGEUP: '\u21DE', PAGEDOWN: '\u21DF',
|
||||
CAPSLOCK: '\u21EA', TAB: '\u21E5', SHIFT: '\u21E7', INFINITY: '\u221E',
|
||||
CONTROL: '\u2303', COMMAND: '\u2318', ENTER: '\u2324', ALT: '\u2325',
|
||||
DELETE: '\u2326', CLEAR:'\u2327',BACKSPACE: '\u232B', OPTION: '\u2387',
|
||||
NAVIGATE: '\u2388', ESCAPE: '\u238B', EJECT: '\u23CF',
|
||||
SPACE: '\u2423', DIAMOND: '\u25C6',
|
||||
STAR: '\u2605', SOUND: '\u266B', TRASH: '\u267A', FLAG: '\u2691',
|
||||
ANCHOR: '\u2693', GEAR: '\u2699', ATOM: '\u269B', WARNING: '\u26A0',
|
||||
CUT: '\u2702', BACKUP: '\u2707', FLY: '\u2708', CHECK: '\u2713',
|
||||
CLOSE: '\u2715', BALLOT: '\u2717', WINDOWS: '\u2756',
|
||||
EDIT: '\uF802', CLICK: '\uF803', APPLE: '\uF8FF'
|
||||
};
|
||||
Ox.TYPES = [
|
||||
'Arguments', 'Array', 'Boolean', 'Date', 'Element', 'Function', 'Infinity',
|
||||
'NaN', 'Null', 'Number', 'Object', 'RegExp', 'String', 'Undefined'
|
||||
];
|
||||
Ox.WEEKDAYS = [
|
||||
'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'
|
||||
];
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
@ -39,38 +88,46 @@ Ox.getset = function(obj, args, callback, context) {
|
|||
/***
|
||||
Generic getter and setter function
|
||||
|
||||
Ox.getset(obj) returns obj
|
||||
can be implemented like this:
|
||||
|
||||
that.options = function() {
|
||||
return Ox.getset(options, arguments, setOption(key, val), that);
|
||||
}
|
||||
|
||||
Ox.getset(obj, []) returns obj
|
||||
Ox.getset(obj, [key]) returns obj.key
|
||||
Ox.getset(obj, [key, val], callback, context)
|
||||
Ox.getset(obj, [{key: val, ...}], callback, context) sets obj.key to val,
|
||||
calls callback(key, val),
|
||||
calls callback(key, val)
|
||||
for any changed value,
|
||||
returns context
|
||||
(for chaining)
|
||||
|
||||
>>> o = new function() { var o = {}, s = function() {}, t = this; t.o = function() { return Ox['getset'](o, arguments, s, t); }; return t; }
|
||||
true
|
||||
>>> Ox.getset({}, []) && o.o('key', 'val').o('key')
|
||||
'val'
|
||||
>>> Ox.getset({}, []) && o.o({key: 'val', foo: 'bar'}).o().foo
|
||||
'bar'
|
||||
>>> Ox.getset({}, []) && typeof o.o({foo: undefined}).o('foo') == 'undefined'
|
||||
true
|
||||
>>> delete o
|
||||
true
|
||||
***/
|
||||
var obj_ = obj,
|
||||
args_ = {},
|
||||
args = args || [],
|
||||
callback = callback || {},
|
||||
context = context || {},
|
||||
length = args.length,
|
||||
ret;
|
||||
if (length == 0) {
|
||||
// getset()
|
||||
var obj_ = Ox.clone(obj), ret;
|
||||
if (args.length == 0) {
|
||||
// getset([])
|
||||
ret = obj;
|
||||
} else if (length == 1 && Ox.isString(args[0])) {
|
||||
// getset(str)
|
||||
} else if (args.length == 1 && !Ox.isObject(args[0])) {
|
||||
// getset([key])
|
||||
ret = obj[args[0]]
|
||||
} else {
|
||||
// getset(str, val) or getset({str: val, ...})
|
||||
if (length == 1) {
|
||||
args = args[0];
|
||||
} else {
|
||||
args_[args[0]] = args[1];
|
||||
args = args_;
|
||||
}
|
||||
obj = $.extend(obj, args);
|
||||
$.each(args, function(key, value) {
|
||||
if (!obj_ || !obj_[key] || obj_[key] !== value) {
|
||||
callback(key, value);
|
||||
// getset([key, val]) or getset([{key: val, ...}])
|
||||
args = Ox.makeObject(Ox.isObject(args[0]) ? args[0] : args);
|
||||
obj = Ox.extend(obj, args);
|
||||
Ox.forEach(args, function(val, key) {
|
||||
if (!obj_ || !Ox.isEqual(obj_[key], val)) {
|
||||
callback && callback(key, val);
|
||||
}
|
||||
});
|
||||
ret = context;
|
||||
|
@ -82,7 +139,7 @@ Ox.print = function() {
|
|||
/*
|
||||
*/
|
||||
if (window.console) {
|
||||
var args = $.makeArray(arguments),
|
||||
var args = Ox.makeArray(arguments),
|
||||
date = new Date;
|
||||
args.unshift(Ox.formatDate(date, '%H:%M:%S') + '.' +
|
||||
(Ox.pad(+date % 1000, 3)));
|
||||
|
@ -109,7 +166,7 @@ Ox.user = function() {
|
|||
re = />(.+?)<\/td>\n<td class=output align="center">\n(.*?)\n/,
|
||||
results = {};
|
||||
arr.shift();
|
||||
$.each(arr, function(i, v) {
|
||||
Ox.forEach(arr, function(v) {
|
||||
var result = re(v);
|
||||
results[result[1].replace(/Your |\*/, "")] = result[2];
|
||||
});
|
||||
|
@ -150,6 +207,10 @@ Ox.avg = function(obj) {
|
|||
|
||||
Ox.clone = function(obj) {
|
||||
/*
|
||||
>>> (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);
|
||||
};
|
||||
|
@ -189,38 +250,6 @@ Ox.each = function(obj, fn) {
|
|||
return obj;
|
||||
};
|
||||
|
||||
Ox.equals = function(obj0, obj1) {
|
||||
/*
|
||||
>>> Ox.equals([1, 2, 3], [1, 2, 3])
|
||||
true
|
||||
>>> Ox.equals({a: 1, b: [2, 3], c: {d: '4'}}, {a: 1, b: [2, 3], c: {d: '4'}})
|
||||
true
|
||||
>>> Ox.equals(function() { return; }, function() { return; });
|
||||
true
|
||||
*/
|
||||
var ret = false;
|
||||
if (obj0 === obj1) {
|
||||
ret = true;
|
||||
} else if (typeof(obj0) == typeof(obj1)) {
|
||||
if (obj0 == obj1) {
|
||||
ret = true;
|
||||
} else if (Ox.isArray(obj0) && obj0.length == obj1.length) {
|
||||
Ox.forEach(obj0, function(v, i) {
|
||||
ret = Ox.equals(v, obj1[i]);
|
||||
return ret;
|
||||
});
|
||||
} else if (Ox.isDate(obj0)) {
|
||||
ret = obj0.getTime() == obj1.getTime();
|
||||
} else if (Ox.isObject(obj0)) {
|
||||
ret = Ox.equals(Ox.keys(obj0), Ox.keys(obj1)) &&
|
||||
Ox.equals(Ox.values(obj0), Ox.values(obj1));
|
||||
} else if (Ox.isFunction(obj0)) {
|
||||
ret = obj0.toString() == obj1.toString();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Ox.every = function(obj, fn) {
|
||||
/*
|
||||
Ox.every() works for arrays, objects and strings, unlike [].every()
|
||||
|
@ -240,10 +269,10 @@ Ox.every = function(obj, fn) {
|
|||
|
||||
Ox.extend = function() {
|
||||
/*
|
||||
>>> Ox.extend({a: 1}, {b: 2}, {c: 3}).c
|
||||
>>> Ox.extend({a: 1, b: 1, c: 1}, {b: 2, c: 2}, {c: 3}).c
|
||||
3
|
||||
*/
|
||||
var obj = {};
|
||||
var obj = arguments[0];
|
||||
Ox.forEach(Array.prototype.slice.call(arguments, 1), function(arg, i) {
|
||||
Ox.forEach(arg, function(val, key) {
|
||||
obj[key] = val;
|
||||
|
@ -257,8 +286,8 @@ Ox.filter = function(arr, fn) {
|
|||
Ox.filter works for arrays and strings, like $.grep(), unlike [].filter()
|
||||
>>> Ox.filter([2, 1, 0], function(v, i) { return v == i; })
|
||||
[1]
|
||||
>>> Ox.filter("210", function(v, i) { return v == i; })
|
||||
[1]
|
||||
>>> Ox.filter('210', function(v, i) { return v == i; })
|
||||
['1']
|
||||
*/
|
||||
var i, len = arr.length, ret = [];
|
||||
for (i = 0; i < len; i++) {
|
||||
|
@ -360,6 +389,48 @@ Ox.getPositionById = function(arr, id) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
Ox.isEmpty = function(val) {
|
||||
return Ox.length(val) == 0;
|
||||
};
|
||||
|
||||
Ox.isEqual = function(obj0, obj1) {
|
||||
/*
|
||||
>>> Ox.isEqual(false, false)
|
||||
true
|
||||
>>> Ox.isEqual(0, 0)
|
||||
true
|
||||
>>> Ox.isEqual(NaN, NaN)
|
||||
false
|
||||
>>> Ox.isEqual([1, 2, 3], [1, 2, 3])
|
||||
true
|
||||
>>> Ox.isEqual({a: 1, b: [2, 3], c: {d: '4'}}, {a: 1, b: [2, 3], c: {d: '4'}})
|
||||
true
|
||||
>>> Ox.isEqual(function() { return; }, function() { return; });
|
||||
true
|
||||
*/
|
||||
var ret = false;
|
||||
if (obj0 === obj1) {
|
||||
ret = true;
|
||||
} else if (typeof(obj0) == typeof(obj1)) {
|
||||
if (obj0 == obj1) {
|
||||
ret = true;
|
||||
} else if (Ox.isArray(obj0) && obj0.length == obj1.length) {
|
||||
Ox.forEach(obj0, function(v, i) {
|
||||
ret = Ox.isEqual(v, obj1[i]);
|
||||
return ret;
|
||||
});
|
||||
} else if (Ox.isDate(obj0)) {
|
||||
ret = obj0.getTime() == obj1.getTime();
|
||||
} else if (Ox.isObject(obj0)) {
|
||||
ret = Ox.isEqual(Ox.keys(obj0), Ox.keys(obj1)) &&
|
||||
Ox.isEqual(Ox.values(obj0), Ox.values(obj1));
|
||||
} else if (Ox.isFunction(obj0)) {
|
||||
ret = obj0.toString() == obj1.toString();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Ox.keys = function(obj) {
|
||||
/*
|
||||
>>> Ox.keys({a: 1, b: 2, c: 3})
|
||||
|
@ -374,6 +445,8 @@ Ox.keys = function(obj) {
|
|||
|
||||
Ox.length = function(obj) {
|
||||
/*
|
||||
>>> Ox.length([1, 2, 3])
|
||||
3
|
||||
>>> Ox.length({"a": 1, "b": 2, "c": 3})
|
||||
3
|
||||
*/
|
||||
|
@ -384,46 +457,42 @@ Ox.length = function(obj) {
|
|||
return length;
|
||||
};
|
||||
|
||||
Ox.makeArray = function(arr) {
|
||||
Ox.makeArray = function(arg) {
|
||||
/*
|
||||
like $.makeArray()
|
||||
>>> Ox.makeArray("foo")
|
||||
["foo"]
|
||||
>>> Ox.makeArray(["foo"])
|
||||
["foo"]
|
||||
>>> (function() { return Ox.makeArray(arguments); }("foo"))
|
||||
["foo"]
|
||||
>>> (function() { return Ox.makeArray(arguments); }(["foo"]))
|
||||
["foo"]
|
||||
>>> Ox.makeArray('foo', 'bar')
|
||||
['foo', 'bar']
|
||||
>>> (function() { return Ox.makeArray(arguments); }('foo', 'bar'))
|
||||
['foo', 'bar']
|
||||
*/
|
||||
// fixme: this doesn't work for numbers
|
||||
var ret = [], i = 0, len = arr.length;
|
||||
if (Ox.isString(arr)) {
|
||||
ret = [arr];
|
||||
} else {
|
||||
for (i = 0; i < len; i++) {
|
||||
ret.push(arr[i]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return Array.prototype.slice.call(
|
||||
Ox.isArguments(arg) ? arg : arguments
|
||||
);
|
||||
};
|
||||
|
||||
Ox.makeObject = function(arr) {
|
||||
Ox.makeObject = function() {
|
||||
/*
|
||||
>>> Ox.makeObject("foo", "bar").foo
|
||||
"bar"
|
||||
>>> Ox.makeObject(["foo", "bar"]).foo
|
||||
"bar"
|
||||
>>> Ox.makeObject({foo: "bar"}).foo
|
||||
"bar"
|
||||
>/>> (function() { return Ox.makeObject(arguments); }("foo", "bar")).foo // fixme
|
||||
"bar"
|
||||
>/>> (function() { return Ox.makeObject(arguments); }({foo: "bar"})).foo
|
||||
>>> (function() { return Ox.makeObject(arguments); }("foo", "bar")).foo
|
||||
"bar"
|
||||
*/
|
||||
var obj = {};
|
||||
if (arguments.length == 1) {
|
||||
obj = arguments[0];
|
||||
var arg = arguments, obj = {};
|
||||
if (arg.length == 1) {
|
||||
if (Ox.isObject(arg[0])) {
|
||||
// ({foo: 'bar'})
|
||||
obj = arg[0];
|
||||
} else {
|
||||
// (['foo', 'bar'])
|
||||
obj[arg[0][0]] = arg[0][1];
|
||||
}
|
||||
} else {
|
||||
obj[arguments[0]] = arguments[1];
|
||||
// ('foo', 'bar')
|
||||
obj[arg[0]] = arg[1];
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
@ -438,7 +507,6 @@ Ox.map = function(arr, fn) {
|
|||
>>> Ox.map(new Array(3), function(v, i) { return i; })
|
||||
[0, 1, 2]
|
||||
*/
|
||||
// fixme: why not [].map.call(str, fn)?
|
||||
var i, len = arr.length, val, ret = [];
|
||||
for (i = 0; i < len; i++) {
|
||||
if ((val = fn(arr[i], i)) !== null) {
|
||||
|
@ -493,12 +561,11 @@ Ox.range = function(start, stop, step) {
|
|||
stop = arguments.length > 1 ? stop : arguments[0];
|
||||
start = arguments.length > 1 ? start : 0;
|
||||
step = step || (start <= stop ? 1 : -1);
|
||||
var range = [],
|
||||
i;
|
||||
var arr = [], i;
|
||||
for (i = start; step > 0 ? i < stop : i > stop; i += step) {
|
||||
range.push(i);
|
||||
arr.push(i);
|
||||
}
|
||||
return range;
|
||||
return arr;
|
||||
};
|
||||
|
||||
Ox.serialize = function(obj) {
|
||||
|
@ -515,9 +582,11 @@ Ox.serialize = function(obj) {
|
|||
|
||||
Ox.setPropertyOnce = function(arr, str) {
|
||||
/*
|
||||
>>> Ox.setPropertyOnce([{selected: false}, {selected: false}])
|
||||
>>> Ox.setPropertyOnce([{selected: false}, {selected: false}], 'selected')
|
||||
0
|
||||
>>> Ox.setPropertyOnce([{selected: true}, {selected: true}])
|
||||
>>> Ox.setPropertyOnce([{selected: false}, {selected: true}], 'selected')
|
||||
1
|
||||
>>> Ox.setPropertyOnce([{selected: true}, {selected: true}], 'selected')
|
||||
0
|
||||
*/
|
||||
var pos = -1;
|
||||
|
@ -573,14 +642,32 @@ Ox.sum = function(obj) {
|
|||
return sum;
|
||||
};
|
||||
|
||||
Ox.toArray = function(obj) {
|
||||
/*
|
||||
>>> Ox.toArray('foo')
|
||||
['foo']
|
||||
>>> Ox.toArray(['foo'])
|
||||
['foo']
|
||||
*/
|
||||
var arr;
|
||||
if (Ox.isArray(obj)) {
|
||||
arr = obj;
|
||||
} else if (Ox.isArguments(obj)) {
|
||||
arr = Ox.makeArray(obj);
|
||||
} else {
|
||||
arr = [obj];
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
Ox.unique = function(arr) {
|
||||
/*
|
||||
>>> Ox.unique([1, 2, 3, 1])
|
||||
[1, 2, 3]
|
||||
*/
|
||||
var unique = [];
|
||||
$.each(arr, function(i, v) {
|
||||
unique.indexOf(v) == -1 && unique.push(v);
|
||||
Ox.forEach(arr, function(val) {
|
||||
unique.indexOf(val) == -1 && unique.push(val);
|
||||
});
|
||||
return unique;
|
||||
};
|
||||
|
@ -731,7 +818,6 @@ Ox.getDateInWeek = function(date, weekday) {
|
|||
>>> Ox.formatDate(Ox.getDateInWeek(new Date("1/1/2000"), 1), "%A, %B %e, %Y")
|
||||
"Monday, December 27, 1999"
|
||||
*/
|
||||
Ox.print("getDateInWeek", date.toString(), weekday)
|
||||
var date = date || new Date(),
|
||||
sourceWeekday = Ox.formatDate(date, "%u");
|
||||
targetWeekday = Ox.isNumber(weekday) ? weekday :
|
||||
|
@ -744,41 +830,51 @@ Ox.getDateInWeek = function(date, weekday) {
|
|||
|
||||
Ox.getDayOfTheYear = function(date) {
|
||||
/*
|
||||
>>> Ox.getDayOfTheYear(new Date("12/31/2000"))
|
||||
366
|
||||
>>> Ox.getDayOfTheYear(new Date("12/31/2002"))
|
||||
365
|
||||
>>> Ox.getDayOfTheYear(new Date("12/31/2004"))
|
||||
366
|
||||
*/
|
||||
var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
return function(date) {
|
||||
date = date || new Date();
|
||||
var month = date.getMonth(),
|
||||
year = date.getFullYear();
|
||||
return Ox.sum(Ox.map(Ox.range(month), function(i) {
|
||||
return Ox.getDaysInMonth(year, i + 1);
|
||||
})) + date.getDate();
|
||||
/*
|
||||
var day = date.getDate(),
|
||||
month = date.getMonth(),
|
||||
month = date.getMonth();
|
||||
i;
|
||||
for (i = 0; i < month; i++) {
|
||||
day += days[i];
|
||||
day += Ox.DAYS[i];
|
||||
}
|
||||
if (month >= 2 && Ox.isLeapYear(date.getFullYear())) {
|
||||
day++;
|
||||
}
|
||||
return day;
|
||||
*/
|
||||
};
|
||||
}();
|
||||
|
||||
Ox.getDaysInMonth = function(year, month) {
|
||||
/*
|
||||
>>> Ox.getDaysInMonth(2000, 2)
|
||||
28
|
||||
29
|
||||
>>> Ox.getDaysInMonth("2002", "Feb")
|
||||
28
|
||||
>>> Ox.getDaysInMonth("2004", "February")
|
||||
29
|
||||
*/
|
||||
Ox.print("getDaysInMonth", year, month)
|
||||
var year = parseInt(year),
|
||||
month = Ox.isNumber(month) ? month :
|
||||
Ox.map(Ox.MONTHS, function(v, i) {
|
||||
return v.substr(0, 3) == month.substr(0, 3) ? i + 1 : null;
|
||||
})[0];
|
||||
return Ox.DAYS[month - 1] + (month == 2 && Ox.isLeapYear(year));
|
||||
return new Date(year, month, 0).getDate()
|
||||
//return Ox.DAYS[month - 1] + (month == 2 && Ox.isLeapYear(year));
|
||||
}
|
||||
|
||||
Ox.getFirstDayOfTheYear = function(date) {
|
||||
|
@ -854,9 +950,9 @@ Ox.getTime = function() {
|
|||
|
||||
Ox.getTimezoneOffsetString = function(date) {
|
||||
/*
|
||||
Time zone offset string (-1200 - +1200)
|
||||
>>> Ox.getTimezoneOffsetString(new Date("01/01/2000"))
|
||||
"+0100"
|
||||
Time zone offset string ('-1200' - '+1200')
|
||||
>>> Ox.getTimezoneOffsetString(new Date('01/01/2000')).length
|
||||
5
|
||||
*/
|
||||
var offset = (date || new Date()).getTimezoneOffset();
|
||||
return (offset < 0 ? '+' : '-') +
|
||||
|
@ -881,10 +977,14 @@ Ox.getWeek = function(date) {
|
|||
|
||||
Ox.isLeapYear = function(year) {
|
||||
/*
|
||||
>>> Ox.isLeapYear(2000)
|
||||
>>> Ox.isLeapYear(1900)
|
||||
false
|
||||
>>> Ox.isLeapYear(2000)
|
||||
true
|
||||
>>> Ox.isLeapYear(2004)
|
||||
true
|
||||
*/
|
||||
return year % 4 == 0 && year % 400 != 0;
|
||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1015,7 +1115,7 @@ Encoding functions
|
|||
>>> Ox.decodeBase32('?').toString()
|
||||
'NaN'
|
||||
*/
|
||||
return parseInt($.map(str.toUpperCase(), function(char) {
|
||||
return parseInt(Ox.map(str.toUpperCase(), function(char) {
|
||||
var index = digits.indexOf(aliases[char] || char);
|
||||
return (index == -1 ? ' ' : index).toString(32);
|
||||
}).join(''), 32);
|
||||
|
@ -1131,7 +1231,7 @@ Encoding functions
|
|||
>>> Ox.encodeHTML('äbçdê')
|
||||
'äbçdê'
|
||||
*/
|
||||
return $.map(str, function(v) {
|
||||
return Ox.map(str, function(v) {
|
||||
var code = v.charCodeAt(0);
|
||||
return code < 128 ? (v in Ox.HTML_ENTITIES ? Ox.HTML_ENTITIES[v] : v) :
|
||||
'&#x' + Ox.pad(code.toString(16).toUpperCase(), 4) + ';';
|
||||
|
@ -1150,8 +1250,9 @@ Encoding functions
|
|||
'äbçdê'
|
||||
*/
|
||||
// relies on dom, but shorter than using this:
|
||||
// http://www.w3.org/TR/html5/named-character-references.html
|
||||
return $('<div/>').html(str)[0].childNodes[0].nodeValue;
|
||||
// http://www.w3.org/TR/html5/named-character-references.html
|
||||
return Ox.element('div').html(str)[0].childNodes[0].nodeValue;
|
||||
//return $('<div/>').html(str)[0].childNodes[0].nodeValue;
|
||||
};
|
||||
|
||||
Ox.encodePNG = function(img, str) {
|
||||
|
@ -1230,7 +1331,7 @@ Encoding functions
|
|||
>>> Ox.encodeUTF8('¥€$')
|
||||
'\u00C2\u00A5\u00E2\u0082\u00AC\u0024'
|
||||
*/
|
||||
return $.map(Array.prototype.slice.call(str), function(chr) {
|
||||
return Ox.map(Array.prototype.slice.call(str), function(chr) {
|
||||
var code = chr.charCodeAt(0),
|
||||
str = '';
|
||||
if (code < 128) {
|
||||
|
@ -1254,7 +1355,7 @@ Encoding functions
|
|||
>>> Ox.decodeUTF8('\u00C2\u00A5\u00E2\u0082\u00AC\u0024')
|
||||
'¥€$'
|
||||
*/
|
||||
var bytes = $.map(str, function(v) {
|
||||
var bytes = Ox.map(str, function(v) {
|
||||
return v.charCodeAt(0);
|
||||
}),
|
||||
i = 0,
|
||||
|
@ -1303,6 +1404,10 @@ Ox.formatColor = function() {
|
|||
};
|
||||
|
||||
Ox.formatCurrency = function(num, str, dec) {
|
||||
/*
|
||||
>>> Ox.formatCurrency(1000, '$', 2)
|
||||
'$1,000.00'
|
||||
*/
|
||||
return str + Ox.formatNumber(num, dec);
|
||||
};
|
||||
|
||||
|
@ -1364,7 +1469,7 @@ Ox.formatDate = function() {
|
|||
"12:03:04 AM"
|
||||
>>> Ox.formatDate(_date, "%S") // Zero-padded second
|
||||
"04"
|
||||
>>> Ox.formatDate(_date, "%s") // Number of seconds since the Epoch
|
||||
>/> Ox.formatDate(_date, "%s") // Number of seconds since the Epoch
|
||||
"1104620584"
|
||||
>>> Ox.formatDate(_date, "%T") // Time
|
||||
"00:03:04"
|
||||
|
@ -1390,11 +1495,11 @@ Ox.formatDate = function() {
|
|||
"2005"
|
||||
>>> Ox.formatDate(_date, "%y") // Abbreviated year
|
||||
"05"
|
||||
>>> Ox.formatDate(_date, "%Z") // Time zone name
|
||||
>/> Ox.formatDate(_date, "%Z") // Time zone name
|
||||
"CET"
|
||||
>>> Ox.formatDate(_date, "%z") // Time zone offset
|
||||
>/> Ox.formatDate(_date, "%z") // Time zone offset
|
||||
"+0100"
|
||||
>>> Ox.formatDate(_date, "%+") // Formatted date and time
|
||||
>/> Ox.formatDate(_date, "%+") // Formatted date and time
|
||||
"Sun Jan 2 00:03:04 CET 2005"
|
||||
>>> Ox.formatDate(_date, "%%")
|
||||
"%"
|
||||
|
@ -1407,12 +1512,7 @@ Ox.formatDate = function() {
|
|||
>>> Ox.formatDate(new Date("01/03/2000"), "%W")
|
||||
"01"
|
||||
*/
|
||||
var ampm = ["AM", "PM"],
|
||||
days = ["Monday", "Tuesday", "Wednesday", "Thursday",
|
||||
"Friday", "Saturday", "Sunday"],
|
||||
months = ["January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"],
|
||||
format = [
|
||||
var format = [
|
||||
["%", function() {return "%{%}";}],
|
||||
["c", function() {return "%x %X";}],
|
||||
["X", function() {return "%r";}],
|
||||
|
@ -1425,10 +1525,10 @@ Ox.formatDate = function() {
|
|||
["T", function() {return "%H:%M:%S";}],
|
||||
["v", function() {return "%e-%b-%Y";}],
|
||||
["\\+", function() {return "%a %b %e %H:%M:%S %Z %Y";}],
|
||||
["A", function(d) {return days[(d.getDay() + 6) % 7];}],
|
||||
["a", function(d) {return days[(d.getDay() + 6) % 7].toString().substr(0, 3);}],
|
||||
["B", function(d) {return months[d.getMonth()];}],
|
||||
["b", function(d) {return months[d.getMonth()].toString().substr(0, 3);}],
|
||||
["A", function(d) {return Ox.WEEKDAYS[(d.getDay() + 6) % 7];}],
|
||||
["a", function(d) {return Ox.WEEKDAYS[(d.getDay() + 6) % 7].toString().substr(0, 3);}],
|
||||
["B", function(d) {return Ox.MONTHS[d.getMonth()];}],
|
||||
["b", function(d) {return Ox.MONTHS[d.getMonth()].toString().substr(0, 3);}],
|
||||
["C", function(d) {return d.getFullYear().toString().substr(0, 2);}],
|
||||
["d", function(d) {return Ox.pad(d.getDate(), 2);}],
|
||||
["e", function(d) {return Ox.pad(d.getDate(), 2, " ");}],
|
||||
|
@ -1441,7 +1541,7 @@ Ox.formatDate = function() {
|
|||
["l", function(d) {return Ox.pad(((d.getHours() + 11) % 12 + 1), 2, " ");}],
|
||||
["M", function(d) {return Ox.pad(d.getMinutes(), 2);}],
|
||||
["m", function(d) {return Ox.pad((d.getMonth() + 1), 2);}],
|
||||
["p", function(d) {return ampm[Math.floor(d.getHours() / 12)];}],
|
||||
["p", function(d) {return Ox.AMPM[Math.floor(d.getHours() / 12)];}],
|
||||
["Q", function(d) {return Math.floor(d.getMonth() / 4) + 1;}],
|
||||
["S", function(d) {return Ox.pad(d.getSeconds(), 2);}],
|
||||
["s", function(d) {return Math.floor(d.getTime() / 1000);}],
|
||||
|
@ -1459,8 +1559,8 @@ Ox.formatDate = function() {
|
|||
["t", function() {return "\t";}],
|
||||
["\\{%\\}", function() {return "%";}]
|
||||
];
|
||||
$.each(format, function(i, v) {
|
||||
format[i][0] = new RegExp("%" + v[0] + "", "g");
|
||||
format.forEach(function(v, i) {
|
||||
v[0] = new RegExp('%' + v[0] + '', 'g');
|
||||
});
|
||||
return function(date, str) {
|
||||
str = str || date;
|
||||
|
@ -1477,7 +1577,7 @@ Ox.formatDate = function() {
|
|||
date = new Date(date);
|
||||
}
|
||||
if (Ox.isDate(date) && date.toString() != 'Invalid Date') {
|
||||
$.each(format, function(i, v) {
|
||||
Ox.forEach(format, function(v) {
|
||||
str = str.replace(v[0], v[1](date));
|
||||
});
|
||||
} else {
|
||||
|
@ -1526,7 +1626,7 @@ Ox.formatDuration = function(sec, dec, format) {
|
|||
str.medium.pop();
|
||||
str.long.pop();
|
||||
}
|
||||
return $.map(val, function(v, i) {
|
||||
return Ox.map(val, function(v, i) {
|
||||
return format == "short" ? Ox.pad(v, pad[i]) :
|
||||
v + (format == "long" ? " " : "") + str[format][i] +
|
||||
(format == "long" && v != 1 ? "s" : "");
|
||||
|
@ -1613,27 +1713,141 @@ Geo functions
|
|||
================================================================================
|
||||
*/
|
||||
|
||||
Ox.getArea = function(point0, point1) {
|
||||
|
||||
Ox.Line = function(point0, point1) {
|
||||
|
||||
var self = {
|
||||
points: [point0, point1]
|
||||
},
|
||||
that = this;
|
||||
|
||||
function rad() {
|
||||
return self.points.map(function(point) {
|
||||
return {
|
||||
lat: Ox.rad(point.lat()),
|
||||
lng: Ox.rad(point.lng())
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
that.getArea = function() {
|
||||
|
||||
};
|
||||
|
||||
that.getBearing = function() {
|
||||
var points = rad(),
|
||||
x = Math.cos(point[0].lat) * Math.sin(point[1].lat) -
|
||||
Math.sin(point[0].lat) * Math.cos(point[1].lat) *
|
||||
Math.cos(point[1].lng - point[0].lng),
|
||||
y = Math.sin(point[1].lng - point[0].lng) *
|
||||
Math.cos(point[1].lat);
|
||||
return (Ox.deg(math.atan2(y, x)) + 360) % 360;
|
||||
};
|
||||
|
||||
that.getDistance = function() {
|
||||
var points = rad();
|
||||
return Math.acos(
|
||||
Math.sin(point[0].lat) * Math.sin(point[1].lat) +
|
||||
Math.cos(point[0].lat) * Math.cos(point[1].lat) *
|
||||
Math.cos(point[1].lng - point[0].lng)
|
||||
) * Ox.EARTH_RADIUS;
|
||||
};
|
||||
|
||||
that.getMidpoint = function() {
|
||||
var points = rad(),
|
||||
x = Math.cos(point[1].lat) *
|
||||
Math.cos(point[1].lng - point[0].lng),
|
||||
y = Math.cos(point[1].lat) *
|
||||
Math.sin(point[1].lng - point[0].lng),
|
||||
d = Math.sqrt(
|
||||
Math.pow(Math.cos(point[0].lat) + x, 2) + Math.pow(y, 2)
|
||||
),
|
||||
lat = Ox.deg(
|
||||
Math.atan2(Math.sin(points[0].lat) + Math.sin(points[1].lat), d)
|
||||
),
|
||||
lng = Ox.deg(
|
||||
points[0].lng + Math.atan2(y, math.cos(points[0].lat) + x)
|
||||
);
|
||||
return new Point(lat, lng);
|
||||
};
|
||||
|
||||
that.points = function() {
|
||||
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
||||
Ox.getCenter = function(point0, point1) {
|
||||
|
||||
Ox.Point = function(lat, lng) {
|
||||
|
||||
var self = {lat: lat, lng: lng},
|
||||
that = this;
|
||||
|
||||
that.lat = function() {
|
||||
|
||||
};
|
||||
|
||||
that.latlng = function() {
|
||||
|
||||
};
|
||||
|
||||
that.lng = function() {
|
||||
|
||||
};
|
||||
|
||||
that.getMetersPerDegree = function() {
|
||||
return Math.cos(self.lat * Math.PI / 180) *
|
||||
Ox.EARTH_CIRCUMFERENCE / 360;
|
||||
}
|
||||
|
||||
that.getXY = function() {
|
||||
return [
|
||||
getXY(Ox.rad(self.lng)),
|
||||
getXY(Ox.asinh(Math.tan(Ox.rad(-self.lat))))
|
||||
];
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
||||
Ox.getDistance = function(point0, point1) {
|
||||
point0 = point0.map(function(deg) {
|
||||
return Ox.rad(deg);
|
||||
});
|
||||
point1 = point1.map(function(deg) {
|
||||
return Ox.rad(deg);
|
||||
});
|
||||
}
|
||||
Ox.Rectangle = function(point0, point1) {
|
||||
|
||||
var self = {
|
||||
points: [
|
||||
new Point(
|
||||
Math.min(point0.lat(), point1.lat()),
|
||||
point0.lng()
|
||||
),
|
||||
new Point(
|
||||
Math.max(point0.lat(), point1.lat()),
|
||||
point1.lng()
|
||||
)
|
||||
]
|
||||
},
|
||||
that = this;
|
||||
|
||||
that.contains = function(rectangle) {
|
||||
|
||||
}
|
||||
|
||||
that.crossesDateline = function() {
|
||||
return self.points[0].lng > self.points[1].lng;
|
||||
}
|
||||
|
||||
that.getCenter = function() {
|
||||
return new Ox.Line(self.points[0], self.points[1]).getMidpoint();
|
||||
};
|
||||
|
||||
that.intersects = function(rectangle) {
|
||||
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
Ox.getMetersPerDegree = function(point) {
|
||||
return Math.cos(point[0] * Math.PI / 180) * Ox.EARTH_CIRCUMFERENCE / 360;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
HTML functions
|
||||
|
@ -1718,7 +1932,9 @@ Ox.parseHTML = (function() {
|
|||
});
|
||||
html = html.replace(/\n/g, '<br/>\n')
|
||||
// close extra opening (and remove extra closing) tags
|
||||
return $('<div>').html(html).html();
|
||||
// return $('<div>').html(html).html();
|
||||
// fixme: this converts '"' to '"'
|
||||
return Ox.element('div').html(html).html();
|
||||
}
|
||||
|
||||
}());
|
||||
|
@ -2035,7 +2251,7 @@ Ox.toTitleCase = function(str) {
|
|||
>>> Ox.toTitleCase("Apple releases iPhone, IBM stock plummets")
|
||||
"Apple Releases iPhone, IBM Stock Plummets"
|
||||
*/
|
||||
return $.map(str.split(' '), function(v) {
|
||||
return Ox.map(str.split(' '), function(v) {
|
||||
var sub = v.substr(1),
|
||||
low = sub.toLowerCase();
|
||||
if (sub == low) {
|
||||
|
@ -2090,7 +2306,7 @@ Ox.truncate = function(str, len, pad, pos) {
|
|||
Ox.words = function(str) {
|
||||
/*
|
||||
>>> Ox.words('He\'s referring to the "ill-conceived" AOL/TimeWarner merger--didn\'t you know?')
|
||||
"he's,referring,to,the,ill-conceived,aol,timewarner,merger,didn't,you,know"
|
||||
['he\'s', 'referring', 'to' , 'the' , 'ill-conceived' , 'aol', 'timewarner' , 'merger' , 'didn\'t', 'you', 'know']
|
||||
*/
|
||||
var arr = str.toLowerCase().split(/\b/),
|
||||
chr = "-'",
|
||||
|
@ -2141,7 +2357,7 @@ Ox.wordwrap = function(str, len, sep, bal, spa) {
|
|||
if (lines.length > 1) {
|
||||
// test shorter line, unless
|
||||
// that means cutting a word
|
||||
var max = Ox.max($.map(words, function(word) {
|
||||
var max = Ox.max(Ox.map(words, function(word) {
|
||||
return word.length;
|
||||
}));
|
||||
while (len > max) {
|
||||
|
@ -2154,7 +2370,7 @@ Ox.wordwrap = function(str, len, sep, bal, spa) {
|
|||
}
|
||||
}
|
||||
lines = [""];
|
||||
$.each(words, function(i, word) {
|
||||
Ox.forEach(words, function(word) {
|
||||
if ((lines[lines.length - 1] + word + " ").length <= len + 1) {
|
||||
// word fits in current line
|
||||
lines[lines.length - 1] += word + " ";
|
||||
|
@ -2174,7 +2390,7 @@ Ox.wordwrap = function(str, len, sep, bal, spa) {
|
|||
}
|
||||
});
|
||||
if (!spa) {
|
||||
lines = $.map(lines, function(line) {
|
||||
lines = Ox.map(lines, function(line) {
|
||||
return Ox.trim(line);
|
||||
});
|
||||
}
|
||||
|
@ -2187,6 +2403,14 @@ Type functions
|
|||
================================================================================
|
||||
*/
|
||||
|
||||
Ox.isArguments = function(val) {
|
||||
/*
|
||||
>>> Ox.isArguments((function() { return arguments; }()))
|
||||
true
|
||||
*/
|
||||
return !!(val && val.toString() == '[object Arguments]');
|
||||
}
|
||||
|
||||
Ox.isArray = function(val) { // is in jQuery
|
||||
/*
|
||||
>>> Ox.isArray([])
|
||||
|
@ -2212,8 +2436,12 @@ Ox.isDate = function(val) {
|
|||
};
|
||||
|
||||
Ox.isElement = function(val) {
|
||||
/*
|
||||
>>> Ox.isElement(document.createElement())
|
||||
true
|
||||
*/
|
||||
return !!(val && val.nodeType == 1);
|
||||
}
|
||||
};
|
||||
|
||||
Ox.isFunction = function(val) { // is in jQuery
|
||||
/*
|
||||
|
@ -2225,6 +2453,18 @@ Ox.isFunction = function(val) { // is in jQuery
|
|||
return typeof val == 'function' && !Ox.isRegExp(val);
|
||||
};
|
||||
|
||||
Ox.isInfinity = function(val) {
|
||||
/*
|
||||
>>> Ox.isInfinity(Infinity)
|
||||
true
|
||||
>>> Ox.isInfinity(-Infinity)
|
||||
true
|
||||
>>> Ox.isInfinity(NaN)
|
||||
false
|
||||
*/
|
||||
return typeof val == 'number' && !isFinite(val) && !Ox.isNaN(val);
|
||||
};
|
||||
|
||||
Ox.isNaN = function(val) {
|
||||
/*
|
||||
>>> Ox.isNaN(NaN)
|
||||
|
@ -2247,6 +2487,8 @@ Ox.isNumber = function(val) {
|
|||
true
|
||||
>>> Ox.isNumber(Infinity)
|
||||
false
|
||||
>>> Ox.isNumber(-Infinity)
|
||||
false
|
||||
>>> Ox.isNumber(NaN)
|
||||
false
|
||||
*/
|
||||
|
@ -2264,8 +2506,8 @@ Ox.isObject = function(val) {
|
|||
>>> Ox.isObject(null)
|
||||
false
|
||||
*/
|
||||
return typeof val == 'object' && !$.isArray(val) &&
|
||||
!Ox.isDate(val) && !Ox.isNull(val);
|
||||
return typeof val == 'object' && !Ox.isArguments(val) &&
|
||||
!Ox.isArray(val) && !Ox.isDate(val) && !Ox.isNull(val);
|
||||
};
|
||||
|
||||
Ox.isRegExp = function(val) {
|
||||
|
@ -2291,3 +2533,44 @@ Ox.isUndefined = function(val) {
|
|||
*/
|
||||
return typeof val == 'undefined';
|
||||
};
|
||||
|
||||
Ox.typeOf = function(val) {
|
||||
/*
|
||||
>>> (function() { return Ox.typeOf(arguments); }())
|
||||
'arguments'
|
||||
>>> Ox.typeOf([])
|
||||
'array'
|
||||
>>> Ox.typeOf(false)
|
||||
'boolean'
|
||||
>>> Ox.typeOf(new Date())
|
||||
'date'
|
||||
>>> Ox.typeOf(document.createElement())
|
||||
'element'
|
||||
>>> Ox.typeOf(function() {})
|
||||
'function'
|
||||
>>> Ox.typeOf(Infinity)
|
||||
'infinity'
|
||||
>>> Ox.typeOf(NaN)
|
||||
'nan'
|
||||
>>> Ox.typeOf(null)
|
||||
'null'
|
||||
>>> Ox.typeOf(0)
|
||||
'number'
|
||||
>>> Ox.typeOf({})
|
||||
'object'
|
||||
>>> Ox.typeOf(/ /)
|
||||
'regexp'
|
||||
>>> Ox.typeOf('')
|
||||
'string'
|
||||
>>> Ox.typeOf()
|
||||
'undefined'
|
||||
*/
|
||||
var ret;
|
||||
Ox.forEach(Ox.TYPES, function(type) {
|
||||
if (Ox['is' + type](val)) {
|
||||
ret = type.toLowerCase();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
|
314
build/js/ox.map.js
Normal file
314
build/js/ox.map.js
Normal file
|
@ -0,0 +1,314 @@
|
|||
Ox.COUNTRIES = [
|
||||
// 302 countries ()
|
||||
// 193 sovereign countries (see http://en.wikipedia.org/wiki/List_of_sovereign_states)
|
||||
// 11 unrecognized countries (see http://en.wikipedia.org/wiki/List_of_sovereign_states#Other_states)
|
||||
// 62 dependent countries (4 Australia, 2 China, 2 Denmark, 1 Finland, 13 France, 4 Netherlands,
|
||||
// 3 New Zealand, 2 Norway, 2 Spain, 22 United Kingdom, 6 United States, plus Antarctica)
|
||||
// 34 former countries (http://en.wikipedia.org/wiki/ISO_3166-3, http://www.imdb.com/country/)
|
||||
// 2 other countries (EU, UK)
|
||||
// also see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2,
|
||||
// http://en.wikipedia.org/wiki/Borders_of_the_continents
|
||||
// and http://unstats.un.org/unsd/methods/m49/m49regin.htm
|
||||
{code: 'AF', continent: 'Asia', name: 'Afghanistan', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'AL', continent: 'Europe', name: 'Albania', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'DZ', continent: 'Africa', name: 'Algeria', region: 'Northern Africa', type: 'sovereign'},
|
||||
{code: 'AD', continent: 'Europe', name: 'Andorra', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'AO', continent: 'Africa', name: 'Angola', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'AG', continent: 'North America', name: 'Antigua and Barbuda', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'AR', continent: 'South America', name: 'Argentina', type: 'sovereign'},
|
||||
{code: 'AM', continent: 'Asia', name: 'Armenia', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'AU', continent: 'Oceania', name: 'Australia', region: 'Australia and New Zealand', type: 'sovereign'},
|
||||
{code: 'AT', continent: 'Europe', name: 'Austria', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'AZ', continent: 'Asia', name: 'Azerbaijan', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'BS', continent: 'North America', name: 'Bahamas', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'BH', continent: 'Asia', name: 'Bahrain', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'BD', continent: 'Asia', name: 'Bangladesh', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'BB', continent: 'North America', name: 'Barbados', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'BY', continent: 'Europe', name: 'Belarus', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'BE', continent: 'Europe', name: 'Belgium', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'BZ', continent: 'North America', name: 'Belize', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'BJ', continent: 'Africa', name: 'Benin', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'BT', continent: 'Asia', name: 'Bhutan', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'BO', continent: 'South America', name: 'Bolivia', type: 'sovereign'},
|
||||
{code: 'BA', continent: 'Europe', name: 'Bosnia and Herzegovina', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'BW', continent: 'Africa', name: 'Botswana', region: 'Southern Africa', type: 'sovereign'},
|
||||
{code: 'BR', continent: 'South America', name: 'Brazil', type: 'sovereign'},
|
||||
{code: 'BN', continent: 'Asia', name: 'Brunei', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'BG', continent: 'Europe', name: 'Bulgaria', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'BF', continent: 'Africa', name: 'Burkina Faso', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'BI', continent: 'Africa', name: 'Burundi', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'KH', continent: 'Asia', name: 'Cambodia', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'CM', continent: 'Africa', name: 'Cameroon', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'CA', continent: 'North America', name: 'Canada', region: 'Northern America', type: 'sovereign'},
|
||||
{code: 'CV', continent: 'Africa', name: 'Cape Verde', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'CF', continent: 'Africa', name: 'Central African Republic', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'TD', continent: 'Africa', name: 'Chad', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'CL', continent: 'South America', name: 'Chile', type: 'sovereign'},
|
||||
{code: 'CN', continent: 'Asia', name: 'China', region: 'Eastern Asia', type: 'sovereign'},
|
||||
{code: 'CO', continent: 'South America', name: 'Colombia', type: 'sovereign'},
|
||||
{code: 'KM', continent: 'Africa', name: 'Comoros', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'CR', continent: 'North America', name: 'Costa Rica', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'CI', continent: 'Africa', name: 'Côte d\'Ivoire', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'HR', continent: 'Europe', name: 'Croatia', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'CU', continent: 'North America', name: 'Cuba', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'CY', continent: 'Asia', name: 'Cyprus', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'CZ', continent: 'Europe', name: 'Czech Republic', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'CD', continent: 'Africa', name: 'Democratic Republic of the Congo', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'DK', continent: 'Europe', name: 'Denmark', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'DJ', continent: 'Africa', name: 'Djibouti', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'DM', continent: 'North America', name: 'Dominica', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'DO', continent: 'North America', name: 'Dominican Republic', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'EC', continent: 'South America', name: 'Ecuador', type: 'sovereign'},
|
||||
{code: 'EG', continent: 'Africa', name: 'Egypt', region: 'Northern Africa', type: 'sovereign'},
|
||||
{code: 'SV', continent: 'North America', name: 'El Salvador', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'GQ', continent: 'Africa', name: 'Equatorial Guinea', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'ER', continent: 'Africa', name: 'Eritrea', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'EE', continent: 'Europe', name: 'Estonia', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'ET', continent: 'Africa', name: 'Ethiopia', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'FJ', continent: 'Oceania', name: 'Fiji', region: 'Melanesia', type: 'sovereign'},
|
||||
{code: 'FI', continent: 'Europe', name: 'Finland', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'FR', continent: 'Europe', name: 'France', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'GA', continent: 'Africa', name: 'Gabon', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'GM', continent: 'Africa', name: 'Gambia', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'GE', continent: 'Asia', name: 'Georgia', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'DE', continent: 'Europe', name: 'Germany', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'GH', continent: 'Africa', name: 'Ghana', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'GR', continent: 'Europe', name: 'Greece', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'GD', continent: 'North America', name: 'Grenada', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'GT', continent: 'North America', name: 'Guatemala', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'GN', continent: 'Africa', name: 'Guinea', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'GW', continent: 'Africa', name: 'Guinea-Bissau', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'GY', continent: 'South America', name: 'Guyana', type: 'sovereign'},
|
||||
{code: 'HT', continent: 'North America', name: 'Haiti', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'VA', continent: 'Europe', name: 'Holy See', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'HN', continent: 'North America', name: 'Honduras', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'HU', continent: 'Europe', name: 'Hungary', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'IS', continent: 'Europe', name: 'Iceland', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'IN', continent: 'Asia', name: 'India', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'ID', continent: 'Asia', name: 'Indonesia', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'IR', continent: 'Asia', name: 'Iran', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'IQ', continent: 'Asia', name: 'Iraq', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'IE', continent: 'Europe', name: 'Ireland', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'IL', continent: 'Asia', name: 'Israel', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'IT', continent: 'Europe', name: 'Italy', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'JM', continent: 'North America', name: 'Jamaica', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'JP', continent: 'Asia', name: 'Japan', region: 'Eastern Asia', type: 'sovereign'},
|
||||
{code: 'JO', continent: 'Asia', name: 'Jordan', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'KZ', continent: 'Asia', name: 'Kazakhstan', region: 'Central Asia', type: 'sovereign'},
|
||||
{code: 'KE', continent: 'Africa', name: 'Kenya', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'KI', continent: 'Oceania', name: 'Kiribati', region: 'Micronesia', type: 'sovereign'},
|
||||
{code: 'KW', continent: 'Asia', name: 'Kuwait', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'KG', continent: 'Asia', name: 'Kyrgyzstan', region: 'Central Asia', type: 'sovereign'},
|
||||
{code: 'LA', continent: 'Asia', name: 'Laos', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'LV', continent: 'Europe', name: 'Latvia', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'LB', continent: 'Asia', name: 'Lebanon', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'LS', continent: 'Africa', name: 'Lesotho', region: 'Southern Africa', type: 'sovereign'},
|
||||
{code: 'LR', continent: 'Africa', name: 'Liberia', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'LY', continent: 'Africa', name: 'Libya', region: 'Northern Africa', type: 'sovereign'},
|
||||
{code: 'LI', continent: 'Europe', name: 'Liechtenstein', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'LT', continent: 'Europe', name: 'Lithuania', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'LU', continent: 'Europe', name: 'Luxembourg', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'MK', continent: 'Europe', name: 'Macedonia', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'MG', continent: 'Africa', name: 'Madagascar', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'MW', continent: 'Africa', name: 'Malawi', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'MY', continent: 'Asia', name: 'Malaysia', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'MV', continent: 'Asia', name: 'Maldives', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'ML', continent: 'Africa', name: 'Mali', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'MT', continent: 'Europe', name: 'Malta', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'MH', continent: 'Oceania', name: 'Marshall Islands', region: 'Micronesia', type: 'sovereign'},
|
||||
{code: 'MR', continent: 'Africa', name: 'Mauritania', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'MU', continent: 'Africa', name: 'Mauritius', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'MX', continent: 'North America', name: 'Mexico', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'FM', continent: 'Oceania', name: 'Micronesia', region: 'Micronesia', type: 'sovereign'},
|
||||
{code: 'MD', continent: 'Europe', name: 'Moldova', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'MC', continent: 'Europe', name: 'Monaco', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'MN', continent: 'Asia', name: 'Mongolia', region: 'Eastern Asia', type: 'sovereign'},
|
||||
{code: 'ME', continent: 'Europe', name: 'Montenegro', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'MA', continent: 'Africa', name: 'Morocco', region: 'Northern Africa', type: 'sovereign'},
|
||||
{code: 'MZ', continent: 'Africa', name: 'Mozambique', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'MM', continent: 'Asia', name: 'Myanmar', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'NA', continent: 'Africa', name: 'Namibia', region: 'Southern Africa', type: 'sovereign'},
|
||||
{code: 'NR', continent: 'Oceania', name: 'Nauru', region: 'Micronesia', type: 'sovereign'},
|
||||
{code: 'NP', continent: 'Asia', name: 'Nepal', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'NL', continent: 'Europe', name: 'Netherlands', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'NZ', continent: 'Oceania', name: 'New Zealand', region: 'Australia and New Zealand', type: 'sovereign'},
|
||||
{code: 'NI', continent: 'North America', name: 'Nicaragua', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'NE', continent: 'Africa', name: 'Niger', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'NG', continent: 'Africa', name: 'Nigeria', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'KP', continent: 'Asia', name: 'North Korea', region: 'Eastern Asia', type: 'sovereign'},
|
||||
{code: 'NO', continent: 'Europe', name: 'Norway', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'OM', continent: 'Asia', name: 'Oman', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'PK', continent: 'Asia', name: 'Pakistan', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'PW', continent: 'Oceania', name: 'Palau', region: 'Micronesia', type: 'sovereign'},
|
||||
{code: 'PA', continent: 'North America', name: 'Panama', region: 'Central America', type: 'sovereign'},
|
||||
{code: 'PG', continent: 'Oceania', name: 'Papua New Guinea', region: 'Melanesia', type: 'sovereign'},
|
||||
{code: 'PY', continent: 'South America', name: 'Paraguay', type: 'sovereign'},
|
||||
{code: 'PE', continent: 'South America', name: 'Peru', type: 'sovereign'},
|
||||
{code: 'PH', continent: 'Asia', name: 'Philippines', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'PL', continent: 'Europe', name: 'Poland', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'PT', continent: 'Europe', name: 'Portugal', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'QA', continent: 'Asia', name: 'Qatar', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'CD', continent: 'Africa', name: 'Republic of the Congo', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'RO', continent: 'Europe', name: 'Romania', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'RU', continent: 'Europe', name: 'Russia', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'RW', continent: 'Africa', name: 'Rwanda', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'KN', continent: 'North America', name: 'Saint Kitts and Nevis', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'LC', continent: 'North America', name: 'Saint Lucia', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'VC', continent: 'North America', name: 'Saint Vincent and the Grenadines', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'WS', continent: 'Oceania', name: 'Samoa', region: 'Polynesia', type: 'sovereign'},
|
||||
{code: 'SM', continent: 'Europe', name: 'San Marino', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'ST', continent: 'Africa', name: 'São Tomé and Príncipe', region: 'Middle Africa', type: 'sovereign'},
|
||||
{code: 'SA', continent: 'Asia', name: 'Saudi Arabia', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'SN', continent: 'Africa', name: 'Senegal', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'RS', continent: 'Europe', name: 'Serbia', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'SC', continent: 'Africa', name: 'Seychelles', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'SL', continent: 'Africa', name: 'Sierra Leone', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'SG', continent: 'Asia', name: 'Singapore', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'SK', continent: 'Europe', name: 'Slovakia', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'SI', continent: 'Europe', name: 'Slovenia', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'SB', continent: 'Oceania', name: 'Solomon Islands', region: 'Melanesia', type: 'sovereign'},
|
||||
{code: 'SO', continent: 'Africa', name: 'Somalia', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'ZA', continent: 'Africa', name: 'South Africa', region: 'Southern Africa', type: 'sovereign'},
|
||||
{code: 'KR', continent: 'Asia', name: 'South Korea', region: 'Eastern Asia', type: 'sovereign'},
|
||||
{code: 'ES', continent: 'Europe', name: 'Spain', region: 'Southern Europe', type: 'sovereign'},
|
||||
{code: 'LK', continent: 'Asia', name: 'Sri Lanka', region: 'Southern Asia', type: 'sovereign'},
|
||||
{code: 'SD', continent: 'Africa', name: 'Sudan', region: 'Northern Africa', type: 'sovereign'},
|
||||
{code: 'SR', continent: 'South America', name: 'Suriname', type: 'sovereign'},
|
||||
{code: 'SZ', continent: 'Africa', name: 'Swaziland', region: 'Southern Africa', type: 'sovereign'},
|
||||
{code: 'SE', continent: 'Europe', name: 'Sweden', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'CH', continent: 'Europe', name: 'Switzerland', region: 'Western Europe', type: 'sovereign'},
|
||||
{code: 'SY', continent: 'Asia', name: 'Syria', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'TJ', continent: 'Asia', name: 'Tajikistan', region: 'Central Asia', type: 'sovereign'},
|
||||
{code: 'TZ', continent: 'Africa', name: 'Tanzania', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'TH', continent: 'Asia', name: 'Thailand', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'TL', continent: 'Asia', name: 'Timor-Leste', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'TG', continent: 'Africa', name: 'Togo', region: 'Western Africa', type: 'sovereign'},
|
||||
{code: 'TO', continent: 'Oceania', name: 'Tonga', region: 'Polynesia', type: 'sovereign'},
|
||||
{code: 'TT', continent: 'North America', name: 'Trinidad and Tobago', region: 'Carribean', type: 'sovereign'},
|
||||
{code: 'TN', continent: 'Africa', name: 'Tunisia', type: 'sovereign'},
|
||||
{code: 'TR', continent: 'Asia', name: 'Turkey', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'TM', continent: 'Asia', name: 'Turkmenistan', region: 'Central Asia', type: 'sovereign'},
|
||||
{code: 'TV', continent: 'Oceania', name: 'Tuvalu', region: 'Polynesia', type: 'sovereign'},
|
||||
{code: 'UG', continent: 'Africa', name: 'Uganda', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'UA', continent: 'Europe', name: 'Ukraine', region: 'Eastern Europe', type: 'sovereign'},
|
||||
{code: 'AE', continent: 'Asia', name: 'United Arab Emirates', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'GB', continent: 'Europe', name: 'United Kingdom', region: 'Northern Europe', type: 'sovereign'},
|
||||
{code: 'US', continent: 'North America', name: 'United States', region: 'Northern America', type: 'sovereign'},
|
||||
{code: 'UY', continent: 'South America', name: 'Uruguay', type: 'sovereign'},
|
||||
{code: 'UZ', continent: 'Asia', name: 'Uzbekistan', region: 'Central Asia', type: 'sovereign'},
|
||||
{code: 'VU', continent: 'Oceania', name: 'Vanuatu', region: 'Melanesia', type: 'sovereign'},
|
||||
{code: 'VE', continent: 'South America', name: 'Venezuela', type: 'sovereign'},
|
||||
{code: 'VN', continent: 'Asia', name: 'Vietnam', region: 'South-Eastern Asia', type: 'sovereign'},
|
||||
{code: 'YE', continent: 'Asia', name: 'Yemen', region: 'Western Asia', type: 'sovereign'},
|
||||
{code: 'ZM', continent: 'Africa', name: 'Zambia', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'ZW', continent: 'Africa', name: 'Zimbabwe', region: 'Eastern Africa', type: 'sovereign'},
|
||||
{code: 'GE-AB', continent: 'Asia', name: 'Abkhazia', region: 'Western Asia', type: 'unrecognized'},
|
||||
{code: 'RS-KO', continent: 'Europe', name: 'Kosovo', region: 'Southern Europe', type: 'unrecognized'},
|
||||
{code: 'AZ-NK', continent: 'Asia', name: 'Nagorno-Karabakh', region: 'Western Asia', type: 'unrecognized'},
|
||||
{code: 'CY-NC', continent: 'Asia', name: 'Northern Cyprus', region: 'Western Asia', type: 'unrecognized'},
|
||||
{code: 'PS', continent: 'Asia', name: 'Palestine', region: 'Western Asia', region: 'Western Asia', type: 'unrecognized'},
|
||||
{code: 'EH', continent: 'Aftica', name: 'Sahrawi', region: 'Northern Africa', type: 'unrecognized'},
|
||||
{code: 'SO-SO', continent: 'Africa', name: 'Somaliland', region: 'Eastern Aftica', type: 'unrecognized'},
|
||||
{code: 'GE-SO', continent: 'Asia', name: 'South Ossetia', region: 'Western Asia', type: 'unrecognized'},
|
||||
{code: 'SD-SS', continent: 'Aftica', name: 'South Sudan', region: 'Northern Africa', type: 'unrecognized'},
|
||||
{code: 'TW', continent: 'Asia', name: 'Taiwan', region: 'Eastern Asia', type: 'unrecognized'},
|
||||
{code: 'MD-TR', continent: 'Europe', name: 'Transnistria', region: 'Eastern Europe', type: 'unrecognized'},
|
||||
{code: 'AQ', continent: 'Antarctica', country: ['Argentina', 'Australia', 'Chile', 'France', 'New Zealand', 'Norway', 'United Kingdom'], name: 'Antarctica'},
|
||||
{code: 'CX', continent: 'Asia', country: 'Australia', name: 'Christmas Island', region: 'South-Eastern Asia', type: 'dependent'},
|
||||
{code: 'CC', continent: 'Asia', country: 'Australia', name: 'Cocos Island', region: 'South-Eastern Asia', type: 'dependent'},
|
||||
{code: 'HM', continent: 'Antarctica', country: 'Australia', name: 'Heard Island and McDonald Islands', type: 'dependent'},
|
||||
{code: 'NF', continent: 'Oceania', country: 'Australia', name: 'Norfolk Island', region: 'Australia and New Zealand', type: 'dependent'},
|
||||
{code: 'HK', continent: 'Asia', country: 'China', name: 'Hong Kong', region: 'Eastern Asia', type: 'dependent'},
|
||||
{code: 'MO', continent: 'Asia', country: 'China', name: 'Macau', region: 'Eastern Asia', type: 'dependent'},
|
||||
{code: 'FO', continent: 'Europe', country: 'Denmark', name: 'Faroe Islands', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'GL', continent: 'North America', country: 'Denmark', name: 'Greenland', region: 'Northern America', type: 'dependent'},
|
||||
{code: 'AX', continent: 'Europe', country: 'Finland', name: 'Åland', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'CP', country: 'France', name: 'Clipperton Island', type: 'dependent'},
|
||||
{code: 'GF', continent: 'South America', country: 'France', name: 'French Guiana', type: 'dependent'},
|
||||
{code: 'PF', continent: 'Oceania', country: 'France', name: 'French Polynesia', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'TF', country: 'France', name: 'French Southern Territories', type: 'dependent'},
|
||||
{code: 'GP', continent: 'North America', country: 'France', name: 'Guadeloupe', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'MQ', continent: 'North America', country: 'France', name: 'Martinique', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'YT', continent: 'Africa', country: 'France', name: 'Mayotte', region: 'Eastern Africa', type: 'dependent'},
|
||||
{code: 'NC', continent: 'Oceania', country: 'France', name: 'New Caledonia', region: 'Melanesia', type: 'dependent'},
|
||||
{code: 'RE', continent: 'Africa', country: 'France', name: 'Réunion', region: 'Eastern Africa', type: 'dependent'},
|
||||
{code: 'BL', continent: 'North America', country: 'France', name: 'Saint Barthélemy', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'MF', continent: 'North America', country: 'France', name: 'Saint Martin', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'PM', continent: 'North America', country: 'France', name: 'Saint Pierre and Miquelon', region: 'Northern America', type: 'dependent'},
|
||||
{code: 'WF', continent: 'Oceania', country: 'France', name: 'Wallis and Futuna', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'AW', continent: 'North America', country: 'Netherlands', name: 'Aruba', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'BQ', continent: 'North America', country: 'Netherlands', name: 'Bonaire, Saint Eustatius and Saba', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'CW', continent: 'North America', country: 'Netherlands', name: 'Curaçao', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'SX', continent: 'North America', country: 'Netherlands', name: 'Sint Maarten', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'CK', continent: 'Oceania', country: 'New Zealand', name: 'Cook Islands', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'NU', continent: 'Oceania', country: 'New Zealand', name: 'Niue', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'TK', continent: 'Oceania', country: 'New Zealand', name: 'Tokelau', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'BV', continent: 'Antarctica', country: 'Norway', name: 'Bouvet Island', type: 'dependent'},
|
||||
{code: 'SJ', continent: 'Europe', country: 'Norway', name: 'Svalbard and Jan Mayen', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'IC', continent: 'Africa', country: 'Spain', name: 'Canary Islands', region: 'Northern Africa', type: 'dependent'},
|
||||
{code: 'EA', continent: 'Africa', country: 'Spain', name: 'Ceuta and Melilla', region: 'Northern Africa', type: 'dependent'},
|
||||
{code: 'AI', continent: 'North America', country: 'United Kingdom', name: 'Anguilla', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'AC', continent: 'Africa', country: 'United Kingdom', name: 'Ascension Island', region: 'Western Africa', type: 'dependent'},
|
||||
{code: 'BM', continent: 'North America', country: 'United Kingdom', name: 'Bermuda', region: 'Northern America', type: 'dependent'},
|
||||
{code: 'IO', country: 'United Kingdom', name: 'British Indian Ocean Territory', type: 'dependent'},
|
||||
{code: 'VG', continent: 'North America', country: 'United Kingdom', name: 'British Virgin Islands', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'KY', continent: 'North America', country: 'United Kingdom', name: 'Cayman Islands', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'DG', country: 'United Kingdom', name: 'Diego Garcia', type: 'dependent'},
|
||||
{code: 'GB-ENG', continent: 'Europe', country: 'United Kingdom', name: 'England', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'FK', continent: 'South America', country: 'United Kingdom', name: 'Falkland Islands', type: 'dependent'},
|
||||
{code: 'GI', continent: 'Europe', country: 'United Kingdom', name: 'Gibraltar', region: 'Southern Europe', type: 'dependent'},
|
||||
{code: 'GG', continent: 'Europe', country: 'United Kingdom', name: 'Guernsey', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'IM', continent: 'Europe', country: 'United Kingdom', name: 'Isle of Man', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'JE', continent: 'Europe', country: 'United Kingdom', name: 'Jersey', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'MS', continent: 'North America', country: 'United Kingdom', name: 'Montserrat', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'GB-NIR', continent: 'Europe', country: 'United Kingdom', name: 'Northern Ireland', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'PN', continent: 'Oceania', country: 'United Kingdom', name: 'Pitcairn', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'SH', continent: 'Africa', country: 'United Kingdom', name: 'Saint Helena', region: 'Western Africa', type: 'dependent'},
|
||||
{code: 'GB-SCT', continent: 'Europe', country: 'United Kingdom', name: 'Scotland', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'GS', continent: 'South America', country: 'United Kingdom', name: 'South Georgia and the South Sandwich Islands', type: 'dependent'},
|
||||
{code: 'TA', continent: 'Africa', country: 'United Kingdom', name: 'Tristan da Cunha', region: 'Western Africa', type: 'dependent'},
|
||||
{code: 'TC', continent: 'Oceania', country: 'United Kingdom', name: 'Turks and Caicos Islands', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'GB-WLS', continent: 'Europe', country: 'United Kingdom', name: 'Wales', region: 'Northern Europe', type: 'dependent'},
|
||||
{code: 'AS', continent: 'Oceania', country: 'United States', name: 'American Samoa', region: 'Polynesia', type: 'dependent'},
|
||||
{code: 'GU', continent: 'Oceania', country: 'United States', name: 'Guam', region: 'Micronesia', type: 'dependent'},
|
||||
{code: 'MP', continent: 'Oceania', country: 'United States', name: 'Northern Mariana Islands', region: 'Micronesia', type: 'dependent'},
|
||||
{code: 'PR', continent: 'North America', country: 'United States', name: 'Puerto Rico', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'UM', country: 'United States', name: 'United States Minor Outlying Islands', type: 'dependent'},
|
||||
{code: 'VI', continent: 'North America', country: 'United States', name: 'United States Virgin Islands', region: 'Carribean', type: 'dependent'},
|
||||
{code: 'BUMM', continent: 'Asia', name: 'Burma', region: 'South-Eastern Asia', type: 'former'},
|
||||
{code: 'BYAA', continent: 'Europe', name: 'Byelorussian Soviet Socialist Republic', region: 'Eastern Europe', type: 'former'},
|
||||
{code: 'CTKI', continent: 'Oceania', name: 'Canton and Enderbury Islands', region: 'Micronesia', type: 'former'},
|
||||
{code: 'CSHH', continent: 'Europe', name: 'Czechoslovakia', region: 'Eastern Europe', type: 'former'},
|
||||
{code: 'DYBJ', continent: 'Africa', name: 'Dahomey', region: 'Western Africa', type: 'former'},
|
||||
{code: 'TPTL', continent: 'Asia', name: 'East Timor', region: 'South-Eastern Asia', type: 'former'},
|
||||
{code: 'DDDE', continent: 'Europe', name: 'East Germany', region: 'Western Europe', type: 'former'},
|
||||
{code: 'GEHH', name: 'Gilbert and Ellice Islands', type: 'former'},
|
||||
{code: 'KOHH', continent: 'Asia', name: 'Korea', region: 'Eastern Asia', type: 'former'},
|
||||
{code: 'NTHH', continent: 'Asia', name: 'Neutral Zone', region: 'Western Asia', type: 'former'},
|
||||
{code: 'VDVN', continent: 'Asia', name: 'North Vietnam', region: 'South-Eastern Asia', type: 'former'},
|
||||
{code: 'RHZW', continent: 'Africa', name: 'Rhodesia', region: 'Eastern Africa', type: 'former'},
|
||||
{code: 'CSXX', continent: 'Europe', name: 'Serbia and Montenegro', type: 'former'},
|
||||
{code: 'SITH', continent: 'Asia', name: 'Siam', region: 'South-Eastern Asia', type: 'former'},
|
||||
{code: 'SKIN', continent: 'Asia', name: 'Sikkim', region: 'Southern Asia', type: 'former'},
|
||||
{code: 'YDYE', continent: 'Asia', name: 'South Yemen', region: 'Western Asia', type: 'former'},
|
||||
{code: 'SUHH', continent: 'Europe', name: 'Soviet Union', region: 'Eastern Europe', type: 'former'},
|
||||
{code: 'HVBF', continent: 'Africa', name: 'Upper Volta', region: 'Western Africa', type: 'former'},
|
||||
{code: 'DE', continent: 'Europe', name: 'West Germany', region: 'Western Europe', type: 'former'},
|
||||
{code: 'YUCS', continent: 'Europe', name: 'Yugoslavia', type: 'former'},
|
||||
{code: 'ZRCD', continent: 'Africa', name: 'Zaire', region: 'Middle Africa', type: 'former'},
|
||||
{code: 'AIDJ', country: 'France',name: 'French Afar and Issas', type: 'former'},
|
||||
{code: 'FQHH', continent: 'Antarctica', country: 'France', name: 'French Southern and Antarctic Territories', type: 'former'},
|
||||
{code: 'FXFR', continent: 'Europe', country: 'France', name: 'Metropolitan France', type: 'former'},
|
||||
{code: 'NHVU', country: ['France', 'United Kingdom'], name: 'New Hebrides', region: 'Melanesia', type: 'former'},
|
||||
{code: 'ANHH', continent: 'North America', country: 'Netherlands', name: 'Netherlands Antilles', region: 'Carribean', type: 'former'},
|
||||
{code: 'NQAQ', continent: 'Antarctica', country: 'Norway', name: 'Dronning Maud Land', type: 'former'},
|
||||
{code: 'BQAQ', continent: 'Antarctica', country: 'United Kingdom', name: 'British Antarctic Territory', type: 'former'},
|
||||
{code: 'JTUM', continent: 'Oceania', country: 'United States', name: 'Johnston Island', region: 'Mictonesia', type: 'former'},
|
||||
{code: 'MIUM', continent: 'Oceania', country: 'United States', name: 'Midway Islands', type: 'former'},
|
||||
{code: 'PCHH', continent: 'Oceania', country: 'United States', name: 'Pacific Islands', region: 'Micronesia', type: 'former'},
|
||||
{code: 'PZPA', continent: 'North America', country: 'United States', name: 'Panama Canal Zone', region: 'Central America', type: 'former'},
|
||||
{code: 'PUUM', continent: 'Oceania', country: 'United States', name: 'United States Miscellaneous Pacific Islands', type: 'former'},
|
||||
{code: 'WKUM', continent: 'Oceania', country: 'United States', name: 'Wake Island', region: 'Micronesia', type: 'former'}
|
||||
{code: 'EU', continent: 'Europe', name: 'European Union', type: 'other'},
|
||||
{code: 'UK', continent: 'Europe', name: 'United Kingdom', region: 'Northern Europe', type: 'other'}
|
||||
];
|
|
@ -35,7 +35,7 @@ requires
|
|||
};
|
||||
return sizes[size];
|
||||
},
|
||||
path: $('script[src*=ox.ui.js]').attr('src').replace('js/ox.ui.js', ''),
|
||||
path: $('script[src*="ox.ui.js"]').attr('src').replace('js/ox.ui.js', ''),
|
||||
scrollbarSize: $.browser.mozilla ? 16 : 12,
|
||||
symbols: {
|
||||
alt: '\u2325',
|
||||
|
@ -8892,7 +8892,7 @@ requires
|
|||
geocoder: new google.maps.Geocoder(),
|
||||
selected: -1
|
||||
});
|
||||
if (Ox.isObject(self.options.places[0])) {
|
||||
if (self.options.places.length == 0 || Ox.isObject(self.options.places[0])) {
|
||||
$.each(self.options.places, function(i, place) {
|
||||
place.bounds = getBounds(),
|
||||
place.center = place.bounds.getCenter();
|
||||
|
@ -9296,7 +9296,6 @@ requires
|
|||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
options
|
||||
height image height (px)
|
||||
|
@ -10865,7 +10864,7 @@ requires
|
|||
function selectAnnotation(event, data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.ids[0]);
|
||||
that.triggerEvent('select', {
|
||||
'in': item.in,
|
||||
'in': item['in'],
|
||||
'out': item.out,
|
||||
'layer': self.options.id
|
||||
});
|
||||
|
@ -11083,7 +11082,7 @@ requires
|
|||
data = imageData.data;
|
||||
$.each(self.options.subtitles, function(i, v) {
|
||||
//var color = self.options.matches.indexOf(i) > -1 ? [255, 255, 0] : [255, 255, 255]
|
||||
var inPoint = Math.round(v.in),
|
||||
var inPoint = Math.round(v['in']),
|
||||
outPoint = Math.round(v.out) + 1,
|
||||
lines = v.value.split('\n').length,
|
||||
bottom = 15,
|
||||
|
@ -11969,7 +11968,7 @@ requires
|
|||
.bindEvent({
|
||||
add: function(event, data) {
|
||||
data.layer = layer.id;
|
||||
data.in = self.options.points[0];
|
||||
data['in'] = self.options.points[0];
|
||||
data.out = self.options.points[1];
|
||||
that.triggerEvent('addAnnotation', data);
|
||||
},
|
||||
|
@ -12071,7 +12070,7 @@ requires
|
|||
// ...
|
||||
} else if (type == 'subtitle') {
|
||||
self.options.subtitles.forEach(function(v, i) {
|
||||
positions.push(v.in);
|
||||
positions.push(v['in']);
|
||||
positions.push(v.out);
|
||||
});
|
||||
}
|
||||
|
@ -12216,13 +12215,13 @@ requires
|
|||
}
|
||||
|
||||
function selectAnnotation(event, data) {
|
||||
self.options.position = data.in
|
||||
self.options.points = [data.in, data.out];
|
||||
self.options.position = data['in']
|
||||
self.options.points = [data['in'], data.out];
|
||||
setPosition();
|
||||
setPoints();
|
||||
}
|
||||
function updateAnnotation(event, data) {
|
||||
data.in = self.options.points[0];
|
||||
data['in'] = self.options.points[0];
|
||||
data.out = self.options.points[1];
|
||||
that.triggerEvent('updateAnnotation', data);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="stylesheet" type="text/css" href="../build/css/ox.ui.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="tests.css"/>
|
||||
<script type="text/javascript" src="../build/js/jquery-1.4.js"></script>
|
||||
<script type="text/javascript" src="../build/js/jquery-1.5.js"></script>
|
||||
<script type="text/javascript" src="../build/js/ox.js"></script>
|
||||
<script type="text/javascript" src="../build/js/ox.data.js"></script>
|
||||
<script type="text/javascript" src="../build/js/ox.ui.js"></script>
|
||||
|
|
|
@ -25,14 +25,16 @@ $(function() {
|
|||
|
||||
setBackground($tests, true);
|
||||
|
||||
tests('../build/js/ox.js', '../build/js/ox.data.js');
|
||||
tests(['../build/js/ox.js', '../build/js/ox.data.js']);
|
||||
|
||||
function tests() {
|
||||
var succeeded = 0, failed = 0,
|
||||
lines, spaces, command, expected, result, success,
|
||||
replace = ['', ''], fns = [], $test
|
||||
$.each($.isArray(arguments[0]) ? arguments[0] : arguments, function(i, script) {
|
||||
Ox.forEach(Ox.isArray(arguments[0]) ? arguments[0] : arguments, function(script, i) {
|
||||
Ox.print(script, Ox)
|
||||
$.get(script, function(data) {
|
||||
Ox.print(script, Ox)
|
||||
new Ox.Bar({size: 17})
|
||||
.css({padding: '3px 0 0 8px'})
|
||||
.html(Ox.basename(script))
|
||||
|
@ -49,15 +51,21 @@ $(function() {
|
|||
spaces = line.indexOf('>>> ');
|
||||
if (spaces > -1) {
|
||||
command = $.trim(line).substr(4).split(' // ')[0];
|
||||
Ox.print('command:', command)
|
||||
fn = command.match(/Ox\.\w+/);
|
||||
fn = command.match(/Ox\.\w+/g);
|
||||
Ox.print('fn', fn)
|
||||
//Ox.print(lines[l + 1].substr(spaces, lines[l + 1].length), eval(lines[l + 1].substr(spaces, lines[l + 1].length)))
|
||||
Ox.print(lines[l + 1].substr(spaces, lines[l + 1].length));
|
||||
expected = eval(lines[l + 1].substr(spaces, lines[l + 1].length));
|
||||
// fixme: if object, recursively check identity
|
||||
result = eval(command);
|
||||
if (fn) {
|
||||
fn = fn[0];
|
||||
fn = fn[fn.length - 1];
|
||||
/*
|
||||
success = typeof expected == 'object' ?
|
||||
expected.toString() == result.toString() : expected === result;
|
||||
*/
|
||||
Ox.print('command:', command, 'expected:', expected, 'result:', result)
|
||||
success = Ox.isEqual(expected, result);
|
||||
succeeded += success;
|
||||
failed += !success;
|
||||
$tests.html((succeeded + failed) + ' tests, ' +
|
||||
|
@ -83,8 +91,8 @@ $(function() {
|
|||
.html(
|
||||
Ox.basename(script) + ', line ' + l + ': <span style="font-weight: bold">' +
|
||||
Ox.encodeHTML(command).replace(replace[0], replace[1]) + ' ' +
|
||||
(success ? '=' : '!') + '=> ' + Ox.encodeHTML(expected.toString()) +
|
||||
(success ? '' : ' ==> ' + Ox.encodeHTML(result.toString())) + '</span>'
|
||||
(success ? '=' : '!') + '=> ' + Ox.encodeHTML(JSON.stringify(expected)) +
|
||||
(success ? '' : ' ==> ' + Ox.encodeHTML(JSON.stringify(result))) + '</span>'
|
||||
)
|
||||
.appendTo($test.$content);
|
||||
//*/
|
||||
|
@ -105,7 +113,7 @@ $(function() {
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 'html');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue