added a hashed ID & fixed some bugs when importing
This commit is contained in:
+13
-1
@@ -173,7 +173,7 @@ document.addEventListener("DOMContentLoaded", async function() {
|
||||
|
||||
switch (CURRENT_PAGE) {
|
||||
case (PAGES.SYNTHWAVE): loadingScreenSynthwave(); break
|
||||
case (PAGES.LICENSE): loadingScreenLicense(); loadingScreenStars(); break
|
||||
case (PAGES.LICENSE): loadingScreenStars(); await loadingScreenLicense(); break
|
||||
case (PAGES.TOYS): loadingScreenStars(); break
|
||||
case (PAGES.LIBS): loadingScreenStars(); break
|
||||
}
|
||||
@@ -236,6 +236,18 @@ window.addEventListener("pageshow", (event) => {
|
||||
|
||||
let prevAnimationState = isAnimating
|
||||
|
||||
|
||||
async function sha256(text) {
|
||||
const data = new TextEncoder().encode(text);
|
||||
|
||||
const hash = await crypto.subtle.digest("SHA-256", data);
|
||||
|
||||
return [...new Uint8Array(hash)]
|
||||
.map(x => x.toString(16).padStart(2, "0"))
|
||||
.join("");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
document.addEventListener("visibilitychange", function() {
|
||||
if (document.hidden) {
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
<h1>Basic</h1><br>
|
||||
<form class="licenseForm licenseFormContainer">
|
||||
<label for="titleInput" >Title</label ><input type="text" id="titleInput" name="titleInput" value="Boykisser license">
|
||||
<label for="titleInput" >Title</label ><input type="text" id="titleInput" name="titleInput" value="Boykisser License">
|
||||
<label for="authorInput" >User</label ><input type="text" id="authorInput" name="authorInput" value="Byte Dice">
|
||||
<label for="createdInput" >Issued</label ><input type="text" id="createdInput" name="createdInput" value="2025-01-01">
|
||||
<label for="expireInput" >Expires</label ><input type="text" id="expireInput" name="expireInput" value="NEVER!!!">
|
||||
@@ -87,12 +87,9 @@
|
||||
</div>
|
||||
</form><br>
|
||||
|
||||
<!--<h1>Extra</h1><br>
|
||||
<!--<h1>Colors</h1><br>
|
||||
<form class="licenseForm">
|
||||
<label for="soon1">Soon...</label><input type="text" name="soon1" value="Does nothing"><br>
|
||||
<\!-- decorations like
|
||||
the QR-code and other "accessories"
|
||||
-\->
|
||||
</form><br>-->
|
||||
|
||||
<!--<h1>Advanced</h1><br>
|
||||
@@ -157,6 +154,8 @@
|
||||
</div>
|
||||
|
||||
<p id="credits">Original by Chilli<br>Remade by Byte Dice at bytedice.net/toys</p>
|
||||
<!-- NR-ID = Non-Reversible IDentification -->
|
||||
<p id="hashID">NR-ID: 8f434346648f6b96</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+37
-17
@@ -17,8 +17,7 @@ let jsonData = {
|
||||
const customPicOption = document.getElementById("customPic")
|
||||
|
||||
|
||||
function prepInputs() {
|
||||
const VMAP = {
|
||||
const VMAP = {
|
||||
img: "picInput",
|
||||
user: "authorInput",
|
||||
title: "titleInput",
|
||||
@@ -28,31 +27,33 @@ function prepInputs() {
|
||||
identity: "identityInput",
|
||||
signature: "signatureInput",
|
||||
imgUpload: "picUpload"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function prepInputs() {
|
||||
function getE(e) { return document.getElementById(e) }
|
||||
|
||||
getE(VMAP.img) .oninput = function() { jsonData.img.preset = this.value; updLicense() }
|
||||
getE(VMAP.user) .oninput = function() { jsonData.user = this.value; updLicense() }
|
||||
getE(VMAP.title) .oninput = function() { jsonData.title = this.value; updLicense() }
|
||||
getE(VMAP.silly) .oninput = function() { jsonData.silly = this.value; updLicense() }
|
||||
getE(VMAP.issued) .oninput = function() { jsonData.issued = this.value; updLicense() }
|
||||
getE(VMAP.expires) .oninput = function() { jsonData.expires = this.value; updLicense() }
|
||||
getE(VMAP.identity) .oninput = function() { jsonData.identity = this.value; updLicense() }
|
||||
getE(VMAP.signature).oninput = function() { jsonData.signature = this.value; updLicense() }
|
||||
getE(VMAP.img) .oninput = async function() { jsonData.img.preset = this.value; await updLicense() }
|
||||
getE(VMAP.user) .oninput = async function() { jsonData.user = this.value; await updLicense() }
|
||||
getE(VMAP.title) .oninput = async function() { jsonData.title = this.value; await updLicense() }
|
||||
getE(VMAP.silly) .oninput = async function() { jsonData.silly = parseInt(this.value); await updLicense() }
|
||||
getE(VMAP.issued) .oninput = async function() { jsonData.issued = this.value; await updLicense() }
|
||||
getE(VMAP.expires) .oninput = async function() { jsonData.expires = this.value; await updLicense() }
|
||||
getE(VMAP.identity) .oninput = async function() { jsonData.identity = this.value; await updLicense() }
|
||||
getE(VMAP.signature).oninput = async function() { jsonData.signature = this.value; await updLicense() }
|
||||
|
||||
getE(VMAP.imgUpload).oninput = function() {
|
||||
getE(VMAP.imgUpload).oninput = async function() {
|
||||
if (this.files.length == 0) { return; }
|
||||
let f = this.files[0]
|
||||
jsonData.img.file = URL.createObjectURL(f)
|
||||
customPicOption.innerHTML = `Custom (${f.name})`
|
||||
|
||||
updLicense()
|
||||
await updLicense()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updLicense() { license.updateFromJSON(jsonData) }
|
||||
async function updLicense() { await license.updateFromJSON(jsonData) }
|
||||
|
||||
|
||||
function importData() {
|
||||
@@ -61,7 +62,7 @@ function importData() {
|
||||
}
|
||||
|
||||
|
||||
function importFromB64(b64) {
|
||||
async function importFromB64(b64) {
|
||||
if (b64.startsWith("B8D6:")) { b64 = b64.slice(5) }
|
||||
|
||||
try {
|
||||
@@ -72,12 +73,29 @@ function importFromB64(b64) {
|
||||
{ alert("Invalid data string imported (Invalid fields). Full results:\n" + isValid.join("\n")); return }
|
||||
|
||||
jsonData = data
|
||||
updLicense()
|
||||
// make sure to add this since it isnt exported
|
||||
jsonData.img = { preset: "boykisser", file: "" }
|
||||
await updLicense()
|
||||
makeOptionsTheSameAsJSON()
|
||||
}
|
||||
catch (err) { alert("Invalid data string imported. Full results:\n" + err); return }
|
||||
}
|
||||
|
||||
|
||||
function makeOptionsTheSameAsJSON() {
|
||||
function getE(e) { return document.getElementById(e) }
|
||||
|
||||
getE(VMAP.user).value = jsonData.user
|
||||
getE(VMAP.title).value = jsonData.title
|
||||
getE(VMAP.silly).value = jsonData.silly
|
||||
getE(VMAP.issued).value = jsonData.issued
|
||||
getE(VMAP.expires).value = jsonData.expires
|
||||
getE(VMAP.identity).value = jsonData.identity
|
||||
getE(VMAP.signature).value = jsonData.signature
|
||||
getE(VMAP.img).value = jsonData.img.preset
|
||||
}
|
||||
|
||||
|
||||
// I wanna keep compatibility with older versions
|
||||
function validateJSON_v0(obj) {
|
||||
let is_valid = (
|
||||
@@ -115,7 +133,9 @@ function validateJSON_v0(obj) {
|
||||
|
||||
|
||||
function exportData() {
|
||||
let str = JSON.stringify(jsonData)
|
||||
let strippedData = jsonData
|
||||
delete strippedData.img
|
||||
let str = JSON.stringify(strippedData)
|
||||
let b64 = btoa(str)
|
||||
let watermarked = "B8D6:" + b64
|
||||
navigator.clipboard.writeText(watermarked)
|
||||
|
||||
@@ -121,10 +121,18 @@ h2 {
|
||||
.sillyValue:last-child {
|
||||
border-radius: 0px 5px 5px 0px;
|
||||
}
|
||||
#titleValue, #DtitleValue {
|
||||
#titleValue {
|
||||
grid-area: 1 / 1 / 2 / 3;
|
||||
font-size: 2rem;
|
||||
margin: 0% auto 0% auto;
|
||||
height: max-content;
|
||||
text-align: center;
|
||||
}
|
||||
#hashID {
|
||||
position: absolute;
|
||||
bottom: 12px;
|
||||
right: 0%;
|
||||
margin: 0% 30px 0% 0%;
|
||||
color: var(--navBarBtn_Inner);
|
||||
font-size: 0.6rem;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ const sillyOptNumber = document.getElementById("sillyNumberValue")
|
||||
|
||||
class License {
|
||||
constructor() {
|
||||
this.idE = undefined
|
||||
this.imgE = undefined
|
||||
this.userE = undefined
|
||||
this.titleE = undefined
|
||||
@@ -17,7 +18,7 @@ class License {
|
||||
}
|
||||
|
||||
|
||||
updateFromJSON(json) {
|
||||
async updateFromJSON(json) {
|
||||
this.userE .textContent = json.user
|
||||
this.titleE .textContent = json.title
|
||||
this.issuedE .textContent = json.issued
|
||||
@@ -27,6 +28,9 @@ class License {
|
||||
|
||||
this.setSillyValue(json.silly)
|
||||
this.setImgValue(json.img)
|
||||
|
||||
let hash = await sha256(JSON.stringify(json))
|
||||
this.idE.textContent = "NR-ID: " + hash.slice(0, 16)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
CURRENT_PAGE = PAGES.LICENSE
|
||||
|
||||
|
||||
function loadingScreenLicense() {
|
||||
async function loadingScreenLicense() {
|
||||
setLoadingProgress("Preparing license...")
|
||||
|
||||
const VMAP = {
|
||||
@@ -11,7 +11,8 @@ function loadingScreenLicense() {
|
||||
expires: "expireValue",
|
||||
identity: "genderValue",
|
||||
signature: "signatureValue",
|
||||
img: "picValue"
|
||||
img: "picValue",
|
||||
id: "hashID"
|
||||
}
|
||||
|
||||
function getE(e) { return document.getElementById(e) }
|
||||
@@ -23,6 +24,7 @@ function loadingScreenLicense() {
|
||||
license.identityE = getE(VMAP.identity)
|
||||
license.signatureE = getE(VMAP.signature)
|
||||
license.imgE = getE(VMAP.img)
|
||||
license.idE = getE(VMAP.id)
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
license.sillyValues.push(document.getElementById(`sillyValue${i}`))
|
||||
@@ -30,6 +32,6 @@ function loadingScreenLicense() {
|
||||
|
||||
setLoadingProgress("Preparing options...")
|
||||
prepInputs()
|
||||
updLicense();
|
||||
await updLicense();
|
||||
scaleDisplayLicense();
|
||||
}
|
||||
Reference in New Issue
Block a user