-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogBookGetMap.js
68 lines (48 loc) · 2.35 KB
/
logBookGetMap.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var moveHistory = [];
var moveHistoryStr = "var moveHistory = [];";
var firstLoc = "";
var Location = "";
var mapUrl = "https://www.google.com/maps/dir/";
var dataClass;
if ($("#eld-ev-s-text-content")[0]) dataClass = $("#eld-ev-s-text-content > tr");
else if ($("#eld-ev-o-text-content")[0]) dataClass = $("#eld-ev-o-text-content > tr");
else if ($("#eld-ev-text-content")[0]) dataClass = $("#eld-ev-text-content > tr");
var count = $( dataClass ).length;
$( dataClass ).each(function(i) {
var ind = $(this).find("td:nth-child(1)").text().trim();
var loc = $(this).find("td:nth-child(5)").text().trim();
var timeStart = $(this).find("td:nth-child(3)").text().trim();
var status = $(this).find("td:nth-child(2)").text().trim();
var notes = $(this).find("td:nth-child(8)").text().trim();
if (notes == "") notes = " ";
moveHistory[ ind ] = [];
moveHistory[ ind ]["loc"] = loc;
moveHistory[ ind ]["timeStart"] = timeStart;
moveHistory[ ind ]["status"] = status;
moveHistoryStr += "moveHistory[" + ind + "] = [];";
moveHistoryStr += "moveHistory[" + ind + "][\"loc\"] = \"" + loc + "\";";
moveHistoryStr += "moveHistory[" + ind + "][\"timeStart\"] = \"" + timeStart + "\";";
moveHistoryStr += "moveHistory[" + ind + "][\"status\"] = \"" + status + "\";";
moveHistoryStr += "moveHistory[" + ind + "][\"notes\"] = \"" + notes + "\";";
var statusBtn = "";
switch (status) {
case "Off Duty" : statusBtn = "edit-event-set-off-duty";break;
case "SB" : statusBtn = "edit-event-set-sleeper";break;
case "Driving" : statusBtn = "edit-event-set-driving";break;
case "ddd" : statusBtn = "edit-event-set-ym";break;
case "ddd" : statusBtn = "edit-event-set-pc";break;
case "On Duty" : statusBtn = "edit-event-set-on-duty";break;
}
moveHistoryStr += "moveHistory[" + ind + "][\"statusBtn\"] = \"" + statusBtn + "\";";
firstLoc = $(this).find("td:nth-child(5)").text().trim().slice( ($(this).find("td:nth-child(5)").text().trim().indexOf(" of ") ) + 4);
if (firstLoc != Location){
mapUrl += firstLoc.replace(" ", "+").replace(" ", "+").replace(" ", "+")
.replace(" ", "+") + ",+USA/";
Location = firstLoc;
}
if (i+1 === count) {
mapUrl += "@?hl=en";
console.log( mapUrl );
window.open(mapUrl, "_blank")
}
});