-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminified-script.js
More file actions
1 lines (1 loc) · 3.3 KB
/
Copy pathminified-script.js
File metadata and controls
1 lines (1 loc) · 3.3 KB
1
let data=[];const myLocalStorage=window.localStorage.getItem("anon-responses");function showButtons(){lock();const t=document.getElementById("input").value;document.getElementById("input-button").style.visibility=t?"visible":"hidden",data.length>0?document.getElementById("get-data").style.visibility="visible":document.getElementById("get-data").style.visibility="hidden"}function enter(){const t=document.getElementById("input").value;t&&(data.push(t),shuffle(data),window.localStorage.setItem("anon-responses",JSON.stringify(data))),document.getElementById("input").value="",document.getElementById("input-button").style.visibility="hidden",document.getElementById("input").focus()}function inputEnter(t){(13===t.which||13===t.keyCode)&&enter()}function clearData(){window.localStorage.setItem("anon-responses",JSON.stringify([])),data=[],document.getElementById("output").value=""}function shuffle(t){for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1)),o=t[e];t[e]=t[n],t[n]=o}return t}function showData(){document.getElementById("output").style.visibility="visible",document.getElementById("output").value=data.join("\n\n"),document.getElementById("lock").style.visibility="visible",document.getElementById("password").value="",document.getElementById("password").style.visibility="hidden",document.getElementById("password-prompt").style.visibility="hidden",document.getElementById("clear-data").style.visibility="visible"}myLocalStorage&&myLocalStorage.length&&myLocalStorage.length>0&&(data=JSON.parse(window.localStorage.getItem("anon-responses")));let password=null,dictionary=["prompt,answer"];function generatePassword(){const t=getRandomNumber(0,dictionary.length),e=dictionary[t].split(","),n=obfuscatePrompt(e[0]);password=e[1],document.getElementById("password-prompt").textContent=n}function requirePassword(){document.getElementById("get-data").style.visibility="hidden",document.getElementById("password").value="",document.getElementById("password").style.visibility="visible",document.getElementById("password-prompt").style.visibility="visible",document.getElementById("lock").style.visibility="hidden",generatePassword(),window.setTimeout((function(){document.getElementById("password").focus()}),100)}function lock(){document.getElementById("get-data").style.visibility="visible",document.getElementById("password").value="",document.getElementById("password").style.visibility="hidden",document.getElementById("password-prompt").style.visibility="hidden",document.getElementById("output").value="",document.getElementById("output").style.visibility="hidden",document.getElementById("lock").style.visibility="hidden",document.getElementById("clear-data").style.visibility="hidden",document.getElementById("input").focus()}function checkPassword(){const t=document.getElementById("password").value;password.startsWith(t)?t===password&&showData():lock()}function getRandomNumber(t,e){return t+Math.floor(Math.random()*e)}let obfuscationMapping={a:"a",b:"b",c:"c",d:"d",e:"e",f:"f",g:"g",h:"h",i:"i",j:"j",k:"k",l:"l",m:"m",n:"n",o:"o",p:"p",q:"q",r:"r",s:"s",t:"t",u:"u",v:"v",w:"w",x:"x",y:"y",z:"z"};function obfuscatePrompt(t){let e="",n=!0,o=getRandomNumber(1,3),i=0;for(;i<t.length;){if(n){e+=obfuscationMapping[t[i]]}else e+=t[i];i>=o&&(n=!n,o=i+getRandomNumber(1,3)),i++}return e}module.exports={getRandomNumber:getRandomNumber};