-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duplicated on_duty locale changed to off_duty
- Loading branch information
Showing
20 changed files
with
551 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,79 @@ | ||
let meterStarted = false; | ||
|
||
const updateMeter = (meterData) => { | ||
$("#total-price").html("$ " + meterData.currentFare.toFixed(2)); | ||
$("#total-distance").html( | ||
(meterData.distanceTraveled).toFixed(2) + " mi" | ||
); | ||
$("#total-price").html("$ " + meterData.currentFare.toFixed(2)); | ||
$("#total-distance").html(meterData.distanceTraveled.toFixed(2) + " mi"); | ||
}; | ||
|
||
const resetMeter = () => { | ||
$("#total-price").html("$ 0.00"); | ||
$("#total-distance").html("0.00 mi"); | ||
$("#total-price").html("$ 0.00"); | ||
$("#total-distance").html("0.00 mi"); | ||
}; | ||
|
||
const toggleMeter = (enabled) => { | ||
if (enabled) { | ||
$(".toggle-meter-btn").html("<p>Started</p>"); | ||
$(".toggle-meter-btn p").css({ color: "rgb(51, 160, 37)" }); | ||
} else { | ||
$(".toggle-meter-btn").html("<p>Stopped</p>"); | ||
$(".toggle-meter-btn p").css({ color: "rgb(231, 30, 37)" }); | ||
} | ||
if (enabled) { | ||
$(".toggle-meter-btn").html("<p>Started</p>"); | ||
$(".toggle-meter-btn p").css({ color: "rgb(51, 160, 37)" }); | ||
} else { | ||
$(".toggle-meter-btn").html("<p>Stopped</p>"); | ||
$(".toggle-meter-btn p").css({ color: "rgb(231, 30, 37)" }); | ||
} | ||
}; | ||
|
||
const meterToggle = () => { | ||
if (!meterStarted) { | ||
$.post( | ||
"https://qb-taxijob/enableMeter", | ||
JSON.stringify({ | ||
enabled: true, | ||
}) | ||
); | ||
toggleMeter(true); | ||
meterStarted = true; | ||
} else { | ||
$.post( | ||
"https://qb-taxijob/enableMeter", | ||
JSON.stringify({ | ||
enabled: false, | ||
}) | ||
); | ||
toggleMeter(false); | ||
meterStarted = false; | ||
} | ||
if (!meterStarted) { | ||
$.post( | ||
"https://qb-taxijob/enableMeter", | ||
JSON.stringify({ | ||
enabled: true, | ||
}) | ||
); | ||
toggleMeter(true); | ||
meterStarted = true; | ||
} else { | ||
$.post( | ||
"https://qb-taxijob/enableMeter", | ||
JSON.stringify({ | ||
enabled: false, | ||
}) | ||
); | ||
toggleMeter(false); | ||
meterStarted = false; | ||
} | ||
}; | ||
|
||
const openMeter = (meterData) => { | ||
$(".container").fadeIn(150); | ||
$("#total-price-per-100m").html("$ " + meterData.defaultPrice.toFixed(2)); | ||
$(".container").fadeIn(150); | ||
$("#total-price-per-100m").html("$ " + meterData.defaultPrice.toFixed(2)); | ||
}; | ||
|
||
const closeMeter = () => { | ||
$(".container").fadeOut(150); | ||
$(".container").fadeOut(150); | ||
}; | ||
|
||
$(document).ready(function () { | ||
$(".container").hide(); | ||
window.addEventListener("message", (event) => { | ||
const eventData = event.data; | ||
switch (eventData.action) { | ||
case "openMeter": | ||
if (eventData.toggle) { | ||
openMeter(eventData.meterData); | ||
} else { | ||
closeMeter(); | ||
$(".container").hide(); | ||
window.addEventListener("message", (event) => { | ||
const eventData = event.data; | ||
switch (eventData.action) { | ||
case "openMeter": | ||
if (eventData.toggle) { | ||
openMeter(eventData.meterData); | ||
} else { | ||
closeMeter(); | ||
} | ||
break; | ||
case "toggleMeter": | ||
meterToggle(); | ||
break; | ||
case "updateMeter": | ||
updateMeter(eventData.meterData); | ||
break; | ||
case "resetMeter": | ||
resetMeter(); | ||
break; | ||
default: | ||
break; | ||
} | ||
break; | ||
case "toggleMeter": | ||
meterToggle(); | ||
break; | ||
case "updateMeter": | ||
updateMeter(eventData.meterData); | ||
break; | ||
case "resetMeter": | ||
resetMeter(); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.