Skip to content

Commit

Permalink
🩹Fixed and improved timepicker form on stationboard (#196)
Browse files Browse the repository at this point in the history
* Fixed and improved timepicker form on stationboard

* Formatting

* Fixed invalid HTML

* Update HelperMethodTest.php
  • Loading branch information
MrKrisKrisu authored Jan 31, 2021
1 parent e59d9bd commit 9d1751a
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 260 deletions.
4 changes: 0 additions & 4 deletions resources/js/appControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,3 @@ $(document).on("click", ".disconnect", function (event) {
}
});
});

$(document).on("click", "#timepicker-button", function (event) {
event.preventDefault();
});
32 changes: 0 additions & 32 deletions resources/js/components/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,5 @@ if (document.getElementById("timepicker-reveal")) {
reveal.add("opacity-null");
}, 1000);
}

document
.getElementById("timepicker-button")
.addEventListener("click", e => {
e.preventDefault();
changeTime();
});
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
changeTime();
}
});

const changeTime = () => {
input.classList.remove("is-invalid");

//This is so completely ugly. Mabe we should reconsider this with moment.js?
let splitDateTime = input.value.split("T");
let splitDate = splitDateTime[0].split('-');
let splitTime = splitDateTime[1].split(':');

let utcDate = Date.UTC(splitDate[0], splitDate[1]-1, splitDate[2], splitTime[0], splitTime[1], 0);
let offset = new Date(utcDate).getTimezoneOffset();
let unixTimestamp = Math.floor((utcDate/1000)+(offset*60));

window.location = window.changeTimeLink
.replace("&", "&")
.replace("&", "&")
.replace("&", "&")
.replace("REPLACEME", unixTimestamp);
};
});
}
Loading

0 comments on commit 9d1751a

Please sign in to comment.