2018-10-18 13:26:40 +00:00
|
|
|
/* global page, swal */
|
|
|
|
|
|
|
|
page.renderRoot = 'render/al/'
|
|
|
|
page.renderArray = [
|
2019-03-27 20:33:38 +00:00
|
|
|
'admiral_graf_spee_1.png',
|
|
|
|
'admiral_hipper_1.png',
|
|
|
|
'akagi_1.png',
|
|
|
|
'akashi_1.png',
|
|
|
|
'akashi_2.png',
|
2018-10-18 13:26:40 +00:00
|
|
|
'atago_1.png',
|
2019-03-27 20:33:38 +00:00
|
|
|
'atago_3.png',
|
|
|
|
'atago_4.png',
|
|
|
|
'atago_5.png',
|
2018-10-18 13:26:40 +00:00
|
|
|
'belfast_2.png',
|
2019-03-27 20:33:38 +00:00
|
|
|
'choukai_1.png',
|
|
|
|
'deutschland_1.png',
|
|
|
|
'enterprise_1.png',
|
|
|
|
'glorious_1.png',
|
2018-10-18 13:26:40 +00:00
|
|
|
'hammann_1.png',
|
|
|
|
'hammann_2.png',
|
2019-03-27 20:33:38 +00:00
|
|
|
'hammann_3.png',
|
|
|
|
'hatsuharu_1.png',
|
2018-10-18 13:26:40 +00:00
|
|
|
'kaga_1.png',
|
2019-03-27 20:33:38 +00:00
|
|
|
'kaga_2.png',
|
|
|
|
'kaga_3.png',
|
2018-10-18 13:26:40 +00:00
|
|
|
'laffey_1.png',
|
2019-03-27 20:33:38 +00:00
|
|
|
'laffey_2.png',
|
|
|
|
'laffey_3.png',
|
|
|
|
'prinz_eugen_3.png',
|
|
|
|
'san_diego_1.png',
|
|
|
|
'takao_3.png',
|
2018-10-18 13:26:40 +00:00
|
|
|
'unicorn_1.png',
|
|
|
|
'unicorn_2.png',
|
|
|
|
'unicorn_3.png',
|
|
|
|
'unicorn_4.png',
|
2019-03-27 20:33:38 +00:00
|
|
|
'unicorn_6.png',
|
|
|
|
'unicorn_7.png',
|
|
|
|
'unicorn_8.png',
|
|
|
|
'yamashiro_1.png',
|
|
|
|
'yamashiro_2.png',
|
|
|
|
'yamashiro_3.png',
|
|
|
|
'yukikaze_1.png'
|
2018-10-18 13:26:40 +00:00
|
|
|
]
|
|
|
|
page.render = null
|
|
|
|
|
|
|
|
page.doRenderSwal = function () {
|
|
|
|
const div = document.createElement('div')
|
|
|
|
div.innerHTML = `
|
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
|
|
|
<label class="checkbox">
|
|
|
|
<input id="swalRender" type="checkbox" ${localStorage.render === '0' ? '' : 'checked'}>
|
|
|
|
Enable random render of ship waifu~
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
|
|
|
|
swal({
|
|
|
|
content: div,
|
|
|
|
buttons: {
|
|
|
|
confirm: true
|
|
|
|
}
|
|
|
|
}).then(function (value) {
|
2018-12-18 17:01:28 +00:00
|
|
|
if (!value) return
|
2018-10-18 13:34:05 +00:00
|
|
|
const newValue = div.querySelector('#swalRender').checked ? undefined : '0'
|
2018-10-18 13:26:40 +00:00
|
|
|
if (newValue !== localStorage.render) {
|
2018-10-18 13:34:05 +00:00
|
|
|
newValue ? localStorage.render = newValue : localStorage.removeItem('render')
|
|
|
|
swal('Success!', `Render is now ${newValue ? 'disabled' : 'enabled'}.`, 'success')
|
2018-10-18 13:26:40 +00:00
|
|
|
const element = document.querySelector('body > .render')
|
|
|
|
element.remove()
|
|
|
|
page.doRender()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-10-23 11:02:19 +00:00
|
|
|
page.getRenderVersion = function () {
|
|
|
|
const renderScript = document.getElementById('renderScript')
|
2019-01-14 12:44:09 +00:00
|
|
|
if (renderScript && renderScript.dataset.version)
|
|
|
|
return `?v=${renderScript.dataset.version}`
|
|
|
|
return ''
|
2018-10-23 11:02:19 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 13:26:40 +00:00
|
|
|
page.doRender = function () {
|
2018-12-18 17:01:28 +00:00
|
|
|
if (!page.renderRoot || !page.renderArray || !page.renderArray.length) return
|
2018-10-18 13:26:40 +00:00
|
|
|
|
|
|
|
let element
|
|
|
|
if (localStorage.render === '0') {
|
|
|
|
element = document.createElement('a')
|
|
|
|
element.className = 'button is-breeze is-hidden-mobile'
|
|
|
|
element.title = 'ship waifu~'
|
|
|
|
element.innerHTML = '<i class="icon-picture-1"></i>'
|
|
|
|
} else {
|
2018-10-23 11:02:19 +00:00
|
|
|
// Let us just allow people to get new render when toggling the option
|
|
|
|
page.render = page.renderArray[Math.floor(Math.random() * page.renderArray.length)]
|
2018-10-18 13:26:40 +00:00
|
|
|
element = document.createElement('img')
|
|
|
|
element.alt = element.title = 'ship waifu~'
|
|
|
|
element.className = 'is-hidden-mobile'
|
2018-10-23 11:02:19 +00:00
|
|
|
element.src = `${page.renderRoot}${page.render}${page.getRenderVersion()}`
|
2018-10-18 13:26:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
element.classList.add('render')
|
|
|
|
element.addEventListener('click', page.doRenderSwal)
|
|
|
|
document.body.appendChild(element)
|
|
|
|
}
|
|
|
|
|
|
|
|
page.doRender()
|