added a hashed ID & fixed some bugs when importing

This commit is contained in:
2026-06-28 20:31:17 +02:00
parent cf737f9087
commit 7d95a8825d
6 changed files with 82 additions and 37 deletions
+13 -1
View File
@@ -173,7 +173,7 @@ document.addEventListener("DOMContentLoaded", async function() {
switch (CURRENT_PAGE) { switch (CURRENT_PAGE) {
case (PAGES.SYNTHWAVE): loadingScreenSynthwave(); break 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.TOYS): loadingScreenStars(); break
case (PAGES.LIBS): loadingScreenStars(); break case (PAGES.LIBS): loadingScreenStars(); break
} }
@@ -236,6 +236,18 @@ window.addEventListener("pageshow", (event) => {
let prevAnimationState = isAnimating 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() { document.addEventListener("visibilitychange", function() {
if (document.hidden) { if (document.hidden) {
+4 -5
View File
@@ -59,7 +59,7 @@
<h1>Basic</h1><br> <h1>Basic</h1><br>
<form class="licenseForm licenseFormContainer"> <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="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="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!!!"> <label for="expireInput" >Expires</label ><input type="text" id="expireInput" name="expireInput" value="NEVER!!!">
@@ -87,12 +87,9 @@
</div> </div>
</form><br> </form><br>
<!--<h1>Extra</h1><br> <!--<h1>Colors</h1><br>
<form class="licenseForm"> <form class="licenseForm">
<label for="soon1">Soon...</label><input type="text" name="soon1" value="Does nothing"><br> <label for="soon1">Soon...</label><input type="text" name="soon1" value="Does nothing"><br>
<\!-- decorations like
the QR-code and other "accessories"
-\->
</form><br>--> </form><br>-->
<!--<h1>Advanced</h1><br> <!--<h1>Advanced</h1><br>
@@ -157,6 +154,8 @@
</div> </div>
<p id="credits">Original by Chilli<br>Remade by Byte Dice at bytedice.net/toys</p> <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> </div>
</div> </div>
+46 -26
View File
@@ -17,42 +17,43 @@ let jsonData = {
const customPicOption = document.getElementById("customPic") const customPicOption = document.getElementById("customPic")
function prepInputs() { const VMAP = {
const VMAP = { img: "picInput",
img: "picInput", user: "authorInput",
user: "authorInput", title: "titleInput",
title: "titleInput", silly: "sillyInput",
silly: "sillyInput", issued: "createdInput",
issued: "createdInput", expires: "expireInput",
expires: "expireInput", identity: "identityInput",
identity: "identityInput", signature: "signatureInput",
signature: "signatureInput", imgUpload: "picUpload"
imgUpload: "picUpload" }
}
async function prepInputs() {
function getE(e) { return document.getElementById(e) } function getE(e) { return document.getElementById(e) }
getE(VMAP.img) .oninput = function() { jsonData.img.preset = this.value; updLicense() } getE(VMAP.img) .oninput = async function() { jsonData.img.preset = this.value; await updLicense() }
getE(VMAP.user) .oninput = function() { jsonData.user = this.value; updLicense() } getE(VMAP.user) .oninput = async function() { jsonData.user = this.value; await updLicense() }
getE(VMAP.title) .oninput = function() { jsonData.title = this.value; updLicense() } getE(VMAP.title) .oninput = async function() { jsonData.title = this.value; await updLicense() }
getE(VMAP.silly) .oninput = function() { jsonData.silly = this.value; updLicense() } getE(VMAP.silly) .oninput = async function() { jsonData.silly = parseInt(this.value); await updLicense() }
getE(VMAP.issued) .oninput = function() { jsonData.issued = this.value; updLicense() } getE(VMAP.issued) .oninput = async function() { jsonData.issued = this.value; await updLicense() }
getE(VMAP.expires) .oninput = function() { jsonData.expires = this.value; updLicense() } getE(VMAP.expires) .oninput = async function() { jsonData.expires = this.value; await updLicense() }
getE(VMAP.identity) .oninput = function() { jsonData.identity = this.value; updLicense() } getE(VMAP.identity) .oninput = async function() { jsonData.identity = this.value; await updLicense() }
getE(VMAP.signature).oninput = function() { jsonData.signature = this.value; 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; } if (this.files.length == 0) { return; }
let f = this.files[0] let f = this.files[0]
jsonData.img.file = URL.createObjectURL(f) jsonData.img.file = URL.createObjectURL(f)
customPicOption.innerHTML = `Custom (${f.name})` customPicOption.innerHTML = `Custom (${f.name})`
updLicense() await updLicense()
} }
} }
function updLicense() { license.updateFromJSON(jsonData) } async function updLicense() { await license.updateFromJSON(jsonData) }
function importData() { function importData() {
@@ -61,7 +62,7 @@ function importData() {
} }
function importFromB64(b64) { async function importFromB64(b64) {
if (b64.startsWith("B8D6:")) { b64 = b64.slice(5) } if (b64.startsWith("B8D6:")) { b64 = b64.slice(5) }
try { try {
@@ -72,12 +73,29 @@ function importFromB64(b64) {
{ alert("Invalid data string imported (Invalid fields). Full results:\n" + isValid.join("\n")); return } { alert("Invalid data string imported (Invalid fields). Full results:\n" + isValid.join("\n")); return }
jsonData = data 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 } 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 // I wanna keep compatibility with older versions
function validateJSON_v0(obj) { function validateJSON_v0(obj) {
let is_valid = ( let is_valid = (
@@ -115,7 +133,9 @@ function validateJSON_v0(obj) {
function exportData() { function exportData() {
let str = JSON.stringify(jsonData) let strippedData = jsonData
delete strippedData.img
let str = JSON.stringify(strippedData)
let b64 = btoa(str) let b64 = btoa(str)
let watermarked = "B8D6:" + b64 let watermarked = "B8D6:" + b64
navigator.clipboard.writeText(watermarked) navigator.clipboard.writeText(watermarked)
+9 -1
View File
@@ -121,10 +121,18 @@ h2 {
.sillyValue:last-child { .sillyValue:last-child {
border-radius: 0px 5px 5px 0px; border-radius: 0px 5px 5px 0px;
} }
#titleValue, #DtitleValue { #titleValue {
grid-area: 1 / 1 / 2 / 3; grid-area: 1 / 1 / 2 / 3;
font-size: 2rem; font-size: 2rem;
margin: 0% auto 0% auto; margin: 0% auto 0% auto;
height: max-content; height: max-content;
text-align: center; text-align: center;
}
#hashID {
position: absolute;
bottom: 12px;
right: 0%;
margin: 0% 30px 0% 0%;
color: var(--navBarBtn_Inner);
font-size: 0.6rem;
} }
+5 -1
View File
@@ -3,6 +3,7 @@ const sillyOptNumber = document.getElementById("sillyNumberValue")
class License { class License {
constructor() { constructor() {
this.idE = undefined
this.imgE = undefined this.imgE = undefined
this.userE = undefined this.userE = undefined
this.titleE = undefined this.titleE = undefined
@@ -17,7 +18,7 @@ class License {
} }
updateFromJSON(json) { async updateFromJSON(json) {
this.userE .textContent = json.user this.userE .textContent = json.user
this.titleE .textContent = json.title this.titleE .textContent = json.title
this.issuedE .textContent = json.issued this.issuedE .textContent = json.issued
@@ -27,6 +28,9 @@ class License {
this.setSillyValue(json.silly) this.setSillyValue(json.silly)
this.setImgValue(json.img) this.setImgValue(json.img)
let hash = await sha256(JSON.stringify(json))
this.idE.textContent = "NR-ID: " + hash.slice(0, 16)
} }
+5 -3
View File
@@ -1,7 +1,7 @@
CURRENT_PAGE = PAGES.LICENSE CURRENT_PAGE = PAGES.LICENSE
function loadingScreenLicense() { async function loadingScreenLicense() {
setLoadingProgress("Preparing license...") setLoadingProgress("Preparing license...")
const VMAP = { const VMAP = {
@@ -11,7 +11,8 @@ function loadingScreenLicense() {
expires: "expireValue", expires: "expireValue",
identity: "genderValue", identity: "genderValue",
signature: "signatureValue", signature: "signatureValue",
img: "picValue" img: "picValue",
id: "hashID"
} }
function getE(e) { return document.getElementById(e) } function getE(e) { return document.getElementById(e) }
@@ -23,6 +24,7 @@ function loadingScreenLicense() {
license.identityE = getE(VMAP.identity) license.identityE = getE(VMAP.identity)
license.signatureE = getE(VMAP.signature) license.signatureE = getE(VMAP.signature)
license.imgE = getE(VMAP.img) license.imgE = getE(VMAP.img)
license.idE = getE(VMAP.id)
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
license.sillyValues.push(document.getElementById(`sillyValue${i}`)) license.sillyValues.push(document.getElementById(`sillyValue${i}`))
@@ -30,6 +32,6 @@ function loadingScreenLicense() {
setLoadingProgress("Preparing options...") setLoadingProgress("Preparing options...")
prepInputs() prepInputs()
updLicense(); await updLicense();
scaleDisplayLicense(); scaleDisplayLicense();
} }