forked from Deyvid777/dozenvalues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatches.html
1 lines (1 loc) · 2.91 KB
/
matches.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><select id="match-dropdown"></select><canvas id="match"></canvas><div id="match-text"></div><div class="small-button-holder"><button class="small-button" id="lister_button"></button><button id="back_button" onclick="window.history.back()"></button><button class="small-button" id="questions_button"></button></div><script type="application/javascript">window.VERSION = "5.0.0"</script><script type="module">import{getJson as e,getLanguage as t,Canvas as n,matchAxisTier as o}from"./dist/common.js";const a=new URLSearchParams(document.location.search);let s=a.get("lang")??"en";const c=t(s);s=c.lang??s;const l=c.resultstext.version_name+": "+window.VERSION,r=e("ideologies-"+s),i=document.getElementById("match"),d=window.matchMedia?.("(prefers-color-scheme: dark)").matches,[m,u]=d?["#202020","#fff"]:["#e0e0e0","#000"],x=new n(i,800,880,c.font.text_font,c.font.title_font,u,m),f=document.getElementById("match-dropdown"),h=document.getElementById("match-text");r.forEach(((e,t)=>{const n=document.createElement("option");n.value=t.toFixed(),n.textContent=e.name,f.appendChild(n)})),c.axes.forEach(((e,t)=>{const n=[e.leftvalue.icon,e.rightvalue.icon];x.drawImages(n,t)}));for(const[e,t]of Object.entries(c.matchestext))document.getElementById(e).textContent=t;document.getElementById("lister_button").addEventListener("click",(()=>{const e=parseInt(f.value);window.location.href="lister.html?lang="+s+"&score="+r[e].stats.map((e=>e.toFixed(1))).join(",")}));function g(e){x.drawHeader(c.resultstext.text.title,"quark88.github.io/dozenvalues/",l,e.name),e.stats.forEach(((e,t)=>{const n=[c.axes[t].leftvalue.color,c.axes[t].rightvalue.color],a=o(e,c.axes[t].tiers);let s;s=c.resultstext.axis_name_before?`${c.resultstext.axis_name} ${c.axes[t].axisname}: ${a}`:`${c.axes[t].axisname} ${c.resultstext.axis_name}: ${a}`,x.drawBar(t,n,e,s)})),h.textContent=e.desc}document.getElementById("questions_button").addEventListener("click",(()=>window.location.href=`questions.html?lang=${s}`)),window.onload=()=>{const e=a.get("ideo");if(e)try{const t=atob(e),n=r.find((e=>e.name===t))??r[0];g(n),f.selectedIndex=r.indexOf(n)}catch(e){console.error(e),g(r[0])}else g(r[0])},f.addEventListener("change",(()=>{const e=parseInt(f.value);g(r[e])}));</script></body></html>