expanded files Fileinfo
This commit is contained in:
parent
d737b43be6
commit
1c71af44ba
@ -284,7 +284,7 @@
|
|||||||
<div class="w3-container w3-flat-clouds w3-padding">
|
<div class="w3-container w3-flat-clouds w3-padding">
|
||||||
<div
|
<div
|
||||||
id="outputInfo"
|
id="outputInfo"
|
||||||
class="w3-row-padding w3-padding-64 w3-container w3-flat-clouds"
|
class="w3-row-padding w3-padding-64 w3-container w3-flat-clouds w3-small"
|
||||||
style="margin-bottom: 0px; display: none"
|
style="margin-bottom: 0px; display: none"
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -1,15 +1,10 @@
|
|||||||
import {
|
import { storeData, clearData, retrieveData, setTimeStamp } from "./storage.js";
|
||||||
storeData,
|
|
||||||
clearData,
|
|
||||||
retrieveData,
|
|
||||||
} from "./storage.js";
|
|
||||||
import { loadTemplate } from "./web.js";
|
import { loadTemplate } from "./web.js";
|
||||||
import parseForm from "./parseForm.js";
|
import parseForm from "./parseForm.js";
|
||||||
import { copyToClipBoard, modalNotifier, resetNavBar } from "./evts.js";
|
import { copyToClipBoard, modalNotifier, resetNavBar } from "./evts.js";
|
||||||
import { passwordHash } from "./scripts.js";
|
import { passwordHash } from "./scripts.js";
|
||||||
|
|
||||||
function buildFile() {
|
function buildFile() {
|
||||||
|
|
||||||
//set current page value in activeState object
|
//set current page value in activeState object
|
||||||
activeState.activePage = "files";
|
activeState.activePage = "files";
|
||||||
|
|
||||||
@ -18,7 +13,10 @@ function buildFile() {
|
|||||||
|
|
||||||
if (tF == null || tF.length == 0) {
|
if (tF == null || tF.length == 0) {
|
||||||
//console.log("none yet");
|
//console.log("none yet");
|
||||||
modalNotifier("there are no saved texts yet", activeState.settings.notifierPause);
|
modalNotifier(
|
||||||
|
"there are no saved texts yet",
|
||||||
|
activeState.settings.notifierPause
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +39,7 @@ function buildFile() {
|
|||||||
i.classList.add("fa", "fa-file");
|
i.classList.add("fa", "fa-file");
|
||||||
//target.classList.add("w3-disabled");
|
//target.classList.add("w3-disabled");
|
||||||
target.appendChild(i);
|
target.appendChild(i);
|
||||||
target.style.cssText = 'background-color:#9e9e9e !important';
|
target.style.cssText = "background-color:#9e9e9e !important";
|
||||||
target.style.borderBottom = "4px solid #9e9e9e";
|
target.style.borderBottom = "4px solid #9e9e9e";
|
||||||
|
|
||||||
//disable toggleTestBlocksMenu
|
//disable toggleTestBlocksMenu
|
||||||
@ -88,7 +86,6 @@ function loadFileDiv(fileName, template, pos) {
|
|||||||
storeData("userInputForce", retrieveData(fileName, template));
|
storeData("userInputForce", retrieveData(fileName, template));
|
||||||
|
|
||||||
loadTemplate(template, false, true);
|
loadTemplate(template, false, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFileDivCallBack() {
|
function loadFileDivCallBack() {
|
||||||
@ -179,7 +176,7 @@ function loadFileDivCallBack() {
|
|||||||
let fileInfoDiv = document.getElementById("outputInfo");
|
let fileInfoDiv = document.getElementById("outputInfo");
|
||||||
|
|
||||||
let pos = "";
|
let pos = "";
|
||||||
tF = retrieveData("templateFiles")
|
tF = retrieveData("templateFiles");
|
||||||
for (let tFi of tF) {
|
for (let tFi of tF) {
|
||||||
if (tFi.fileName == fN) {
|
if (tFi.fileName == fN) {
|
||||||
pos = parseInt(tFi.pos);
|
pos = parseInt(tFi.pos);
|
||||||
@ -187,26 +184,68 @@ function loadFileDivCallBack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let tsCreate = tF[pos].metadata.ts_create;
|
let tsCreate = tF[pos].metadata.ts_create;
|
||||||
tsCreate = tsCreate.current_time_long+" "+tsCreate.current_date+"."+tsCreate.current_year;
|
|
||||||
let created = "";
|
let created = "";
|
||||||
if (tF[pos].metadata.ts_create != undefined) {
|
if (tsCreate != "") {
|
||||||
created = "<p>Created at: "+tsCreate+"</p>";
|
tsCreate =
|
||||||
|
tsCreate.current_time_long +
|
||||||
|
" " +
|
||||||
|
tsCreate.current_date +
|
||||||
|
"." +
|
||||||
|
tsCreate.current_year;
|
||||||
|
created = "";
|
||||||
|
created = "<p style='margin: 0'>Created at: " + tsCreate + "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
let tsSave = tF[pos].metadata.ts_save;
|
let tsSave = tF[pos].metadata.ts_save;
|
||||||
tsSave = tsSave.current_time_long+" "+tsSave.current_date+"."+tsSave.current_year;
|
|
||||||
let lastSaved = "";
|
let lastSaved = "";
|
||||||
if (tF[pos].metadata.ts_save != "") {
|
if (tsSave != "") {
|
||||||
lastSaved = "<p>Last saved at: "+tsSave+"</p>";
|
tsSave =
|
||||||
|
tsSave.current_time_long +
|
||||||
|
" " +
|
||||||
|
tsSave.current_date +
|
||||||
|
"." +
|
||||||
|
tsSave.current_year;
|
||||||
|
lastSaved = "";
|
||||||
|
lastSaved = "<p style='margin: 0'>Last saved at: " + tsSave + "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
let tsCopy = tF[pos].metadata.ts_copy;
|
let tsCopy = tF[pos].metadata.ts_copy;
|
||||||
tsCopy = tsCopy.current_time_long+" "+tsCopy.current_date+"."+tsCopy.current_year;
|
|
||||||
let lastCopy = "";
|
let lastCopy = "";
|
||||||
if (tF[pos].metadata.ts_copy != "") {
|
if (tsCopy != "") {
|
||||||
lastCopy = "<p>Last copied at: "+tsCopy+"</p>";
|
tsCopy =
|
||||||
|
tsCopy.current_time_long +
|
||||||
|
" " +
|
||||||
|
tsCopy.current_date +
|
||||||
|
"." +
|
||||||
|
tsCopy.current_year;
|
||||||
|
lastCopy = "";
|
||||||
|
lastCopy = "<p style='margin: 0'>Last copied at: " + tsCopy + "</p>";
|
||||||
}
|
}
|
||||||
fileInfoDiv.innerHTML = "<p><b>Fileinformation:</b></p>"+created+lastSaved+lastCopy+"<p>Template: "+lT+"</p>";
|
|
||||||
|
let tsEdit = tF[pos].metadata.ts_edit;
|
||||||
|
let lastEdit = "";
|
||||||
|
if (tsEdit != "") {
|
||||||
|
tsEdit =
|
||||||
|
tsEdit.current_time_long +
|
||||||
|
" " +
|
||||||
|
tsEdit.current_date +
|
||||||
|
"." +
|
||||||
|
tsEdit.current_year;
|
||||||
|
lastEdit = "";
|
||||||
|
lastEdit = "<p style='margin: 0'>Last edited at: " + tsEdit + "</p>";
|
||||||
|
}
|
||||||
|
fileInfoDiv.innerHTML =
|
||||||
|
"<p><b>Fileinformation:</b></p>" +
|
||||||
|
"<p style='margin: 0'>Template: " +
|
||||||
|
lT +
|
||||||
|
"</p>" +
|
||||||
|
"<p style='margin: 0'>ID: " +
|
||||||
|
tF[pos].metadata.id +
|
||||||
|
"</p>" +
|
||||||
|
created +
|
||||||
|
lastSaved +
|
||||||
|
lastCopy +
|
||||||
|
lastEdit
|
||||||
fileInfoDiv.style.display = "block";
|
fileInfoDiv.style.display = "block";
|
||||||
|
|
||||||
//fix min height of file display
|
//fix min height of file display
|
||||||
@ -263,18 +302,15 @@ function loadFileSidebar(tF) {
|
|||||||
|
|
||||||
let sidebarListItem = document.createElement("li");
|
let sidebarListItem = document.createElement("li");
|
||||||
|
|
||||||
sidebarListItem.classList.add(
|
sidebarListItem.classList.add("w3-padding-large");
|
||||||
"w3-padding-large",
|
|
||||||
);
|
|
||||||
sidebarListItem.style.borderBottom = "1px solid #ddd";
|
sidebarListItem.style.borderBottom = "1px solid #ddd";
|
||||||
sidebarListItem.id = "sb-title";
|
sidebarListItem.id = "sb-title";
|
||||||
sidebarListItem.innerHTML = "Saved Files:"
|
sidebarListItem.innerHTML = "Saved Files:";
|
||||||
sidebarList.appendChild(sidebarListItem);
|
sidebarList.appendChild(sidebarListItem);
|
||||||
|
|
||||||
let c = 0;
|
let c = 0;
|
||||||
let sidebarItemsAmount = 6;
|
let sidebarItemsAmount = 6;
|
||||||
for (let obj of tF.reverse()) {
|
for (let obj of tF.reverse()) {
|
||||||
|
|
||||||
sidebarListItem = document.createElement("li");
|
sidebarListItem = document.createElement("li");
|
||||||
sidebarListItem.classList.add(
|
sidebarListItem.classList.add(
|
||||||
"w3-bar-item",
|
"w3-bar-item",
|
||||||
@ -299,13 +335,14 @@ function loadFileSidebar(tF) {
|
|||||||
|
|
||||||
let sidebarListItemTitle = document.createElement("p");
|
let sidebarListItemTitle = document.createElement("p");
|
||||||
sidebarListItemTitle.innerText = obj.fileName.replace(/_/g, " ");
|
sidebarListItemTitle.innerText = obj.fileName.replace(/_/g, " ");
|
||||||
sidebarListItemTitle.style.cssText = "margin: 0;"
|
sidebarListItemTitle.style.cssText = "margin: 0;";
|
||||||
let sidebarListItemInfo = document.createElement("span");
|
let sidebarListItemInfo = document.createElement("span");
|
||||||
sidebarListItemInfo.classList.add("w3-small");
|
sidebarListItemInfo.classList.add("w3-small");
|
||||||
sidebarListItemInfo.innerText = "created at: "
|
sidebarListItemInfo.innerText =
|
||||||
+obj.metadata.ts_create.current_time
|
"created at: " +
|
||||||
+" - "
|
obj.metadata.ts_create.current_time +
|
||||||
+obj.metadata.ts_create.current_date;
|
" - " +
|
||||||
|
obj.metadata.ts_create.current_date;
|
||||||
sidebarListItem.appendChild(sidebarListItemTitle);
|
sidebarListItem.appendChild(sidebarListItemTitle);
|
||||||
sidebarListItem.append(sidebarListItemInfo);
|
sidebarListItem.append(sidebarListItemInfo);
|
||||||
sidebarListItem.setAttribute("data-file", obj.fileName);
|
sidebarListItem.setAttribute("data-file", obj.fileName);
|
||||||
@ -346,7 +383,6 @@ function copyFileToClipboard() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function formEvts(storageName) {
|
function formEvts(storageName) {
|
||||||
//add event listener to submitContainer
|
//add event listener to submitContainer
|
||||||
document.getElementById("submitContainer").addEventListener("click", (e) => {
|
document.getElementById("submitContainer").addEventListener("click", (e) => {
|
||||||
@ -369,7 +405,10 @@ function formEvts(storageName) {
|
|||||||
);
|
);
|
||||||
e.target.style.pointerEvents = "auto";
|
e.target.style.pointerEvents = "auto";
|
||||||
}, 250);
|
}, 250);
|
||||||
modalNotifier(activeState.fileName + " copied to clipboard", activeState.settings.notifierPause);
|
modalNotifier(
|
||||||
|
activeState.fileName + " copied to clipboard",
|
||||||
|
activeState.settings.notifierPause
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case "Delete":
|
case "Delete":
|
||||||
let previousFile = getPreviousFile(storageName);
|
let previousFile = getPreviousFile(storageName);
|
||||||
@ -377,12 +416,19 @@ function formEvts(storageName) {
|
|||||||
let delFileName = activeState.fileName;
|
let delFileName = activeState.fileName;
|
||||||
document.getElementById("mainForm").innerHTML = "";
|
document.getElementById("mainForm").innerHTML = "";
|
||||||
if (previousFile) {
|
if (previousFile) {
|
||||||
loadFileDiv(previousFile.fileName, previousFile.template, previousFile.pos);
|
loadFileDiv(
|
||||||
|
previousFile.fileName,
|
||||||
|
previousFile.template,
|
||||||
|
previousFile.pos
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("mainForm").innerHTML =
|
document.getElementById("mainForm").innerHTML =
|
||||||
mainFormPlaceholder("No file yet");
|
mainFormPlaceholder("No file yet");
|
||||||
}
|
}
|
||||||
modalNotifier(delFileName + " deleted!", activeState.settings.notifierPause);
|
modalNotifier(
|
||||||
|
delFileName + " deleted!",
|
||||||
|
activeState.settings.notifierPause
|
||||||
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -407,6 +453,9 @@ function editSpecificTemplate(storageName) {
|
|||||||
//reset correct activePage
|
//reset correct activePage
|
||||||
activeState.activePage = "template";
|
activeState.activePage = "template";
|
||||||
|
|
||||||
|
//set edit timestamp
|
||||||
|
setTimeStamp("edit");
|
||||||
|
|
||||||
loadTemplate(storageName.split("_m21_")[1]);
|
loadTemplate(storageName.split("_m21_")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +490,10 @@ function clickClearAllFiles() {
|
|||||||
case "Delete":
|
case "Delete":
|
||||||
clearAllFiles();
|
clearAllFiles();
|
||||||
modal.replaceWith(modal.cloneNode(true));
|
modal.replaceWith(modal.cloneNode(true));
|
||||||
modalNotifier("All files deleted!", activeState.settings.notifierPause);
|
modalNotifier(
|
||||||
|
"All files deleted!",
|
||||||
|
activeState.settings.notifierPause
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
e.preventDefault;
|
e.preventDefault;
|
||||||
@ -458,7 +510,10 @@ function clickClearAllFiles() {
|
|||||||
function clearAllFiles() {
|
function clearAllFiles() {
|
||||||
let tF = retrieveData("templateFiles");
|
let tF = retrieveData("templateFiles");
|
||||||
if (tF == null || tF.length == 0) {
|
if (tF == null || tF.length == 0) {
|
||||||
modalNotifier("there are no saved texts yet", activeState.settings.notifierPause);
|
modalNotifier(
|
||||||
|
"there are no saved texts yet",
|
||||||
|
activeState.settings.notifierPause
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let storageName of tF) {
|
for (let storageName of tF) {
|
||||||
|
|||||||
@ -70,27 +70,7 @@ function createStorageObj(ref = "none") {
|
|||||||
setCurrentFileName();
|
setCurrentFileName();
|
||||||
|
|
||||||
//set savetime in templateFiles
|
//set savetime in templateFiles
|
||||||
if (activeState.fileName != "") {
|
setTimeStamp(ref);
|
||||||
let tF = retrieveData("templateFiles");
|
|
||||||
if (tF.length != 0) {
|
|
||||||
let c = 0;
|
|
||||||
for (let tFi of tF) {
|
|
||||||
if (tFi.fileName == activeState.fileName) {
|
|
||||||
switch (ref) {
|
|
||||||
case "save":
|
|
||||||
tF[c].metadata.ts_save = getCurrentDate();
|
|
||||||
break;
|
|
||||||
case "copy":
|
|
||||||
console.log("copy");
|
|
||||||
tF[c].metadata.ts_copy = getCurrentDate();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
storeData("templateFiles", tF);
|
|
||||||
}
|
|
||||||
c += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
storeData("userInput", dataArray);
|
storeData("userInput", dataArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +163,7 @@ function getFileName() {
|
|||||||
ts_create: getCurrentDate(),
|
ts_create: getCurrentDate(),
|
||||||
ts_save: "",
|
ts_save: "",
|
||||||
ts_copy: "",
|
ts_copy: "",
|
||||||
|
ts_edit: "",
|
||||||
id: cyrb53(currentFileName),
|
id: cyrb53(currentFileName),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -330,6 +311,33 @@ function setCurrentFileName() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTimeStamp(type) {
|
||||||
|
if (activeState.fileName != "") {
|
||||||
|
let tF = retrieveData("templateFiles");
|
||||||
|
if (tF.length != 0) {
|
||||||
|
let c = 0;
|
||||||
|
for (let tFi of tF) {
|
||||||
|
if (tFi.fileName == activeState.fileName) {
|
||||||
|
switch (type) {
|
||||||
|
case "save":
|
||||||
|
tF[c].metadata.ts_save = getCurrentDate();
|
||||||
|
break;
|
||||||
|
case "copy":
|
||||||
|
console.log("copy");
|
||||||
|
tF[c].metadata.ts_copy = getCurrentDate();
|
||||||
|
break;
|
||||||
|
case "edit":
|
||||||
|
tF[c].metadata.ts_edit = getCurrentDate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
storeData("templateFiles", tF);
|
||||||
|
}
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
createStorageObj,
|
createStorageObj,
|
||||||
storeData,
|
storeData,
|
||||||
@ -340,5 +348,6 @@ export {
|
|||||||
importBookShelf,
|
importBookShelf,
|
||||||
storeSettings,
|
storeSettings,
|
||||||
clearStorage,
|
clearStorage,
|
||||||
setCurrentFileName
|
setCurrentFileName,
|
||||||
|
setTimeStamp
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user