PageSourceSearch

https://amfi.no/dist/client/assets/poll.component-BJLieIkn.js

js amfi.no collected 2026-10-02 08:06:35 UTC 1,754 bytes, 1 lines download raw bytes

1class c extends HTMLFormElement{get storageKey(){return`poll-votes-${this.dataset.center}`}get buttons(){return this.querySelectorAll(".poll-block__button")}get meters(){return this.querySelectorAll(".poll-block__meter")}get votes(){return this.dataset.votes?JSON.parse(this.dataset.votes):{}}connectedCallback(){this.syncCSSProperties();const t=this.getVote();t?this.setResponses(this.votes,t):(this.addEventListener("submit",this.submitForm),this.ariaLive="polite")}async submitForm(t){t.preventDefault(),this.dataset.loading="";const o=t.submitter,a=t.target,s=await fetch(a.target,{method:a.method??"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({vote:o.value})});if(s.ok){const e=await s.json();this.trackVote(e,o.value),this.setResponses(e.votes,o.value)}else console.error("Failed to submit vote",s);delete this.dataset.loading}getVote(){const t=this.dataset.id,o=localStorage.getItem(this.storageKey);return(o?JSON.parse(o):{})[t]}trackVote(t,o){const a=this.storageKey,s=localStorage.getItem(a),e=s?JSON.parse(s):{};e[t.pollId]=o,localStorage.setItem(a,JSON.stringify(e))}setResponses(t,o){const a=Object.values(t).reduce((s,e)=>s+e,0);this.buttons.forEach(s=>{const e=document.createElement("span");e.classList.add("poll-block__meter");const n=document.createElement("span");e.appendChild(n);const r=s.value,i=t[r]??0;let l=Math.round(i/a*100);Number.isFinite(l)||(l=0),e.dataset.value=`${l}`,n.textContent=s.textContent,e.ariaLabel=`${s.textContent}: ${l}%`,r===o&&(e.dataset.vote=""),s.replaceWith(e)}),this.syncCSSProperties()}syncCSSProperties(){this.meters.forEach(t=>{t.style.setProperty("--value",`${t.dataset.value}%`)})}}customElements.get("poll-block")||customElements.define("poll-block",c,{extends:"form"});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.