-
Notifications
You must be signed in to change notification settings - Fork 7
/
lister.html
1 lines (1 loc) · 2.42 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,b64enc as o}from"./dist/common.js";const c=new URLSearchParams(document.location.search);let a=c.get("lang")??"en";const m=t(a);a=m.lang??a;let l=(c.get("score")??"50,50,50,50,50,50").split(",").map((e=>parseFloat(e)));const s=e("ideologies-"+a),r=[1,.9,1,.6,.6,.7];6==l.length&&l.every((e=>e>=0&&e<=100))||(l=new Array(6).fill(50));const d=n(l,r,s);for(const[e,t]of Object.entries(m.listertext))document.getElementById(e).textContent=t;document.getElementById("questions_button").addEventListener("click",(()=>window.location.href=`questions.html?lang=${a}`));document.getElementById("matches_button").addEventListener("click",(()=>{window.location.href="matches.html?lang="+a+"&ideo="+o(d[0].name)}));const i=document.getElementById("abs");function h(e,t=!1){const n=l.map((e=>Math.max(e,100-e)));let c=0;for(let e=0;e<n.length;e++)c+=r[e]*Math.pow(n[e]/100,3);c/=n.length;const m=Math.max(...e.map((e=>e.score))),s=e.map((e=>{const n=e.score/(t?m:c),o={};return o.score=100*(1-n),o.name=e.name,o})),d=document.getElementById("matchholder");d.innerHTML="",s.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=${a}&ideo=${o(e.name)}`,d.appendChild(n)}))}i.addEventListener("click",(()=>{h(d,i.checked)})),h(d,i.checked);</script></body></html>