diff --git a/index.html b/index.html index 9e89976..9285636 100644 --- a/index.html +++ b/index.html @@ -117,7 +117,6 @@ > @@ -134,6 +133,7 @@
+
clickImportFiles()); //add key listener for ctrl s in form mode +inputRead.init(); window.addEventListener("keydown", (e) => { - + inputRead.read(e); if (e.ctrlKey && e.key == "s") { if (activeState.activePage == "form"); createStorageObj(); diff --git a/js/9.9.9/scripts.js b/js/9.9.9/scripts.js index 81d0111..4f62d29 100644 --- a/js/9.9.9/scripts.js +++ b/js/9.9.9/scripts.js @@ -1,4 +1,4 @@ -import { retrieveData } from "./storage.js"; +import { createStorageObj, retrieveData } from "./storage.js"; import sha256 from "./sha256.min.js"; import XORCipher from "./xorc.js"; import getBrowserFingerprint from "./identify.js" @@ -178,8 +178,49 @@ export function sanitize(string) { '=': '_' }; const reg = /[&<>"'/]/ig; - console.log(string.replace(reg, (match)=>(map[match]))); return string.replace(reg, (match)=>(map[match])); } +function isAlphaNumeric(str) { + var code, i, len; + + for (i = 0, len = str.length; i < len; i++) { + code = str.charCodeAt(i); + if (!(code > 47 && code < 58) && // numeric (0-9) + !(code > 64 && code < 91) && // upper alpha (A-Z) + !(code > 96 && code < 123)) { // lower alpha (a-z) + return false; + } + } + return true; +}; + +export const inputRead = { + init: function () { + this.event = ""; + this.inputString = ""; + this.source = ""; + this.inputContent = ""; + }, + read: function (event) { + this.event = event; + this.source = event.srcElement.id; + let key = (event.key !=undefined) ? event.key : ""; + let contentElement = document.getElementById(this.source); + this.inputContent = (contentElement != undefined) ? contentElement.value + key : ""; + + if (this.inputContent == "" || key == "") return; + if (!isAlphaNumeric(key)) return; + if (key.length > 1) return; + if (activeState.activePage != "template") return; + + document.getElementById("toggleFilesMenu").style.backgroundColor = "#c0392b"; + const run = setTimeout(() => { + createStorageObj(); + document.getElementById("toggleFilesMenu").style.backgroundColor = "#34495e" + }, 3000); + }, + //filter words +} + export default setPassword;