Skip to content

Commit 19d5dac

Browse files
committed
separated updateScale_tresh() action
1 parent aa22acb commit 19d5dac

File tree

3 files changed

+64
-49
lines changed

3 files changed

+64
-49
lines changed

public/js/stops.js

+4
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ function resizeCircles () {
235235
};
236236

237237
function toggleStopTypes () {
238+
toggleLoad("on");
238239
if (globals.lastcall.vis !== null) {
240+
console.log("Running long toggle process.");
239241
var early = $("#param_stoptype_early")[0].checked;
240242
var ontime = $("#param_stoptype_ontime")[0].checked;
241243
var late = $("#param_stoptype_late")[0].checked;
@@ -270,7 +272,9 @@ function toggleStopTypes () {
270272
});
271273

272274
redrawStops();
275+
console.log("Finished long toggle process.");
273276
}
277+
toggleLoad("off");
274278
};
275279

276280
function getCounts (aspect, stop) {

server.js

+42-35
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,48 @@ app.get('/api/arrivals', function (req, res) {
6565
} else {
6666

6767
rows = getConfig('public/data/example_response.json');
68-
69-
// var query = "SELECT rds.stop_id, route_id, direction_id, " +
70-
// "fulfilled, early_5, early_2, early, " +
71-
// "on_time, late, late_10, late_15, late_20, late_30 " +
72-
// "FROM stops " +
73-
// "INNER JOIN rds ON stops.stop_id = rds.stop_id " +
74-
// "INNER JOIN adherence ON adherence.rds = rds.rds " +
75-
// "WHERE feed_index >= 26 " +
76-
// "AND date = '" + date + "'" +
77-
// "AND hour = '" + hour + "' LIMIT 200;"
78-
79-
// console.log(query);
80-
// connection.query(query, function (err, rows, fields) {
81-
// if (err) {
82-
// res.status(500).send("MySQL error during query run. " + err);
83-
// } else {
84-
85-
var clean = {};
86-
87-
rows.forEach(function (stop) {
88-
var k = stop.stop_id;
89-
if (clean[k] == undefined) {
90-
clean[k] = {0: null, 1: null};
91-
}
92-
var d = stop.direction_id;
93-
if (d == 0 || d == 1) {
94-
clean[k][d] = stop;
95-
delete clean[k][d].stop_id;
96-
delete clean[k][d].direction_id;
97-
}
98-
});
99-
100-
res.status(200).send(clean);
101-
// }
102-
// });
68+
var clean = {};
69+
rows.forEach(function (stop) {
70+
var k = stop.stop_id;
71+
if (clean[k] == undefined) { clean[k] = {0: null, 1: null}; }
72+
var d = stop.direction_id;
73+
if (d == 0 || d == 1) { clean[k][d] = stop; delete clean[k][d].stop_id; delete clean[k][d].direction_id; }
74+
});
75+
res.status(200).send(clean);
76+
77+
// var query = "SELECT rds.stop_id, route_id, direction_id, " +
78+
// "fulfilled, early_5, early_2, early, " +
79+
// "on_time, late, late_10, late_15, late_20, late_30 " +
80+
// "FROM stops " +
81+
// "INNER JOIN rds ON stops.stop_id = rds.stop_id " +
82+
// "INNER JOIN adherence ON adherence.rds = rds.rds " +
83+
// "WHERE feed_index >= 26 " +
84+
// "AND date = '" + date + "'" +
85+
// "AND hour = '" + hour + "';"
86+
87+
// connection.query(query, function (err, rows, fields) {
88+
// if (err) {
89+
// res.status(500).send("MySQL error during query run. " + err);
90+
// } else {
91+
92+
// var clean = {};
93+
94+
// rows.forEach(function (stop) {
95+
// var k = stop.stop_id;
96+
// if (clean[k] == undefined) {
97+
// clean[k] = {0: null, 1: null};
98+
// }
99+
// var d = stop.direction_id;
100+
// if (d == 0 || d == 1) {
101+
// clean[k][d] = stop;
102+
// delete clean[k][d].stop_id;
103+
// delete clean[k][d].direction_id;
104+
// }
105+
// });
106+
107+
// res.status(200).send(clean);
108+
// }
109+
// });
103110
}
104111
});
105112

views/stops.html

+18-14
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ <h5>
127127

128128
<div class="row">
129129
<div class="one-half column">
130-
Minimum percentage ontime (<span id="changeable_early_threshold">0</span> percent)
130+
Minimum percentage early (<span id="changeable_early_threshold">0</span> percent)
131131
</div>
132132
<div class="one-half column">
133133
<input class="u-full-width" type="range" id="param_early_threshold"
134-
min="0" max="100" value="0" onclick="updateScale()">
134+
min="0" max="100" value="0" onclick="updateScale_tresh()">
135135
</div>
136136
</div>
137137

@@ -141,17 +141,17 @@ <h5>
141141
</div>
142142
<div class="one-half column">
143143
<input class="u-full-width" type="range" id="param_ontime_threshold"
144-
min="0" max="100" value="0" onclick="updateScale()">
144+
min="0" max="100" value="0" onclick="updateScale_tresh()">
145145
</div>
146146
</div>
147147

148148
<div class="row">
149149
<div class="one-half column">
150-
Minimum percentage ontime (<span id="changeable_late_threshold">0</span> percent)
150+
Minimum percentage late (<span id="changeable_late_threshold">0</span> percent)
151151
</div>
152152
<div class="one-half column">
153153
<input class="u-full-width" type="range" id="param_late_threshold"
154-
min="0" max="100" value="0" onclick="updateScale()">
154+
min="0" max="100" value="0" onclick="updateScale_tresh()">
155155
</div>
156156
</div>
157157

@@ -261,15 +261,19 @@ <h5>
261261

262262
function updateScale () {
263263
if (!$(".ajax").is(":visible")) {
264-
if ($("#changeable_scale")[0].innerHTML !== $("#param_scale")[0].value) {
265-
$("#changeable_scale")[0].innerHTML !== $("#param_scale")[0].value;
266-
resizeCircles();
267-
} else {
268-
$("#changeable_early_threshold")[0].innerHTML = $("#param_early_threshold").val();
269-
$("#changeable_ontime_threshold")[0].innerHTML = $("#param_ontime_threshold").val();
270-
$("#changeable_late_threshold")[0].innerHTML = $("#param_late_threshold").val();
271-
toggleStopTypes();
272-
}
264+
console.log("Update scale.");
265+
$("#changeable_scale")[0].innerHTML !== $("#param_scale")[0].value;
266+
resizeCircles();
267+
}
268+
}
269+
270+
function updateScale_tresh () {
271+
if (!$(".ajax").is(":visible")) {
272+
console.log("Update scale thresh.");
273+
$("#changeable_early_threshold")[0].innerHTML = $("#param_early_threshold").val();
274+
$("#changeable_ontime_threshold")[0].innerHTML = $("#param_ontime_threshold").val();
275+
$("#changeable_late_threshold")[0].innerHTML = $("#param_late_threshold").val();
276+
toggleStopTypes();
273277
}
274278
}
275279

0 commit comments

Comments
 (0)