forked from nezroy/EVEoj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.js
More file actions
69 lines (58 loc) · 1.52 KB
/
Copy pathcore.js
File metadata and controls
69 lines (58 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var EVEoj = EVEoj || {};
(function ($) {
var ME = EVEoj,
F = function () {} // if needed for Object.create polyfill
;
ME.V_MAJOR = 0;
ME.V_MINOR = 1;
ME.V_PATCH = 0;
ME.VERSION = ME.V_MAJOR + '.' + ME.V_MINOR + '.' + ME.V_PATCH;
ME.M_per_LY = 9.4605284e+15; // meters per lightyear
ME.M_per_AU = 149597870700; // meters per AU
// implementations from external stuff (mostly jQuery) that might theoretically change later
ME.create = (typeof Object.create == 'function')
? Object.create
: function (o) {
// object create polyfill (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
if (arguments.length > 1) throw Error('Second argument not supported');
if (o === null) throw Error('Cannot set a null [[Prototype]]');
if (typeof o != 'object') throw TypeError('Argument must be an object');
F.prototype = o;
return new F();
};
ME.extend = $.extend;
ME.deferred = $.Deferred;
ME.ajax = $.ajax;
// utility stuff
ME.FormatNum = function (val, fixed) {
var stringy = [],
base = String(Math.floor(val)),
k = -1,
i = 0,
decimals
;
fixed = fixed || 0;
for (i = base.length - 1; i >= 0; i--) {
if (k % 3 == 0) {
k = 1;
stringy.push(",");
}
else if (k == -1) {
k = 1;
}
else {
k++;
}
stringy.push(base.charAt(i));
}
base = "";
for (i = stringy.length - 1; i >= 0; i--) {
base = base.concat(stringy[i]);
}
if (fixed > 0) {
decimals = val.toFixed(fixed);
base += decimals.substring(decimals.length - fixed - 1);
}
return base;
};
})(jQuery);