This repository was archived by the owner on Jul 6, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathutil.js
More file actions
125 lines (104 loc) · 3.83 KB
/
Copy pathutil.js
File metadata and controls
125 lines (104 loc) · 3.83 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var Util = {
compareRegion: function( pilot ) {
try {
return Data.systems[ pilot.systemId ].regionID === Data.state.vicinity.regionId;
} catch(e) {
return false;
}
},
isMe: function(pilot) {
return Data.state.self.characterId == pilot.characterId;
},
dedupe: function(list, element, key) {
var match = $.grep(list, function(e) { return e[key] === element[key] && e.ts.toString().slice(0,-2) === element.ts.toString().slice(0,-2); });
return (match.length > 0) ? true : false;
},
is_wormhole: function(system) {
return system.id >= 31000000 && system.id <= 31999999;
},
isShip: function (shipName) {
return (typeof Data.ships[shipName] !== 'undefined' && Data.ships[shipName].icons !== undefined);
},
getShipType: function (shipName) {
if (Util.isShip(shipName)){
return Data.ships[shipName].icons[0];
}
return 'other';
},
getShipIcon: function (shipName) {
var returnElement = $('<div/>');
if (Util.isShip(shipName)){
for (var i in Data.ships[shipName].class) {
var file_name = Util.getShipClass(Data.ships[shipName].icons[i]).toLowerCase().replace(/ /gi, '-');
returnElement.append($('<img src="/images/ship-icons/' + file_name + '.png" title="' + shipName +'" alt="' + shipName + '" />'));
}
} else {
returnElement.append($('<img src="/images/ship-icons/ship-icon-other.gif" title="No Visual" alt="No Visual" />'));
}
return $('<div/>').append(returnElement).html();
},
getShipClass: function (shipName) {
if (shipName == 'Rookie Ship') return 'Rookie';
else if (shipName == 'Covert Ops') return 'Frigate';
else if (shipName == 'Stealth Bomber') return 'Frigate';
else if (shipName == 'Blockade Runner') return 'Industrial';
else if (shipName == 'Exhumer') return 'Mining-Barge';
else if (shipName == 'Logistics') return 'Cruiser';
else if (shipName == 'Heavy Assault Cruiser') return 'Cruiser';
else if (shipName == 'Force Recon Ship') return 'Cruiser';
else if (shipName == 'Combat Recon Ship') return 'Cruiser';
else if (shipName == 'Combat Battlecruiser') return 'Battlecruiser';
else if (shipName == 'Marauder') return 'Battleship';
else return shipName;
},
getTime: function () {
return moment().utc().format('HH:mm:ss');
},
formatTime: function(ts) {
return moment(ts).format('HH:mm:ss');
},
escapeHTML: function (string) {
return string.replace(/</gi,'<').replace(/>/gi,'>');
},
deepClone: function (object) {
return JSON.parse(JSON.stringify(object));
},
getUrlKey: function () {
var url = window.location.href,
match = url.match(/[A-z0-9]{17}/);
return match ? match[0] : false;
},
redirectToKeyUrl: function (fleetKey) {
if (fleetKey !== undefined) {
window.location = location.protocol
+ '//' + location.hostname
+ (location.port ? ':' + location.port : '')
+ '/' + fleetKey + '/';
} else {
Data.poll = false;
stopPolling();
Util.redirectToBasePath();
}
},
redirectToBasePath: function () {
window.location = location.protocol
+ '//' + location.hostname
+ (location.port ? ':' + location.port : '')
+ '/';
},
redirectToLoginPath: function () {
window.location = location.protocol
+ '//' + location.hostname
+ (location.port ? ':' + location.port : '')
+ '/login/';
},
redirectIfNecessary: function (fleetKey, callback) {
if (!!fleetKey !== !!Util.getUrlKey() || fleetKey !== Util.getUrlKey()) {
UIPanels.showLoadingPanel('Redirecting to Standing Fleet URL...', function () {
Util.redirectToKeyUrl();
});
} else {
callback();
}
}
};