-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
51 lines (36 loc) · 1.14 KB
/
utils.js
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
function format_origin(origin) {
/* Specifies New York, New York in address */
return origin + ', New York, New York';
}
function address_from_elm(elm) {
/* Given DOM element of listing details, return origin */
return $(elm).find('a').text();
}
function neighborhood_from_elm(elm) {
/* Given DOM element of listing details, return origin */
return $(elm).text();
}
function borough_from_elm(elm) {
/* Given DOM element of listing details, return origin */
return neighborhood_map[neighborhood_from_elm(elm)];
}
function append_time_to_elm(elm, time) {
/* Appends time string to the element */
$(elm).append(' ' + time);
}
function append_time_to_elm_list(elm_list, time_list) {
/* Appends time string to the element */
for (var i = 0; i < elm_list.length; i++) {
append_time_to_elm(elm_list[i], time_list[i]);
}
}
function error_elm(elm) {
/* Appends time string to the element */
$(elm).append(' ' + 'Commute time unavailible');
}
function error_elm_list(elm_list) {
/* Appends time string to the element */
for (var i = 0; i < elm_list.length; i++) {
error_elm(elm_list[i]);
}
}