day add leading zero and add comments

This commit is contained in:
ReznoRMichael 2021-07-20 18:11:09 +02:00
parent 213d5e324a
commit cdf67a5906

View file

@ -1059,7 +1059,9 @@ function SelectCopyInputText(mouseEvent, tooltipId = "", tooltipFill = "") {
if (tooltipFill.length && tooltipId.length) FillInnerHTML(tooltipId, tooltipFill);
}
/* ----------------------- Event Listeners -------------------------- */
/* ========================== Event Listeners ========================== */
/* --------------- Toggle visibility of scroll arrow ------------------ */
document.addEventListener("scroll", () => {
@ -1072,27 +1074,33 @@ document.addEventListener("scroll", () => {
0.1);
});
/* ---------------- Scroll to top when clicked ------------------- */
SCROLL_BUTTON.addEventListener("click", () => {
ScrollToElement(ROOT);
});
// Auto select & copy to clipboard when the save file location input text is clicked once
/* ------------- Auto select & copy to clipboard when the save file location input text is clicked once ------------- */
document.getElementById("save-location-input").addEventListener("click", (e) => {
SelectCopyInputText(e, "save-location-input-tooltip", "Copied save file location to clipboard");
SelectCopyInputText(e, "save-location-input-tooltip", "Copied save location to clipboard");
}, false);
// Switch text back to the default on mouse out
/* -------------- Switch text back to the default on mouse out -------------- */
document.getElementById("save-location-input").addEventListener("mouseout", () => {
FillInnerHTML("save-location-input-tooltip", "Click once to copy to clipboard");
}, false);
// Checkboxes functions
/* ------------- Checkbox functions ---------------------- */
document.getElementById("checkbox-hints").addEventListener("click", CheckboxHintsToggle, false);
document.getElementById("checkbox-spoilers").addEventListener("click", CheckboxSpoilersToggle, false);
/* Drag & drop file to the window */
/* ------------ Drag & drop file to the window -------------- */
window.addEventListener('dragover', (event) => {
event.stopPropagation();
@ -1113,7 +1121,8 @@ window.addEventListener('drop', (event) => {
LoadSaveFile(dt, new Date());
});
/* Monitor file input change and show the file name when file is loaded */
/* ---------- Monitor file input change and show the file name when file is loaded ----------- */
document.getElementById("save-area-file").addEventListener("change", (event) => {
var label = document.getElementById("save-area-file").nextElementSibling;
@ -1124,8 +1133,8 @@ document.getElementById("save-area-file").addEventListener("change", (event) =>
/* Shorten the file name if too long */
if (fileName.length > 17) {
let begin = fileName.slice(0, 10);
let end = fileName.slice(-4);
let begin = fileName.slice(0, 10); // take 10 characters from the beginning (0)
let end = fileName.slice(-4); // take 4 characters from the end (-)
fileName = `${begin}..${end}`;
}
@ -1133,20 +1142,15 @@ document.getElementById("save-area-file").addEventListener("change", (event) =>
var year = fileDate.getFullYear();
var month = fileDate.getMonth() + 1;
if (month < 10) month = "0" + month;
var day = fileDate.getDate();
var hour = fileDate.getHours();
if (hour < 10) hour = "0" + hour;
var minutes = fileDate.getMinutes();
if (minutes < 10) minutes = "0" + minutes;
var seconds = fileDate.getSeconds();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
if (hour < 10) hour = "0" + hour;
if (minutes < 10) minutes = "0" + minutes;
if (seconds < 10) seconds = "0" + seconds;
var fileDateFormat = `${year}.${month}.${day} ${hour}:${minutes}:${seconds}`;
@ -1158,7 +1162,8 @@ document.getElementById("save-area-file").addEventListener("change", (event) =>
}
});
/* Clean the text area and file input from leftover save file if present (Firefox especially) */
/* -------- Clean the text area and file input from leftover save file if present (Firefox especially) -------- */
document.addEventListener("DOMContentLoaded", () => {
(async () => {