-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
1 lines (1 loc) · 23.3 KB
/
index.js
File metadata and controls
1 lines (1 loc) · 23.3 KB
1
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=28)}([function(e,t,r){"use strict";var n=r(2),o=Object.prototype.toString;function a(e){return"[object Array]"===o.call(e)}function i(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===o.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:a,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!i(e)&&null!==e.constructor&&!i(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:c,isUndefined:i,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:u,isStream:function(e){return s(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:l,merge:function e(){var t={};function r(r,n){c(t[n])&&c(r)?t[n]=e(t[n],r):c(r)?t[n]=e({},r):a(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)l(arguments[n],r);return t},extend:function(e,t,r){return l(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},function(e,t,r){e.exports=r(10)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},function(e,t,r){"use strict";var n=r(0);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var a;if(r)a=r(t);else if(n.isURLSearchParams(t))a=t.toString();else{var i=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),i.push(o(t)+"="+o(e))})))})),a=i.join("&")}if(a){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";(function(t){var n=r(0),o=r(16),a={"Content-Type":"application/x-www-form-urlencoded"};function i(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==t&&"[object process]"===Object.prototype.toString.call(t))&&(s=r(6)),s),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(i(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(i(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(a)})),e.exports=c}).call(this,r(15))},function(e,t,r){"use strict";var n=r(0),o=r(17),a=r(19),i=r(3),s=r(20),c=r(23),u=r(24),l=r(7);e.exports=function(e){return new Promise((function(t,r){var f=e.data,d=e.headers;n.isFormData(f)&&delete d["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(m+":"+h)}var g=s(e.baseURL,e.url);if(p.open(e.method.toUpperCase(),i(g,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p.onreadystatechange=function(){if(p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in p?c(p.getAllResponseHeaders()):null,a={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:n,config:e,request:p};o(t,r,a),p=null}},p.onabort=function(){p&&(r(l("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(l("Network Error",e,null,p)),p=null},p.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(l(t,e,"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var y=(e.withCredentials||u(g))&&e.xsrfCookieName?a.read(e.xsrfCookieName):void 0;y&&(d[e.xsrfHeaderName]=y)}if("setRequestHeader"in p&&n.forEach(d,(function(e,t){void 0===f&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),e.responseType)try{p.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),r(e),p=null)})),f||(f=null),p.send(f)}))}},function(e,t,r){"use strict";var n=r(18);e.exports=function(e,t,r,o,a){var i=new Error(e);return n(i,t,r,o,a)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],a=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function c(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function u(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=c(void 0,t[e]))})),n.forEach(a,u),n.forEach(i,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(void 0,t[o])})),n.forEach(s,(function(n){n in t?r[n]=c(e[n],t[n]):n in e&&(r[n]=c(void 0,e[n]))}));var l=o.concat(a).concat(i).concat(s),f=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return n.forEach(f,u),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){"use strict";var n=r(0),o=r(2),a=r(11),i=r(8);function s(e){var t=new a(e),r=o(a.prototype.request,t);return n.extend(r,a.prototype,t),n.extend(r,t),r}var c=s(r(5));c.Axios=a,c.create=function(e){return s(i(c.defaults,e))},c.Cancel=r(9),c.CancelToken=r(25),c.isCancel=r(4),c.all=function(e){return Promise.all(e)},c.spread=r(26),c.isAxiosError=r(27),e.exports=c,e.exports.default=c},function(e,t,r){"use strict";var n=r(0),o=r(3),a=r(12),i=r(13),s=r(8);function c(e){this.defaults=e,this.interceptors={request:new a,response:new a}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[i,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(s(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,n){return this.request(s(n||{},{method:e,url:t,data:r}))}})),e.exports=c},function(e,t,r){"use strict";var n=r(0);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,r){"use strict";var n=r(0),o=r(14),a=r(4),i=r(5);function s(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return s(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function(t){return s(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return a(t)||(s(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t){var r,n,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c,u=[],l=!1,f=-1;function d(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!l){var e=s(d);l=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new m(e,t)),1!==u.length||l||s(p)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(7);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,a,i){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(o)&&s.push("path="+o),n.isString(a)&&s.push("domain="+a),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";var n=r(21),o=r(22);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,a,i={};return e?(n.forEach(e.split("\n"),(function(e){if(a=e.indexOf(":"),t=n.trim(e.substr(0,a)).toLowerCase(),r=n.trim(e.substr(a+1)),t){if(i[t]&&o.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(9);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},function(e,t,r){"use strict";r.r(t);var n=r(1),o=r.n(n);var a=class{constructor(e){this.questionsNum=e,this.indexArray=[],this.createIndexArray(e)}createIndexArray(e){for(;this.indexArray.length<e;){const t=Math.floor(Math.random()*e)+1;-1===this.indexArray.indexOf(t)&&this.indexArray.push(t)}}async drawAnswers(e){const t=[],r=[],n=await this.getCharacter(e);for(r.push(e);r.length<4;){const e=Math.floor(Math.random()*this.questionsNum);-1===r.indexOf(e)&&r.push(e)}return t[0]=n,t[1]=await this.getCharacter(r[1]),t[2]=await this.getCharacter(r[2]),t[3]=await this.getCharacter(r[3]),t}shuffledArray(e){const t=[...e],r=[];for(let e=4;e>0;e--){const n=Math.floor(Math.random()*e);let o=t.splice(n,1);r.push(o[0])}return r}};var i=class extends a{constructor(e){super(e)}async getCharacter(e){(e=e||1)>this.questionsNum-1&&(e%=this.questionsNum-1);const t=this.indexArray[e-1],r={},n=await o()("https://thronesapi.com/api/v2/Characters/"+t);return r.id=await n.data.id,r.name=await n.data.fullName,r.image=await n.data.imageUrl,r}};var s=class extends a{constructor(e){super(e)}async getCharacter(e){(e=e||1)>this.questionsNum-1&&(e%=this.questionsNum-1);const t=this.indexArray[e-1],r={},n=await o()("https://rickandmortyapi.com/api/character/"+t);return r.id=n.data.id,r.name=n.data.name,r.image=n.data.image,r}};var c=class extends a{constructor(e){super(e)}async getCharacter(e){(e=e||1)>this.questionsNum-1&&(e%=this.questionsNum-1);const t=this.indexArray[e-1],r={},n=await o()("https://breakingbadapi.com/api/characters/"+t);return r.id=n.data[0].char_id,r.name=n.data[0].name,r.image=n.data[0].img,r}};const u=document.querySelectorAll(".main__quiz__button"),l=document.querySelector("#logo"),f=new i(30),d=new s(30),p=new c(30),m={correctAnswer:"",questionCounter:0,trueAnswer:0,falseAnswer:0,quizName:""};function h(e){u.forEach(e=>e.removeEventListener("click",h)),m.questionCounter++,parseInt(e.target.dataset.id,10)===m.correctAnswer.id?(e.target.classList.add("btn--correct"),localStorage.setItem("trueAnswer",++m.trueAnswer),setTimeout(()=>{w(m.quizName)},1e3)):(e.target.classList.add("btn--wrong"),localStorage.setItem("falseAnswer",++m.falseAnswer),setTimeout(()=>{w(m.quizName)},1e3))}function g(e){e.classList.remove("btn--correct"),e.classList.remove("btn--wrong")}async function y(e){const t=await e.drawAnswers(m.questionCounter+1),r=e.shuffledArray(t);m.correctAnswer=t[0],function e(t){setTimeout(()=>{if(void 0===t[0].id||void 0===t[1].id||void 0===t[2].id||void 0===t[3].id)e(t);else for(let e in t)g(u[e]),u[e].innerText=t[e].name,u[e].dataset.id=t[e].id,u[e].addEventListener("click",h)},400)}(r),function e(t){const r=document.querySelector("#character-img"),n=document.querySelector(".quiz-panel");setTimeout(()=>{if(void 0===t.image)e(t);else{r.style.backgroundImage=`url("${t.image}")`;const e=localStorage.getItem("category"),o=window.location.toString().substr(0,window.location.toString().lastIndexOf("/"));n.style.backgroundImage=`linear-gradient(\n 170deg,\n rgba(0, 15, 31, 0.5) 5%,\n rgba(206, 70, 70, 0) 40%,\n rgba(4, 8, 15, 0.9) 100%\n ), url("${o}/img/${e}.jpg")`}},100)}(m.correctAnswer)}function w(e){switch(m.quizName=e,e){case"got":y(f),l.setAttribute("src","img/got-logo.png");break;case"rm":y(d),l.setAttribute("src","img/rm-logo.png");break;case"bb":y(p),l.setAttribute("src","img/bb-logo.png");break;default:alert("error: wrong category")}}const b=document.querySelector(".GameOfThrone"),v=document.querySelector(".RickAndMorty"),S=document.querySelector(".Breaking-Bad");function x(e){localStorage.setItem("category",e);const t=window.location.toString().substr(0,window.location.toString().lastIndexOf("/"));window.location.href=t+"/filler-panel.html"}const A=document.querySelector(".footer__time-bar__time"),I=document.querySelector("#character-img"),T=document.head.appendChild(document.createElement("style"));const E=document.querySelector(".container"),q=document.querySelector("#title");function C(){const e=document.getElementById("username").value;return localStorage.setItem("username",e),e}const O=new class{constructor(){this.timeLeft=60,this.prefix="0:"}updateProgressBar(){T.innerHTML="\n .footer__time-bar__time-progress::before {\n left: 99%;\n transition: all 60s linear;\n } .footer__time-bar__time-progress::after {\n width: 100%;\n transition: all 60s linear;\n }"}countingDown(){setTimeout(()=>{if(I.style.backgroundImage){const e=setInterval(()=>{if(this.updateProgressBar(),this.timeLeft<10&&(this.prefix="0:0"),A.innerText=this.prefix+this.timeLeft--,this.timeLeft<0){clearInterval(e),localStorage.getItem("trueAnswer"),localStorage.getItem("falseAnswer");const t=window.location.toString().substr(0,window.location.toString().lastIndexOf("/"));window.location.href=t+"/ranking.html"}},1e3)}else this.countingDown()},100)}},k=window.location.pathname.split("/").pop();switch(k){case"intro-panel.html":b.addEventListener("click",()=>{x("got")}),v.addEventListener("click",()=>{x("rm")}),S.addEventListener("click",()=>{x("bb")});break;case"filler-panel.html":!function(){switch(localStorage.getItem("category")){case"got":E.style.backgroundImage="linear-gradient(\n 170deg,\n rgba(0, 15, 31, 0.5) 5%,\n rgba(206, 70, 70, 0) 40%,\n rgba(4, 8, 15, 0.9) 100%\n ),url('img/got.jpg')",q.innerText="GAME OF THRONES";break;case"rm":E.style.backgroundImage="linear-gradient(\n 170deg,\n rgba(0, 15, 31, 0.5) 5%,\n rgba(206, 70, 70, 0) 40%,\n rgba(4, 8, 15, 0.9) 100%\n ),url('img/rm.jpg')",q.innerText="RICK AND MORTY";break;case"bb":E.style.backgroundImage="linear-gradient(\n 170deg,\n rgba(0, 15, 31, 0.5) 5%,\n rgba(206, 70, 70, 0) 40%,\n rgba(4, 8, 15, 0.9) 100%\n ),url('img/bb.jpg')",q.innerText="BREAKING BAD";break;default:alert("error: wrong category")}}(),document.querySelector("#button").addEventListener("click",C);break;case"quiz-panel.html":localStorage.setItem("falseAnswer",0),localStorage.setItem("trueAnswer",0);w(localStorage.getItem("category")),O.countingDown();break;case"ranking.html":document.querySelector("#name").innerText=localStorage.getItem("username"),function(){localStorage.getItem("first")||(localStorage.setItem("first",""),localStorage.setItem("firstScore",0)),localStorage.getItem("second")||(localStorage.setItem("second",""),localStorage.setItem("secondScore",0)),localStorage.getItem("third")||(localStorage.setItem("third",""),localStorage.setItem("thirdScore",0));const e=localStorage.getItem("username"),t=10*parseInt(localStorage.getItem("trueAnswer"))-parseInt(localStorage.getItem("falseAnswer")),r=parseInt(localStorage.getItem("firstScore")),n=parseInt(localStorage.getItem("secondScore")),o=parseInt(localStorage.getItem("thirdScore"));t>r?(localStorage.setItem("first",e),localStorage.setItem("firstScore",t)):t>n?(localStorage.setItem("second",e),localStorage.setItem("secondScore",t)):t>o&&(localStorage.setItem("third",e),localStorage.setItem("thirdScore",t)),document.querySelector("#stUsedname").innerText=localStorage.getItem("first"),document.querySelector("#stScore").innerText=localStorage.getItem("firstScore"),document.querySelector("#ndUsername").innerText=localStorage.getItem("second"),document.querySelector("#ndScore").innerText=localStorage.getItem("secondScore"),document.querySelector("#rdUsername").innerText=localStorage.getItem("third"),document.querySelector("#rdScore").innerText=localStorage.getItem("thirdScore")}();break;default:console.log("Page ",k)}}]);