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