Encoding v3

This commit is contained in:
MeowcaTheoRange 2024-01-03 19:05:02 -06:00
parent a48291379b
commit 773c3b8424
2 changed files with 67 additions and 3 deletions

View file

@ -138,7 +138,7 @@
<section>
<h2>Sexual orientation</h2>
<label>
<input id="spec-sex-ori-amt" type="range" min="0" max="4" value="2" />
<input id="spec-sex-ori-amt" type="range" min="0" max="6" value="3" />
<div class="span3">
<span>Asexual</span>
<span>Regular</span>
@ -158,7 +158,7 @@
<section>
<h2>Romantic orientation</h2>
<label>
<input id="spec-rom-ori-amt" type="range" min="0" max="4" value="2" />
<input id="spec-rom-ori-amt" type="range" min="0" max="6" value="3" />
<div class="span3">
<span>Aromantic</span>
<span>Regular</span>

View file

@ -86,9 +86,11 @@ const descs = {
components: {
amount: [
(val) => `I do not experience any sexual attraction.`,
(val) => `I feel very little sexual attraction, ${val}.`,
(val) => `I feel some sexual attraction, ${val}.`,
(val) => `I feel an average amount of sexual attraction, ${val}.`,
(val) => `I feel more sexual attraction than usual, ${val}.`,
(val) => `I feel a lot of sexual attraction, ${val}.`,
(val) => `I feel extreme sexual attraction, ${val}.`,
],
value: [
@ -105,9 +107,11 @@ const descs = {
components: {
amount: [
(val) => `I do not experience any romantic attraction.`,
(val) => `I feel very little romantic attraction, ${val}.`,
(val) => `I feel some romantic attraction, ${val}.`,
(val) => `I feel an average amount of romantic attraction, ${val}.`,
(val) => `I feel more romantic attraction than usual, ${val}.`,
(val) => `I feel a lot of romantic attraction, ${val}.`,
(val) => `I feel extreme romantic attraction, ${val}.`,
],
value: [
@ -221,6 +225,56 @@ function encode() {
}
function extract_ecfBIN(parsed_string) {
enc_s_gia.value = parseInt(parsed_string.substring(0, 3), 2);
enc_s_gi.value = parseInt(parsed_string.substring(3, 7), 2);
enc_s_geo.checked = parseInt(parsed_string.substring(7, 8), 2);
enc_s_ge.value = parseInt(parsed_string.substring(8, 12), 2);
enc_s_so.value = parseInt(parsed_string.substring(15, 18), 2);
enc_s_ro.value = parseInt(parsed_string.substring(21, 24), 2);
enc_s_raa.value = parseInt(parsed_string.substring(24, 27), 2);
enc_s_ra.value = parseInt(parsed_string.substring(27, 30), 2);
const sex_att = parseInt(parsed_string.substring(12, 15), 2);
const rom_att = parseInt(parsed_string.substring(18, 21), 2);
switch (sex_att) {
case 0:
enc_s_soa.value = 0;
break;
case 1:
enc_s_soa.value = 2;
break;
case 2:
enc_s_soa.value = 3;
break;
case 3:
enc_s_soa.value = 4;
break;
case 4:
enc_s_soa.value = 6;
break;
}
switch (rom_att) {
case 0:
enc_s_roa.value = 0;
break;
case 1:
enc_s_roa.value = 2;
break;
case 2:
enc_s_roa.value = 3;
break;
case 3:
enc_s_roa.value = 4;
break;
case 4:
enc_s_roa.value = 6;
break;
}
}
function extract_ecfBINv2(parsed_string) {
enc_s_gia.value = parseInt(parsed_string.substring(0, 3), 2);
enc_s_gi.value = parseInt(parsed_string.substring(3, 7), 2);
enc_s_geo.checked = parseInt(parsed_string.substring(7, 8), 2);
@ -245,13 +299,19 @@ function decodev2(string) {
extract_ecfBIN(parsed_string);
}
function decodev3(string) {
var parsed_string = parseInt(string, 36).toString(2).padStart(30, "0");
extract_ecfBINv2(parsed_string);
}
const s_share_link = document.getElementById("spec-share-link");
function createShareableURL() {
const url = new URL(window.location.href);
const code = encode();
url.hash = "2-" + code;
url.hash = "3-" + code;
s_share_link.innerHTML = url.toString();
s_share_link.href = url.toString();
@ -265,6 +325,10 @@ function parseURL() {
decodev2(hash.substring(2));
return lockSliders();
}
if (hash.startsWith("3-")) {
decodev3(hash.substring(2));
return lockSliders();
}
} else if (urlParams.get("s") != null) {
decodev1(urlParams.get("s"));
return lockSliders();