commit | author | age
|
68aeb4
|
1 |
// Special directions |
JK |
2 |
var special_directions = { |
|
3 |
'Zajezdnia Nowa Huta' : 'NH', |
|
4 |
'Zajezdnia Podgórze' : 'P', |
|
5 |
}; |
|
6 |
|
572390
|
7 |
var script_version; |
JK |
8 |
var script_version_xhr; |
|
9 |
|
|
10 |
// Check for website updates |
|
11 |
function checkVersion() { |
|
12 |
if(script_version_xhr) script_version_xhr.abort(); |
|
13 |
|
|
14 |
script_version_xhr = $.get( |
|
15 |
'version.php' |
|
16 |
).done(function(data) { |
|
17 |
if(!script_version) { |
|
18 |
script_version = data; |
|
19 |
return; |
|
20 |
} |
|
21 |
|
|
22 |
if(script_version != data) { |
|
23 |
fail(lang.error_new_version); |
|
24 |
location.reload(true); |
|
25 |
} |
|
26 |
}); |
|
27 |
} |
|
28 |
|
|
29 |
function checkVersionInit() { |
|
30 |
checkVersion(); |
|
31 |
setInterval(checkVersion, 3600000); |
|
32 |
} |
|
33 |
|
68aeb4
|
34 |
// Webservice-related functions |
JK |
35 |
function parseVehicle(vehicleId) { |
|
36 |
if(!vehicleId) return; |
|
37 |
if(vehicleId.substr(0, 15) != '635218529567218') { |
|
38 |
console.log('Unknown vehicle, vehicleId=' + vehicleId); |
|
39 |
return; |
|
40 |
} |
|
41 |
|
|
42 |
var id = parseInt(vehicleId.substr(15)) - 736; |
|
43 |
var prefix; |
|
44 |
var type; |
|
45 |
var low; // low floor: 0 = no, 1 - semi, 2 - full |
|
46 |
|
|
47 |
// Single exception - old id used in one case |
|
48 |
if(id == 831) { |
|
49 |
id = 216; |
|
50 |
} |
|
51 |
|
|
52 |
if(101 <= id && id <= 173) { |
|
53 |
prefix = 'HW'; |
|
54 |
type = 'E1'; |
|
55 |
low = 0; |
|
56 |
|
|
57 |
if((108 <= id && id <= 113) || id == 127 || id == 131 || id == 132 || id == 134 || (137 <= id && id <= 139) || (148 <= id && id <= 150) || (153 <= id && id <= 166) || id == 161) { |
|
58 |
prefix = 'RW'; |
|
59 |
} |
|
60 |
} else if(201 <= id && id <= 293) { |
|
61 |
prefix = 'RZ'; |
|
62 |
type = '105Na'; |
|
63 |
low = 0; |
|
64 |
|
|
65 |
if(246 <= id) { |
|
66 |
prefix = 'HZ'; |
|
67 |
} |
|
68 |
if(id == 290) { |
|
69 |
type = '105Nb'; |
|
70 |
} |
|
71 |
} else if(301 <= id && id <= 328) { |
|
72 |
prefix = 'RF'; |
|
73 |
type = 'GT8S'; |
|
74 |
low = 0; |
|
75 |
|
|
76 |
if(id == 313) { |
|
77 |
type = 'GT8C' |
|
78 |
low = 1; |
|
79 |
} |
|
80 |
} else if(401 <= id && id <= 440) { |
|
81 |
prefix = 'HL'; |
|
82 |
type = 'EU8N'; |
|
83 |
low = 1; |
|
84 |
} else if(451 <= id && id <= 462) { |
|
85 |
prefix = 'HK'; |
|
86 |
type = 'N8S-NF'; |
|
87 |
low = 0; |
|
88 |
|
|
89 |
if((451 <= id && id <= 453) || id == 462) { |
|
90 |
type = 'N8C-NF'; |
|
91 |
low = 1; |
|
92 |
} |
|
93 |
} else if(601 <= id && id <= 650) { |
|
94 |
prefix = 'RP'; |
|
95 |
type = 'NGT6 (3)'; |
|
96 |
low = 2; |
|
97 |
|
|
98 |
if(id <= 613) { |
|
99 |
type = 'NGT6 (1)'; |
|
100 |
} else if (id <= 626) { |
|
101 |
type = 'NGT6 (2)'; |
|
102 |
} |
|
103 |
} else if(801 <= id && id <= 824) { |
|
104 |
prefix = 'RY'; |
|
105 |
type = 'NGT8'; |
|
106 |
low = 2; |
|
107 |
} else if(id == 899) { |
|
108 |
prefix = 'RY'; |
|
109 |
type = '126N'; |
|
110 |
low = 2; |
|
111 |
} else if(901 <= id && id <= 936) { |
|
112 |
prefix = 'RG'; |
|
113 |
type = '2014N'; |
|
114 |
low = 2; |
|
115 |
|
|
116 |
if(915 <= id) { |
|
117 |
prefix = 'HG'; |
|
118 |
} |
|
119 |
} else if(id === 999) { |
|
120 |
prefix = 'HX'; |
|
121 |
type = '405N-Kr'; |
|
122 |
low = 1; |
|
123 |
} else { |
|
124 |
console.log('Unknown vehicle, vehicleId=' + vehicleId + ', id=' + id); |
|
125 |
return; |
|
126 |
} |
|
127 |
|
|
128 |
return { |
|
129 |
vehicleId: vehicleId, |
|
130 |
prefix: prefix, |
|
131 |
id: id, |
|
132 |
num: prefix + id, |
|
133 |
type: type, |
|
134 |
low: low |
|
135 |
}; |
|
136 |
} |
|
137 |
|
|
138 |
// Element mangling |
|
139 |
function deleteChildren(element) { |
|
140 |
while(element.lastChild) element.removeChild(element.lastChild); |
|
141 |
} |
|
142 |
|
|
143 |
function addElementWithText(parent, element, text) { |
|
144 |
var elem = document.createElement(element); |
|
145 |
elem.appendChild(document.createTextNode(text)); |
|
146 |
parent.appendChild(elem); |
|
147 |
return elem; |
|
148 |
} |
|
149 |
|
|
150 |
function addCellWithText(parent, text) { |
|
151 |
return addElementWithText(parent, 'td', text); |
|
152 |
} |
|
153 |
|
|
154 |
function addParaWithText(parent, text) { |
|
155 |
return addElementWithText(parent, 'p', text); |
|
156 |
} |
|
157 |
|
|
158 |
function setText(element, text) { |
|
159 |
deleteChildren(element); |
|
160 |
element.appendChild(document.createTextNode(text)); |
|
161 |
} |
|
162 |
|
|
163 |
// Other functions |
|
164 |
var decodeEntitiesTextArea = document.createElement('textarea'); |
|
165 |
function decodeEntities(text) { |
|
166 |
decodeEntitiesTextArea.innerHTML = text; |
|
167 |
return decodeEntitiesTextArea.value; |
|
168 |
} |