mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 00:46:22 +00:00
1 line
6.7 KiB
Plaintext
1 line
6.7 KiB
Plaintext
{"version":3,"sources":["render.js"],"names":["const","render","lsKey","configs","al","name","root","array","Array","apply","length","map","_","i","slice","miku","config","selected","done","renderEnabled","localStorage","div","document","createElement","innerHTML","buttons","reload","text","className","confirm","swal","content","then","value","do","newValue","querySelector","checked","undefined","removeItem","timer","renderScript","dataset","version","parseSelectedConfig","previousElement","remove","element","parseVersion","Math","floor","random","alt","title","src","classList","add","addEventListener","showTogglePrompt","body","appendChild","page","apiChecked","readyState","onloaded","window"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SACPC,QAAS,CACPC,GAAI,CACFC,KAAM,cACNC,KAAM,aAENC,MAAOC,MAAMC,MAAM,KAAM,CAAEC,OAAQ,KAAMC,KAAG,SAAEC,EAAGC,GAAG,OAAO,MAAQA,EAAI,IAAIC,OAAO,GAAE,WAEtFC,KAAM,CACJV,KAAM,WACNC,KAAM,eAENC,MAAOC,MAAMC,MAAM,KAAM,CAAEC,OAAQ,KAAMC,KAAG,SAAEC,EAAGC,GAAG,OAAO,MAAQA,EAAI,IAAIC,OAAO,GAAE,YAGxFE,OAAQ,KACRC,SAAU,KACVC,MAAM,EAGRjB,iBAAuB,WACrBD,IAAMmB,IAAiD,MAA/BC,aAAanB,OAAOC,QACtCmB,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,+IAIiCL,EAAgB,UAAY,IAAE,wCAC7ClB,OAAOe,OAAO,KAAI,kMAOpDhB,IAAMyB,EAAU,GACZN,IACFM,EAAQC,OAAS,CACfC,KAAM,sCACNC,UAAW,wBAGfH,EAAQI,SAAU,EAElBC,KAAK,CACHC,QAASV,EATTI,QAUAA,IACCO,MAAI,SAACC,GACN,GAAc,WAAVA,EACFhC,OAAOiC,IAAG,QACL,GAAID,EAAO,CAChBjC,IAAMmC,EAAWd,EAAIe,cAAc,eAAeC,aAAUC,EA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D,OAAOyD,kBACzCpC,SAASqC,KAAKC,YAAYb,KAG5B9C,SAAe,WAGO,oBAAT4D,MAAwBA,KAAKC,aAAe7D,OAAOiB,MAC5DjB,OAAOiC,OAIiB,gBAAxBZ,SAASyC,YAAwD,aAAxBzC,SAASyC,WACpD9D,OAAO+D,WAEPC,OAAOR,iBAAiB,oBAAkB,WAAK,OAAGxD,OAAO+D","file":"render.js","sourcesContent":["/* global page, swal */\n\nconst render = {\n lsKey: 'render',\n configs: {\n al: {\n name: 'ship waifu~',\n root: 'render/al/',\n // 001.png ~ 038.png\n array: Array.apply(null, { length: 38 }).map((_, i) => `${('00' + (i + 1)).slice(-3)}.png`)\n },\n miku: {\n name: 'miku ❤️~',\n root: 'render/miku/',\n // 001.png ~ 050.png\n array: Array.apply(null, { length: 50 }).map((_, i) => `${('00' + (i + 1)).slice(-3)}.png`)\n }\n },\n config: null,\n selected: null,\n done: false\n}\n\nrender.showTogglePrompt = () => {\n const renderEnabled = !(localStorage[render.lsKey] === '0')\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalRender\" type=\"checkbox\" ${renderEnabled ? 'checked' : ''}>\n Enable random render of ${render.config.name}\n </label>\n </div>\n <p class=\"help\">If disabled, you will still be able to see a small button on the bottom right corner of the screen to re-enable it.</p>\n </div>\n `\n\n const buttons = {}\n if (renderEnabled) {\n buttons.reload = {\n text: 'Nah fam, show me a different render',\n className: 'swal-button--cancel'\n }\n }\n buttons.confirm = true\n\n swal({\n content: div,\n buttons\n }).then(value => {\n if (value === 'reload') {\n render.do(true)\n } else if (value) {\n const newValue = div.querySelector('#swalRender').checked ? undefined : '0'\n if (newValue !== localStorage[render.lsKey]) {\n if (newValue) localStorage[render.lsKey] = newValue\n else localStorage.removeItem(render.lsKey)\n swal('', `Random render is now ${newValue ? 'disabled' : 'enabled'}.`, 'success', {\n buttons: false,\n timer: 1500\n })\n render.do()\n }\n }\n })\n}\n\nrender.parseSelectedConfig = () => {\n const renderScript = document.querySelector('#renderScript')\n if (renderScript && renderScript.dataset.config) return renderScript.dataset.config\n}\n\nrender.parseVersion = () => {\n const renderScript = document.querySelector('#renderScript')\n if (renderScript && renderScript.dataset.version) return `?v=${renderScript.dataset.version}`\n else return ''\n}\n\nrender.do = reload => {\n if (!render.done) render.done = true\n\n render.config = render.configs[render.parseSelectedConfig()]\n if (!render.config || !render.config.array.length) return\n\n const previousElement = document.querySelector('body > .render')\n if (previousElement) previousElement.remove()\n\n const doRender = () => {\n if (typeof render.version === 'undefined') {\n render.version = render.parseVersion()\n }\n\n // Let us just allow people to get new render when toggling the option\n render.selected = render.config.array[Math.floor(Math.random() * render.config.array.length)]\n element = document.createElement('img')\n element.alt = element.title = render.config.name\n element.className = 'is-hidden-mobile'\n element.src = `${render.config.root}${render.selected}${render.version}`\n }\n\n let element\n if (!reload && localStorage[render.lsKey] === '0') {\n element = document.createElement('a')\n element.className = 'button is-info is-hidden-mobile'\n element.title = render.config.name\n element.innerHTML = '<i class=\"icon-picture\"></i>'\n } else {\n doRender()\n }\n\n element.classList.add('render')\n element.addEventListener('click', render.showTogglePrompt)\n document.body.appendChild(element)\n}\n\nrender.onloaded = () => {\n // If the main script had already done its API check, yet render haven't been triggered, do it\n // This would only happen if this render script only gets loaded after the main script's API check\n if (typeof page !== 'undefined' && page.apiChecked && !render.done) {\n render.do()\n }\n}\n\nif (document.readyState === 'interactive' || document.readyState === 'complete') {\n render.onloaded()\n} else {\n window.addEventListener('DOMContentLoaded', () => render.onloaded())\n}\n"]} |