mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
Added floating home button to auth page
Moved floating home button codes to views/_partial/floating-home.njk. Added some variables support into some partial NJK files. album.njk now uses partial versions for noscript codes. A few other things. Bumped v1 version string and rebuilt client assets.
This commit is contained in:
parent
4c2157e7d2
commit
36a41c9711
2
dist/js/auth.js
vendored
2
dist/js/auth.js
vendored
@ -1,2 +1,2 @@
|
||||
var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],user:null,pass:null,unhide:function(){document.querySelector("#loader").classList.add("is-hidden"),document.querySelector("#login").classList.remove("is-hidden")},onAxiosError:function(e){console.error(e);var r={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,o=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+r,o,"error")},do:function(e,r){var o=page.user.value.trim();if(!o)return swal("An error occurred!","You need to specify a username.","error");var n=page.pass.value.trim();if(!n)return swal("An error occurred!","You need to specify a password.","error");r.classList.add("is-loading"),axios.post("api/"+e,{username:o,password:n}).then((function(o){if(!1===o.data.success)return r.classList.remove("is-loading"),swal("Unable to "+e+"!",o.data.description,"error");localStorage.token=o.data.token,window.location="dashboard"})).catch((function(e){r.classList.remove("is-loading"),page.onAxiosError(e)}))},verify:function(){axios.post("api/tokens/verify",{token:page.token}).then((function(e){if(!1===e.data.success)return page.unhide(),swal("An error occurred!",e.data.description,"error");window.location="dashboard"})).catch((function(e){page.unhide(),page.onAxiosError(e)}))}};window.onload=function(){page.user=document.querySelector("#user"),page.pass=document.querySelector("#pass");var e=document.querySelector("#authForm");e.addEventListener("submit",(function(e){e.preventDefault()}));var r=document.querySelector("#loginBtn");r&&r.addEventListener("click",(function(r){e.checkValidity()&&page.do("login",r.currentTarget)}));var o=document.querySelector("#registerBtn");o&&o.addEventListener("click",(function(r){e.checkValidity()&&page.do("register",r.currentTarget)})),page.token?page.verify():page.unhide()};
|
||||
var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],user:null,pass:null,unhide:function(){var e=document.querySelector("#loader");e&&e.classList.add("is-hidden");var r=document.querySelector("#login.is-hidden");r&&r.classList.remove("is-hidden");var o=document.querySelector(".floating-home-button.is-hidden");o&&o.classList.remove("is-hidden")},onAxiosError:function(e){console.error(e);var r={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,o=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+r,o,"error")},do:function(e,r){var o=page.user.value.trim();if(!o)return swal("An error occurred!","You need to specify a username.","error");var n=page.pass.value.trim();if(!n)return swal("An error occurred!","You need to specify a password.","error");r.classList.add("is-loading"),axios.post("api/"+e,{username:o,password:n}).then((function(o){if(!1===o.data.success)return r.classList.remove("is-loading"),swal("Unable to "+e+"!",o.data.description,"error");localStorage.token=o.data.token,window.location="dashboard"})).catch((function(e){r.classList.remove("is-loading"),page.onAxiosError(e)}))},verify:function(){axios.post("api/tokens/verify",{token:page.token}).then((function(e){if(!1===e.data.success)return page.unhide(),swal("An error occurred!",e.data.description,"error");window.location="dashboard"})).catch((function(e){page.unhide(),page.onAxiosError(e)}))}};window.onload=function(){page.user=document.querySelector("#user"),page.pass=document.querySelector("#pass");var e=document.querySelector("#authForm");e.addEventListener("submit",(function(e){e.preventDefault()}));var r=document.querySelector("#loginBtn");r&&r.addEventListener("click",(function(r){e.checkValidity()&&page.do("login",r.currentTarget)}));var o=document.querySelector("#registerBtn");o&&o.addEventListener("click",(function(r){e.checkValidity()&&page.do("register",r.currentTarget)})),page.token?page.verify():page.unhide()};
|
||||
//# sourceMappingURL=auth.js.map
|
||||
|
2
dist/js/auth.js.map
vendored
2
dist/js/auth.js.map
vendored
File diff suppressed because one or more lines are too long
@ -14,8 +14,17 @@ const page = {
|
||||
}
|
||||
|
||||
page.unhide = () => {
|
||||
document.querySelector('#loader').classList.add('is-hidden')
|
||||
document.querySelector('#login').classList.remove('is-hidden')
|
||||
const loaderSection = document.querySelector('#loader')
|
||||
if (loaderSection)
|
||||
loaderSection.classList.add('is-hidden')
|
||||
|
||||
const loginSection = document.querySelector('#login.is-hidden')
|
||||
if (loginSection)
|
||||
loginSection.classList.remove('is-hidden')
|
||||
|
||||
const floatingBtn = document.querySelector('.floating-home-button.is-hidden')
|
||||
if (floatingBtn)
|
||||
floatingBtn.classList.remove('is-hidden')
|
||||
}
|
||||
|
||||
// Handler for Axios errors
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"1": "1590437259",
|
||||
"1": "1590439689",
|
||||
"2": "1589010026",
|
||||
"3": "1581416390",
|
||||
"4": "1581416390",
|
||||
|
5
views/_partial/floating-home.njk
Normal file
5
views/_partial/floating-home.njk
Normal file
@ -0,0 +1,5 @@
|
||||
<a class="floating-home-button{{ ' is-hidden' if floatingHomeHideInitially }}" title="Back to Safe" href="{{ floatingHomeHref or '.' }}">
|
||||
<span class="icon is-medium">
|
||||
<i class="icon-home icon-2x"></i>
|
||||
</span>
|
||||
</a>
|
@ -6,5 +6,5 @@
|
||||
<noscript>
|
||||
<style>body > section:not(#noscript) { display: none !important; }</style>
|
||||
<!-- Redirect after 3 seconds -->
|
||||
<meta http-equiv="refresh" content="3;url=nojs">
|
||||
<meta http-equiv="refresh" content="3;url={{ noscriptRefreshUrl or 'nojs' }}">
|
||||
</noscript>
|
||||
|
@ -3,7 +3,13 @@
|
||||
<div class="hero-body">
|
||||
<div class="container has-text-centered">
|
||||
<p>This page requires JavaScript to function.</p>
|
||||
<p>If you are not redirected to the No-JS uploader, please <a href="nojs">click here</a>.</p>
|
||||
<p>
|
||||
{%- if noscriptMessage -%}
|
||||
{{ noscriptMessage | safe }}
|
||||
{%- else -%}
|
||||
If you are not redirected to the No-JS uploader, please <a href="nojs">click here</a>.
|
||||
{%- endif -%}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
||||
{% set noJsUrl = '../' + album.url + '?nojs' %}
|
||||
{% set generateZips = config.uploads.generateZips %}
|
||||
{% set usingCdn = config.cloudflare and config.cloudflare.purgeCache %}
|
||||
|
||||
@ -27,16 +28,13 @@
|
||||
<script src="../libs/lazyload/lazyload.min.js{{ versions[3] }}"></script>
|
||||
<script src="../js/album.js{{ versions[1] }}"></script>
|
||||
<script src="../js/misc/utils.js{{ versions[1] }}"></script>
|
||||
{% endif %}
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block endmeta %}
|
||||
{% if not nojs -%}
|
||||
<noscript>
|
||||
<style>body > section:not(#noscript) { display: none !important; }</style>
|
||||
<!-- Redirect after 3 seconds -->
|
||||
<meta http-equiv="refresh" content="3;url=../{{ album.url }}?nojs">
|
||||
</noscript>
|
||||
{% set noscriptRefreshUrl = noJsUrl %}
|
||||
{% include "_partial/noscript-refresh.njk" %}
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
||||
@ -105,7 +103,7 @@
|
||||
<img alt="{{ file.name }}" data-src="{{ fileRoot }}/{{ file.thumb }}">
|
||||
{%- endif %}
|
||||
{%- else -%}
|
||||
<h1 class="title">{{ file.extname | default('N/A') }}</h1>
|
||||
<h1 class="title">{{ file.extname or 'N/A' }}</h1>
|
||||
{%- endif %}
|
||||
</a>
|
||||
<div class="details">
|
||||
@ -125,22 +123,10 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a class="floating-home-button" title="Back to Safe" href="..">
|
||||
<span class="icon is-medium">
|
||||
<i class="icon-home icon-2x"></i>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
{% set floatingHomeHref = '..' %}
|
||||
{% include "_partial/floating-home.njk" %}
|
||||
{% if not nojs -%}
|
||||
<noscript>
|
||||
<section id="noscript" class="hero is-fullheight">
|
||||
<div class="hero-body">
|
||||
<div class="container has-text-centered">
|
||||
<p>This page requires JavaScript to function.</p>
|
||||
<p>If you are not redirected to its No-JS version, please <a href="../{{ album.url }}?nojs">click here</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</noscript>
|
||||
{% set noscriptMessage = 'If you are not redirected to its No-JS version, please <a href="' + noJsUrl + '">click here</a>.' %}
|
||||
{% include "_partial/noscript.njk" %}
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
@ -78,5 +78,7 @@
|
||||
</section>
|
||||
|
||||
{% include "_partial/loader.njk" %}
|
||||
{% set floatingHomeHideInitially = true %}
|
||||
{% include "_partial/floating-home.njk" %}
|
||||
{% include "_partial/noscript.njk" %}
|
||||
{% endblock %}
|
||||
|
@ -199,9 +199,5 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a class="floating-home-button" title="Back to Safe" href=".">
|
||||
<span class="icon is-medium">
|
||||
<i class="icon-home icon-2x"></i>
|
||||
</span>
|
||||
</a>
|
||||
{% include "_partial/floating-home.njk" %}
|
||||
{% endblock %}
|
||||
|
@ -284,9 +284,5 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a class="floating-home-button" title="Back to Safe" href=".">
|
||||
<span class="icon is-medium">
|
||||
<i class="icon-home icon-2x"></i>
|
||||
</span>
|
||||
</a>
|
||||
{% include "_partial/floating-home.njk" %}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user