oxjs/source/Ox/js/Constants.js

149 lines
6.6 KiB
JavaScript
Raw Normal View History

2011-11-05 16:46:53 +00:00
'use strict';
2012-06-04 09:49:27 +00:00
//@ Ox.AMPM <[s]> ['AM', 'PM']
Ox.AMPM = ['AM', 'PM'];
//@ Ox.BASE_32_ALIASES <o> Base 32 aliases
Ox.BASE_32_ALIASES = {'I': '1', 'L': '1', 'O': '0', 'U': 'V'},
//@ Ox.BASE_32_DIGITS <o> Base 32 digits
Ox.BASE_32_DIGITS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
2012-06-04 09:49:27 +00:00
//@ Ox.BCAD <[s]> ['BC', 'AD']
Ox.BCAD = ['BC', 'AD'];
2012-06-04 09:49:27 +00:00
/*@
Ox.EARTH_RADIUS <n> Radius of the earth in meters
See http://en.wikipedia.org/wiki/WGS-84
*/
Ox.EARTH_RADIUS = 6378137;
2012-06-04 09:49:27 +00:00
//@ Ox.EARTH_CIRCUMFERENCE <n> Circumference of the earth in meters
2012-09-01 03:51:35 +00:00
Ox.EARTH_CIRCUMFERENCE = 2 * Math.PI * Ox.EARTH_RADIUS;
//@ Ox.EARTH_SURFACE <n> Surface of the earth in square meters
Ox.EARTH_SURFACE = 4 * Math.PI * Math.pow(Ox.EARTH_RADIUS, 2);
//@ Ox.HTML_ENTITIES <o> HTML entities for ... (FIXME)
Ox.HTML_ENTITIES = {
'"': '&quot;', '&': '&amp;', "'": '&apos;', '<': '&lt;', '>': '&gt;'
};
//@ Ox.KEYS <o> Names for key codes
// The dot notation ('0.numpad') allows for namespaced events ('key_0.numpad'),
// so that binding to 'key_0' will catch both 'key_0' and 'key_0.numpad'.
Ox.KEYS = {
0: 'section', 8: 'backspace', 9: 'tab', 12: 'clear', 13: 'enter',
16: 'shift', 17: 'control', 18: 'alt', 20: 'capslock', 27: 'escape',
32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home',
37: 'left', 38: 'up', 39: 'right', 40: 'down',
45: 'insert', 46: 'delete', 47: 'help',
48: '0', 49: '1', 50: '2', 51: '3', 52: '4',
53: '5', 54: '6', 55: '7', 56: '8', 57: '9',
65: 'a', 66: 'b', 67: 'c', 68: 'd', 69: 'e',
70: 'f', 71: 'g', 72: 'h', 73: 'i', 74: 'j',
75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't',
85: 'u', 86: 'v', 87: 'w', 88: 'x', 89: 'y', 90: 'z',
// fixme: this is usually 91: window.left, 92: window.right, 93: select
91: 'meta.left', 92: 'meta.right', 93: 'meta.right',
96: '0.numpad', 97: '1.numpad', 98: '2.numpad',
99: '3.numpad', 100: '4.numpad', 101: '5.numpad',
102: '6.numpad', 103: '7.numpad', 104: '8.numpad', 105: '9.numpad',
106: 'asterisk.numpad', 107: 'plus.numpad', 109: 'minus.numpad',
108: 'enter.numpad', 110: 'dot.numpad', 111: 'slash.numpad',
112: 'f1', 113: 'f2', 114: 'f3', 115: 'f4', 116: 'f5',
117: 'f6', 118: 'f7', 119: 'f8', 120: 'f9', 121: 'f10',
122: 'f11', 123: 'f12', 124: 'f13', 125: 'f14', 126: 'f15',
127: 'f16', 128: 'f17', 129: 'f18', 130: 'f19', 131: 'f20',
144: 'numlock', 145: 'scrolllock',
186: 'semicolon', 187: 'equal', 188: 'comma', 189: 'minus',
190: 'dot', 191: 'slash', 192: 'backtick', 219: 'openbracket',
220: 'backslash', 221: 'closebracket', 222: 'quote', 224: 'meta'
// see dojo, for ex.
2013-05-09 13:03:33 +00:00
};
2013-05-09 15:00:28 +00:00
//@ Ox.LOCALE <s> Default locale
2013-05-09 13:03:33 +00:00
Ox.LOCALE = 'en';
2013-05-09 15:00:28 +00:00
//@ Ox.LOCALE_NAMES <o> Locale names
Ox.LOCALE_NAMES = {
2013-05-09 13:03:33 +00:00
'ar': 'العربية',
2014-04-01 14:14:46 +00:00
'de': 'Deutsch',
2014-04-01 14:06:49 +00:00
'el': 'Ελληνικά',
2013-05-09 15:00:28 +00:00
'en': 'English',
2014-04-01 14:14:46 +00:00
'fr': 'Français',
2014-02-17 15:30:43 +00:00
'hi': 'हिन्दी'
2013-05-09 13:03:33 +00:00
};
2013-05-09 15:00:28 +00:00
//@ Ox.LOCALES <o> Locales per module
Ox.LOCALES = {};
//@ Ox.MAX_LATITUDE <n> Maximum latitude of a Mercator projection
Ox.MAX_LATITUDE = Ox.deg(Math.atan(Ox.sinh(Math.PI)));
//@ Ox.MIN_LATITUDE <n> Minimum latitude of a Mercator projection
Ox.MIN_LATITUDE = -Ox.MAX_LATITUDE;
2012-06-04 09:49:27 +00:00
//@ Ox.MODIFIER_KEYS <o> Names for modifier keys
// meta comes last so that one can differentiate between
// alt_control_shift_meta.left and alt_control_shift_meta.right
Ox.MODIFIER_KEYS = {
altKey: 'alt', // Mac: option
ctrlKey: 'control',
shiftKey: 'shift',
2012-05-25 21:59:48 +00:00
metaKey: 'meta' // Mac: command
2013-05-09 13:03:33 +00:00
};
2012-06-04 09:49:27 +00:00
//@ Ox.MONTHS <[s]> Names of months
Ox.MONTHS = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];
//@ Ox.SHORT_MONTHS <[s]> Short names of months
Ox.SHORT_MONTHS = Ox.MONTHS.map(function(val) {
2012-05-24 09:47:33 +00:00
return val.slice(0, 3);
});
//@ Ox.PATH <s> Path of Ox.js
Ox.PATH = (function() {
// IE8 can't apply slice to NodeLists, see Ox.slice
2013-12-04 16:21:27 +00:00
var index, regexp = /Ox\.js(\?\d+|)$/,
scripts = document.getElementsByTagName('script'), src;
2013-12-01 12:24:59 +00:00
for (index = scripts.length - 1; index >= 0; index--) {
2013-12-04 16:21:27 +00:00
src = scripts[index].src;
if (regexp.test(src)) {
return src.replace(regexp, '');
}
}
}());
//@ Ox.MODE <s> Mode ('build' or 'dev')
Ox.MODE = Ox.PATH.slice(0, -1).split('/').pop();
//@ Ox.PREFIXES <[str]> `['', 'K', 'M', 'G', 'T', 'P']`
2012-03-24 10:39:21 +00:00
Ox.PREFIXES = ['', 'K', 'M', 'G', 'T', 'P'];
2012-06-04 09:49:27 +00:00
//@ Ox.SEASONS <[s]> Names of the seasons of the year
Ox.SEASONS = ['Winter', 'Spring', 'Summer', 'Fall'];
2012-05-19 08:10:41 +00:00
//@ Ox.STACK_SIZE <n> Maximum number of arguments
Ox.STACK_SIZE = 65536;
2012-06-04 09:49:27 +00:00
//@ Ox.SYMBOLS <o> Unicode characters for symbols
Ox.SYMBOLS = {
2014-09-25 09:49:01 +00:00
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',
arrow_left: '\u2190', arrow_up: '\u2191', arrow_right: '\u2192',
arrow_down: '\u2193', home: '\u2196', end: '\u2198', 'return': '\u21A9',
redo: '\u21BA', undo: '\u21BB', page_up: '\u21DE', page_down: '\u21DF',
tab: '\u21E5', shift: '\u21E7', capslock: '\u21EA', 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',
2014-09-25 09:53:42 +00:00
triangle_up: '\u25B2', triangle_right: '\u25BA', triangle_down: '\u25BC',
select: '\u25BE', triangle_left: '\u25C0', diamond: '\u25C6',
black_star: '\u2605', white_star: '\u2606', burn: '\u2622',
sound: '\u266B', trash: '\u267A', flag: '\u2691', anchor: '\u2693',
gear: '\u2699', atom: '\u269B', warning: '\u26A0', voltage: '\u26A1',
cut: '\u2702', backup: '\u2707', fly: '\u2708', check: '\u2713',
close: '\u2715', ballot: '\u2717', windows: '\u2756', edit: '\uF802',
click: '\uF803', apple: '\uF8FF'
};
2012-06-04 09:49:27 +00:00
//@ Ox.VERSION <s> OxJS version number
2012-04-05 15:29:33 +00:00
Ox.VERSION = '0.1';
2012-06-04 09:49:27 +00:00
//@ Ox.WEEKDAYS <[s]> Names of weekdays
Ox.WEEKDAYS = [
'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'
];
2012-06-04 09:49:27 +00:00
//@ Ox.SHORT_WEEKDAYS <[s]> Short names of weekdays
Ox.SHORT_WEEKDAYS = Ox.WEEKDAYS.map(function(val) {
2012-05-24 09:47:33 +00:00
return val.slice(0, 3);
});