tried some url control
This commit is contained in:
parent
89a44377c9
commit
6c362693da
55
index.html
55
index.html
@ -38,14 +38,14 @@
|
||||
style="width: 300px; margin-top: 51px; padding-top: 12px"
|
||||
id="sidebar"
|
||||
>
|
||||
<ul class="w3-ul">
|
||||
<li
|
||||
<ul class="w3-ul" style="padding-top: 1px;">
|
||||
<!-- <li
|
||||
class="w3-bar-item w3-padding-large w3-button"
|
||||
style="border-bottom: 1px solid rgb(221, 221, 221)"
|
||||
id="loadTemplateBtn"
|
||||
>
|
||||
Load new template
|
||||
</li>
|
||||
</li> -->
|
||||
<li
|
||||
class="w3-bar-item w3-padding-large w3-button"
|
||||
style="border-bottom: 1px solid rgb(221, 221, 221)"
|
||||
@ -91,7 +91,7 @@
|
||||
href="javascript:void(0);"
|
||||
title="Toggle Textblocks Menu"
|
||||
id="toggleTestBlocksMenu"
|
||||
style="display: none;"
|
||||
style="display: none"
|
||||
><i class="fa fa-plane"></i
|
||||
></a>
|
||||
<a
|
||||
@ -103,7 +103,7 @@
|
||||
></a>
|
||||
<a
|
||||
id="logo"
|
||||
href="."
|
||||
href="javascript:void(0)"
|
||||
class="w3-left-align w3-button w3-padding-large w3-flat-wet-asphalt"
|
||||
><img class="logo" src="logo.png" alt="logo" height="30px"
|
||||
/></a>
|
||||
@ -124,7 +124,7 @@
|
||||
<div
|
||||
id="mainForm"
|
||||
class="w3-row-padding w3-padding-top-64 w3-container w3-flat-clouds"
|
||||
style="min-height: 600px;"
|
||||
style="min-height: 600px"
|
||||
>
|
||||
<div class="w3-content">
|
||||
<div class="w3-third w3-center">
|
||||
@ -175,9 +175,9 @@
|
||||
</li>
|
||||
<li>
|
||||
<b>For one word which needs to change:</b><br />
|
||||
<code class="w3-codespan">%Sample Word%1</code><br>
|
||||
<code class="w3-codespan">%Sample Word%1</code><br />
|
||||
Use <code class="w3-codespan">%</code> at the start and end
|
||||
position of the placeholder<br>
|
||||
position of the placeholder<br />
|
||||
Set <code class="w3-codespan">1</code> as priority or any other
|
||||
number up until <code class="w3-codespan">99</code>
|
||||
</li>
|
||||
@ -191,23 +191,26 @@
|
||||
<code class="w3-codespan">Sample Expression=</code> placeholder
|
||||
name<br />
|
||||
Set <code class="w3-codespan">1</code> as priority or any other
|
||||
number up until <code class="w3-codespan">99</code> <br>
|
||||
number up until <code class="w3-codespan">99</code> <br />
|
||||
Config <code class="w3-codespan">hiddenField</code> like so:
|
||||
<br />
|
||||
<code class="w3-codespan"
|
||||
>%Sample Expression=hiddenField:id:longText:!l%1</code
|
||||
><br>
|
||||
><br />
|
||||
in this example <code class="w3-codespan">longText:!l</code> can
|
||||
also be omitted.<br />
|
||||
With <code class="w3-codespan">longText</code> you can add
|
||||
markups like <code class="w3-codespan">!l</code> by adding them
|
||||
like this:<br>
|
||||
like this:<br />
|
||||
<code class="w3-codespan"
|
||||
>%Sample Expression=longText:!l%1</code
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<b>Use field types like longText or markup to customize further</b>
|
||||
<b
|
||||
>Use field types like longText or markup to customize
|
||||
further</b
|
||||
>
|
||||
These are all the different Field types:<br />
|
||||
<code class="w3-codespan">simpleInput</code><br />
|
||||
<code class="w3-codespan">longText</code><br />
|
||||
@ -237,12 +240,17 @@
|
||||
</li>
|
||||
<li>
|
||||
<b>For dropdown lists:</b><br />
|
||||
Use <code class="w3-codespan">%Sample Expression=l:item 1;l:item 2;%1</code> for each item
|
||||
Use
|
||||
<code class="w3-codespan"
|
||||
>%Sample Expression=l:item 1;l:item 2;%1</code
|
||||
>
|
||||
for each item
|
||||
</li>
|
||||
<li>
|
||||
<b>For hidden fields and its trigger:</b><br />
|
||||
Use
|
||||
<code class="w3-codespan">%Sample Expression=h:itemid 1:fieldtype:formatting;%1</code
|
||||
<code class="w3-codespan"
|
||||
>%Sample Expression=h:itemid 1:fieldtype:formatting;%1</code
|
||||
><br />
|
||||
You can also have multiple hidden fields selectable by a list
|
||||
</li>
|
||||
@ -269,10 +277,10 @@
|
||||
|
||||
<div class="w3-container w3-flat-clouds w3-padding">
|
||||
<div
|
||||
id="outputInfo"
|
||||
class="w3-row-padding w3-padding-64 w3-container w3-flat-clouds"
|
||||
style="margin-bottom: 0px; display: none"
|
||||
></div>
|
||||
id="outputInfo"
|
||||
class="w3-row-padding w3-padding-64 w3-container w3-flat-clouds"
|
||||
style="margin-bottom: 0px; display: none"
|
||||
></div>
|
||||
<div
|
||||
id="output"
|
||||
class="w3-row-padding w3-padding-64 w3-container w3-flat-clouds"
|
||||
@ -320,11 +328,7 @@
|
||||
>
|
||||
<p>
|
||||
wrong password - would you like to
|
||||
<a
|
||||
href="#"
|
||||
style="text-decoration: underline"
|
||||
>clear</a
|
||||
>
|
||||
<a href="#" style="text-decoration: underline">clear</a>
|
||||
all files?
|
||||
</p>
|
||||
</div>
|
||||
@ -355,7 +359,10 @@
|
||||
<footer
|
||||
class="w3-container w3-padding w3-flat-clouds w3-center w3-margin-top"
|
||||
>
|
||||
<div class="w3-container w3-margin-top w3-right-align w3-small" id="currentVersion">
|
||||
<div
|
||||
class="w3-container w3-margin-top w3-right-align w3-small"
|
||||
id="currentVersion"
|
||||
>
|
||||
<span></span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
140
js/2.0.0/evts.js
140
js/2.0.0/evts.js
@ -1,13 +1,10 @@
|
||||
import {
|
||||
clearData,
|
||||
createBookShelf,
|
||||
importBookShelf,
|
||||
} from "./storage.js";
|
||||
import { passwordHash } from "./scripts.js";
|
||||
import { clearData, createBookShelf, importBookShelf } from "./storage.js";
|
||||
import {
|
||||
loadTemplate,
|
||||
storeFilesToServer,
|
||||
checkForStoredDataOnServer,
|
||||
delStoredDataOnServer
|
||||
delStoredDataOnServer,
|
||||
} from "./web.js";
|
||||
|
||||
function showMenu() {
|
||||
@ -59,13 +56,18 @@ function insertTextBlocks(t) {
|
||||
if (element === null) {
|
||||
return;
|
||||
}
|
||||
element.value += " "+insert;
|
||||
element.value += " " + insert;
|
||||
let tB = document.getElementById("navTb");
|
||||
tB.className.replace(" w3-show", "");
|
||||
|
||||
if (element.parentElement != undefined) {
|
||||
if (element.parentElement.getElementsByClassName("pell-content")[0] != undefined) {
|
||||
element.parentElement.getElementsByClassName("pell-content")[0].innerHTML = element.value;
|
||||
if (
|
||||
element.parentElement.getElementsByClassName("pell-content")[0] !=
|
||||
undefined
|
||||
) {
|
||||
element.parentElement.getElementsByClassName(
|
||||
"pell-content"
|
||||
)[0].innerHTML = element.value;
|
||||
element = element.parentElement.getElementsByClassName("pell-content")[0];
|
||||
}
|
||||
}
|
||||
@ -133,7 +135,7 @@ function printVersion(msg = "") {
|
||||
let pathVersion = source.split("/");
|
||||
pathVersion = pathVersion[pathVersion.length - 2];
|
||||
//add it to document footer currentVersion
|
||||
versionSpan.textContent = msg+" version: " + pathVersion;
|
||||
versionSpan.textContent = msg + " version: " + pathVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,37 +155,45 @@ function clickImportFiles() {
|
||||
document.getElementById("modalMsg").addEventListener("click", (e) => {
|
||||
if (e.target && e.target.tagName === "BUTTON") {
|
||||
let modal = document.getElementById("modalNotifier");
|
||||
|
||||
|
||||
switch (e.target.innerHTML) {
|
||||
case "Yes":
|
||||
importBookShelf();
|
||||
modal.replaceWith(modal.cloneNode(true));
|
||||
modalNotifier("Imported!", activeState.settings.notifierPause);
|
||||
modalNotifier(
|
||||
"Imported!",
|
||||
activeState.settings.notifierPause
|
||||
);
|
||||
break;
|
||||
case "Cancel":
|
||||
modal.replaceWith(modal.cloneNode(true));
|
||||
document.getElementById("modalNotifier").style.display = "none";
|
||||
document.getElementById("modalNotifier").style.display =
|
||||
"none";
|
||||
break;
|
||||
default:
|
||||
e.preventDefault;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
modalNotifier(
|
||||
"<div class='w3-container'> \
|
||||
Would you like to import the backup created on: "+activeState.serverFilesTs.replace("_", " - ")+ "<br><br> \
|
||||
Would you like to import the backup created on: " +
|
||||
activeState.serverFilesTs.replace("_", " - ") +
|
||||
"<br><br> \
|
||||
<button class='w3-button w3-border w3-flat-wet-asphalt' >Yes</button> \
|
||||
<button class='w3-button w3-border w3-flat-wet-asphalt' >Cancel</button></div>",
|
||||
0);
|
||||
0
|
||||
);
|
||||
break;
|
||||
case "Save":
|
||||
storeFilesToServer(createBookShelf());
|
||||
modal.replaceWith(modal.cloneNode(true));
|
||||
modalNotifier(
|
||||
"Files saved to server <br><br> would you like to <a href='/storage/" +
|
||||
activeState.userId +
|
||||
".txt' style='text-decoration: underline;' download>download</a> them?"
|
||||
,0);
|
||||
activeState.userId +
|
||||
".txt' style='text-decoration: underline;' download>download</a> them?",
|
||||
0
|
||||
);
|
||||
break;
|
||||
case "Delete":
|
||||
delStoredDataOnServer();
|
||||
@ -201,20 +211,24 @@ function clickImportFiles() {
|
||||
<div class='w3-container'> \
|
||||
<button style='display: none;' id='importModalBtn' class='w3-button w3-border w3-flat-wet-asphalt' >Import</button> \
|
||||
<button class='w3-button w3-border w3-flat-wet-asphalt' >Save</button> \
|
||||
<button class='w3-button w3-border w3-flat-pomegranate' >Delete</button></div>",
|
||||
0);
|
||||
|
||||
<button class='w3-button w3-border w3-flat-pomegranate' >Delete</button></div>",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
function createBookShelfDownload() {
|
||||
let data = createBookShelf();
|
||||
let filename = data[0]['data'] + ".txt";
|
||||
let filename = data[0]["data"] + ".txt";
|
||||
document.getElementById("modalMsg").addEventListener("click", (e) => {
|
||||
if (e.target && e.target.tagName === "BUTTON") {
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(data)));
|
||||
element.setAttribute('download', filename);
|
||||
element.style.display = 'none';
|
||||
var element = document.createElement("a");
|
||||
element.setAttribute(
|
||||
"href",
|
||||
"data:text/plain;charset=utf-8," +
|
||||
encodeURIComponent(JSON.stringify(data))
|
||||
);
|
||||
element.setAttribute("download", filename);
|
||||
element.style.display = "none";
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
@ -224,23 +238,64 @@ function createBookShelfDownload() {
|
||||
"Since you are in local only mode you can only export a backup of your files \
|
||||
<br><br> \
|
||||
<div class='w3-container'> \
|
||||
<button class='w3-button w3-border w3-flat-wet-asphalt' >Export</button></div>"
|
||||
,0);
|
||||
|
||||
<button class='w3-button w3-border w3-flat-wet-asphalt' >Export</button></div>",
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
function resetNavBar() {
|
||||
//enable toggleFiles Button
|
||||
let target = document.getElementById("toggleFilesMenu");
|
||||
target.innerHTML = "";
|
||||
let i = document.createElement("i");
|
||||
i.classList.add("fa", "fa-file");
|
||||
//target.classList.add("w3-disabled");
|
||||
target.appendChild(i);
|
||||
target.style.cssText = '';
|
||||
|
||||
//enable toggleTestBlocksMenu
|
||||
document.getElementById("toggleTestBlocksMenu").style.display = "block";
|
||||
//enable toggleFiles Button
|
||||
let target = document.getElementById("toggleFilesMenu");
|
||||
target.innerHTML = "";
|
||||
let i = document.createElement("i");
|
||||
i.classList.add("fa", "fa-file");
|
||||
//target.classList.add("w3-disabled");
|
||||
target.appendChild(i);
|
||||
target.style.cssText = "";
|
||||
|
||||
//enable toggleTestBlocksMenu
|
||||
document.getElementById("toggleTestBlocksMenu").style.display = "block";
|
||||
}
|
||||
|
||||
function resetPage() {
|
||||
return;
|
||||
//set current page value in activeState object
|
||||
activeState.activePage = "landing";
|
||||
|
||||
if (screen.width > 992) {
|
||||
document.getElementById("siteTitle").innerHTML = "Template Gen";
|
||||
} else {
|
||||
document.getElementById("siteTitle").innerHTML = "TG";
|
||||
}
|
||||
|
||||
//sessionVerfication check
|
||||
if (!passwordHash.verify()) {
|
||||
modalNotifier("Error: Session is not authenticated...", 0, false);
|
||||
}
|
||||
|
||||
//reset navbar if files was used
|
||||
resetNavBar();
|
||||
|
||||
//disable toggleTestBlocksMenu
|
||||
document.getElementById("toggleTestBlocksMenu").style.display = "none";
|
||||
|
||||
//reset page and event listeners
|
||||
|
||||
hideMenus("force");
|
||||
|
||||
let mainFormDiv = document.getElementById("mainForm");
|
||||
let outputDiv = document.getElementById("output");
|
||||
let submitContainerDiv = document.getElementById("submitContainer");
|
||||
let sidebarDiv = document.getElementById("sidebar");
|
||||
|
||||
mainFormDiv.innerHTML = "";
|
||||
mainFormDiv.replaceWith(activeState.orgPage.main);
|
||||
outputDiv.innerHTML = "";
|
||||
outputDiv.replaceWith(outputDiv.cloneNode(true));
|
||||
submitContainerDiv.innerHTML = "";
|
||||
submitContainerDiv.replaceWith(submitContainerDiv.cloneNode(true));
|
||||
sidebarDiv.innerHTML = "";
|
||||
sidebarDiv.replaceWith(activeState.orgPage.sidebar);
|
||||
}
|
||||
|
||||
export {
|
||||
@ -254,5 +309,6 @@ export {
|
||||
modalNotifier,
|
||||
clickImportFiles,
|
||||
resetNavBar,
|
||||
printVersion
|
||||
printVersion,
|
||||
resetPage,
|
||||
};
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
clickImportFiles,
|
||||
modalNotifier,
|
||||
printVersion,
|
||||
resetPage
|
||||
} from "./evts.js";
|
||||
import { buildFile } from "./files.js";
|
||||
import setPassword, {
|
||||
@ -46,7 +47,11 @@ window.activeState = {
|
||||
"markup",
|
||||
],
|
||||
markups: ["title", "link", "italic", "green_highlighted", "highlighted"],
|
||||
storage: []
|
||||
storage: [],
|
||||
orgPage: {
|
||||
main: {},
|
||||
sidebar: {}
|
||||
}
|
||||
};
|
||||
|
||||
function init() {
|
||||
@ -87,6 +92,11 @@ function init() {
|
||||
if (screen.width < 993) {
|
||||
document.getElementById("siteTitle").innerHTML = "TG";
|
||||
}
|
||||
|
||||
//backup landing page
|
||||
activeState.orgPage.sidebar = document.getElementById("sidebar");
|
||||
|
||||
activeState.orgPage.main = document.getElementById("mainForm");
|
||||
}
|
||||
|
||||
function eventListeners() {
|
||||
@ -95,6 +105,11 @@ function eventListeners() {
|
||||
.body
|
||||
.addEventListener("click", (e) => hideMenus(e));
|
||||
|
||||
//add logo reset event
|
||||
document
|
||||
.getElementById("logo")
|
||||
.addEventListener("click", resetPage);
|
||||
|
||||
//add set Password to loginForm
|
||||
document
|
||||
.getElementById("submitPassword")
|
||||
@ -104,9 +119,9 @@ function eventListeners() {
|
||||
.getElementById("toggleNavigationMenu")
|
||||
.addEventListener("click", showMenu);
|
||||
//add loadTemplateBtn event showMenu
|
||||
document
|
||||
/* document
|
||||
.getElementById("loadTemplateBtn")
|
||||
.addEventListener("click", showMenu);
|
||||
.addEventListener("click", showMenu); */
|
||||
//add toggle sideBar Menu
|
||||
document
|
||||
.getElementById("toggleSidebarMenu")
|
||||
@ -155,11 +170,15 @@ function eventListeners() {
|
||||
template = newURLArr[newURLArr.length -1];
|
||||
if (template != undefined) {
|
||||
template = template.split("=")[1];
|
||||
if (template != undefined) {
|
||||
if (activeState.templates.includes("")) {
|
||||
loadNewTemplate(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(template);
|
||||
//loadNewTemplate(template);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { hideMenus, modalNotifier, printVersion, resetNavBar } from "./evts.js";
|
||||
import { passwordHash, sanitize } from "./scripts.js";
|
||||
import { clearData, retrieveData, storeData, storeSettings } from "./storage.js";
|
||||
import { retrieveData, storeData, storeSettings } from "./storage.js";
|
||||
|
||||
const buildSettings = () => {
|
||||
//set current page value in activeState object
|
||||
|
||||
@ -102,7 +102,7 @@ function loadNavBar() {
|
||||
for (let x in res) {
|
||||
let aMob = document.createElement("a");
|
||||
|
||||
aMob.setAttribute("href", "#");
|
||||
aMob.setAttribute("href", "javascript:void(0)");
|
||||
aMob.setAttribute("data-template", res[x][1]);
|
||||
aMob.classList.add("w3-bar-item", "w3-button", "w3-padding-large");
|
||||
aMob.innerHTML = res[x][0];
|
||||
@ -112,7 +112,7 @@ function loadNavBar() {
|
||||
activeState.templates.push(res[x][1]);
|
||||
}
|
||||
let createEntry = document.createElement("a");
|
||||
createEntry.setAttribute("href", "#");
|
||||
createEntry.setAttribute("href", "javascript:void(0)");
|
||||
createEntry.setAttribute("data-template", "!createNew");
|
||||
createEntry.classList.add("w3-bar-item", "w3-button", "w3-padding-large");
|
||||
createEntry.style.borderTop = "2px solid rgb(221, 221, 221)";
|
||||
@ -120,22 +120,22 @@ function loadNavBar() {
|
||||
divMob.appendChild(createEntry);
|
||||
|
||||
createEntry = document.createElement("a");
|
||||
createEntry.setAttribute("href", "#");
|
||||
createEntry.setAttribute("href", "javascript:void(0)");
|
||||
createEntry.setAttribute("data-template", "!settings");
|
||||
createEntry.classList.add("w3-bar-item", "w3-button", "w3-padding-large");
|
||||
createEntry.innerHTML = "Settings";
|
||||
divMob.appendChild(createEntry);
|
||||
|
||||
createEntry = document.createElement("a");
|
||||
createEntry.setAttribute("href", "#");
|
||||
createEntry.setAttribute("href", "javascript:void(0)");
|
||||
createEntry.setAttribute("data-template", "!logout");
|
||||
createEntry.classList.add("w3-bar-item", "w3-button", "w3-padding-large", "w3-flat-pomegranate");
|
||||
createEntry.innerHTML = "Logout";
|
||||
divMob.appendChild(createEntry);
|
||||
|
||||
divMob.addEventListener("click", (e) => {
|
||||
e.preventDefault;
|
||||
if (e.target && e.target.matches("a.w3-bar-item")) {
|
||||
e.preventDefault;
|
||||
let template = e.target.dataset.template;
|
||||
if (template == "!createNew") {
|
||||
createTemplate();
|
||||
@ -174,7 +174,7 @@ function initTextBlocks() {
|
||||
if (res[x][1].length < 1) continue;
|
||||
|
||||
let aReg = document.createElement("a");
|
||||
aReg.setAttribute("href", "#");
|
||||
aReg.setAttribute("href", "javascript:void(0)");
|
||||
aReg.classList.add("w3-bar-item", "w3-hide-small", "w3-padding-small");
|
||||
let textBlockText = res[x][1];
|
||||
if (res[x][1].length > 80) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user