forked from Deyvid777/dozenvalues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lister.html
1 lines (1 loc) · 2.41 KB
/
lister.html
1
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Dozenvalues</title><link rel="shortcut icon" href="./assets/icon.png" type="image/x-icon"><link href="./assets/icon.png" type="image/x-icon"><meta property="og:title" content="Dozenvalues"><meta property="og:image" content="https://quark88.github.io/dozenvalues/assets/icon.png"><meta property="og:url" content="https://quark88.github.io/dozenvalues"><meta property="og:type" content="Political test"><meta property="og:locale" content="en_US"><meta property="og:description" content="DozenValues is a political test that aims to map differing political perspectives onto six axes."><link rel="stylesheet" href="./dist/style.css"></head><body><h1 id="title"></h1><div id="matchholder"></div><label for="abs" id="abs_label"></label><input type="checkbox" id="abs"><div class="small-button-holder"><button class="small-button" id="matches_button"></button><button id="back_button" onclick="window.history.back()"></button><button class="small-button" id="questions_button"></button></div><script type="module">import{getJson as e,getLanguage as t,orderScores as n}from"./dist/common.js";const o=new URLSearchParams(document.location.search);let c=o.get("lang")??"en";const a=t(c);c=a.lang??c;let m=(o.get("score")??"50,50,50,50,50,50").split(",").map((e=>parseFloat(e)));const l=e("ideologies-"+c),s=[1,.9,1,.6,.6,.7];6==m.length&&m.every((e=>e>=0&&e<=100))||(m=new Array(6).fill(50));const r=n(m,s,l);for(const[e,t]of Object.entries(a.listertext))document.getElementById(e).textContent=t;document.getElementById("questions_button").addEventListener("click",(()=>window.location.href=`questions.html?lang=${c}`));document.getElementById("matches_button").addEventListener("click",(()=>{window.location.href="matches.html?lang="+c+"&ideo="+btoa(r[0].name)}));const d=document.getElementById("abs");function i(e,t=!1){const n=m.map((e=>Math.max(e,100-e)));let o=0;for(let e=0;e<n.length;e++)o+=s[e]*Math.pow(n[e]/100,3);o/=n.length;const a=Math.max(...e.map((e=>e.score))),l=e.map((e=>{const n=e.score/(t?a:o),c={};return c.score=100*(1-n),c.name=e.name,c})),r=document.getElementById("matchholder");r.innerHTML="",l.forEach(((e,t)=>{const n=document.createElement("a");n.className="match-text",n.textContent=`${t+1}: ${e.name} : ${e.score?.toFixed(1)}%`,n.href=`matches.html?lang=${c}&ideo=${btoa(e.name)}`,r.appendChild(n)}))}d.addEventListener("click",(()=>{i(r,d.checked)})),i(r,d.checked);</script></body></html>