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