diff --git a/.gitignore b/.gitignore index 2f20378..49c916d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ migrate.js yarn.lock yarn-error.log package-lock.json +public/render/**/original diff --git a/public/css/style.css b/public/css/style.css index 1dbbce6..620e5ad 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -23,6 +23,10 @@ a { color: #3794d2; } +a.is-dotted { + border-bottom: 1px dotted #3794d2; +} + a:hover { color: #60a8dc; } @@ -96,3 +100,24 @@ hr { border-color: transparent; color: #fff; } + +.render { + position: fixed; + right: 0; + bottom: 0; + font-size: 1rem; + color: #bdc3c7; + cursor: pointer; +} + +.render.button { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + right: 1%; + opacity: .25; + transition: opacity .25s; +} + +.render.button:hover { + opacity: 1; +} diff --git a/public/css/sweetalert.css b/public/css/sweetalert.css index aa7cb35..a72891a 100644 --- a/public/css/sweetalert.css +++ b/public/css/sweetalert.css @@ -2,11 +2,19 @@ background-color: #31363b; } +.swal-modal .field { + text-align: initial; +} + .swal-title, .swal-text { color: #eff0f1; } +.swal-text { + text-align: center; +} + .swal-content .label, .swal-content .checkbox, .swal-content .radio { diff --git a/public/js/dashboard.js b/public/js/dashboard.js index 333bfff..a8303e6 100644 --- a/public/js/dashboard.js +++ b/public/js/dashboard.js @@ -65,6 +65,8 @@ const page = { clipboardJS: null, lazyLoad: null, + imageExtensions: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png'], + // byte units for getPrettyBytes() byteUnits: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] } @@ -360,6 +362,12 @@ page.getUploads = function ({ album, pageNum, all } = {}, element) { const selected = page.selected.uploads.includes(upload.id) if (!selected && allSelected) { allSelected = false } + page.cache.uploads[upload.id] = { + name: upload.name, + thumb: upload.thumb, + original: upload.file + } + // Prettify upload.prettyBytes = page.getPrettyBytes(parseInt(upload.size)) upload.prettyDate = page.getPrettyDate(new Date(upload.timestamp * 1000)) @@ -379,6 +387,11 @@ page.getUploads = function ({ album, pageNum, all } = {}, element) { div.innerHTML += `
+ + + + + @@ -443,7 +456,8 @@ page.getUploads = function ({ album, pageNum, all } = {}, element) { page.cache.uploads[upload.id] = { name: upload.name, - thumb: upload.thumb + thumb: upload.thumb, + original: upload.file } // Prettify @@ -516,13 +530,57 @@ page.setUploadsView = function (view, element) { page.displayThumbnail = function (id) { const file = page.cache.uploads[id] if (!file.thumb) { return } + + const div = document.createElement('div') + div.innerHTML = ` +
+ +
+ +
+
+ ` + if (file.original) { + div.innerHTML += ` +
+ +
+ ` + div.querySelector('#swalOriginal').addEventListener('click', function () { + const button = this + const original = button.dataset.original + button.classList.add('is-loading') + + const thumb = div.querySelector('#swalThumb') + const exec = /.[\w]+(\?|$)/.exec(original) + const isimage = exec && exec[0] && page.imageExtensions.includes(exec[0].toLowerCase()) + + if (isimage) { + thumb.src = file.original + thumb.onload = function () { button.style.display = 'none' } + } else { + thumb.style.display = 'none' + const video = document.createElement('video') + video.id = 'swalVideo' + video.controls = true + video.src = file.original + thumb.insertAdjacentElement('afterend', video) + button.style.display = 'none' + } + + // Resize currently visible modal + document.body.querySelector('.swal-overlay--show-modal .swal-modal').style = 'width: auto; max-width: 90%;' + }) + } + return swal({ - text: file.name, - content: { - element: 'img', - attributes: { src: file.thumb } - }, - button: true + content: div, + buttons: false + }).then(function () { + const video = div.querySelector('#swalVideo') + if (video) { video.remove() } }) } @@ -845,9 +903,11 @@ page.addFilesToAlbum = function (ids, callback) { const content = document.createElement('div') content.innerHTML = ` -

You are about to add ${count} file${count === 1 ? '' : 's'} to an album.

+
+

You are about to add ${count} file${count === 1 ? '' : 's'} to an album.

+

If a file is already in an album, it will be moved.

+
-
+ Enable random render of ship waifu~ + +
+

If disabled, you will still be able to see a small button on the bottom right corner of the screen to re-enable it.

+
+ ` + + swal({ + content: div, + buttons: { + confirm: true + } + }).then(function (value) { + if (!value) { return } + const newValue = div.querySelector('#swalRender').checked ? '1' : '0' + if (newValue !== localStorage.render) { + localStorage.render = newValue + swal('Success!', `Render is now ${newValue === '1' ? 'enabled' : 'disabled'}.`, 'success') + const element = document.querySelector('body > .render') + element.remove() + page.doRender() + } + }) +} + +page.doRender = function () { + if (!page.renderRoot || !page.renderArray || !page.renderArray.length) { return } + if (localStorage.render === undefined) { localStorage.render = '1' } + + let element + if (localStorage.render === '0') { + element = document.createElement('a') + element.className = 'button is-breeze is-hidden-mobile' + element.title = 'ship waifu~' + element.innerHTML = '' + } else { + if (!page.render) { + page.render = page.renderArray[Math.floor(Math.random() * page.renderArray.length)] + } + element = document.createElement('img') + element.alt = element.title = 'ship waifu~' + element.className = 'is-hidden-mobile' + element.src = `${page.renderRoot}${page.render}` + } + + element.classList.add('render') + element.addEventListener('click', page.doRenderSwal) + document.body.appendChild(element) +} + +page.doRender() diff --git a/public/libs/lazyload/lazyload.min.js b/public/libs/lazyload/lazyload.min.js index 897f1ad..c493598 100755 --- a/public/libs/lazyload/lazyload.min.js +++ b/public/libs/lazyload/lazyload.min.js @@ -1 +1 @@ -/*! lazyload v10.5.2 | Copyright (c) 2015 Andrea Verlicchi */var _extends=Object.assign||function(e){for(var t=1;t-1&&(v(e,t),u(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),f(t.callback_set,e)},p=function(e){return e.isIntersecting||e.intersectionRatio>0},h=function(t,n){this._settings=e(t),this._setObserver(),this.update(n)};h.prototype={_setObserver:function(){var e=this;if(c){var t=this._settings,n={root:t.container===document?null:t.container,rootMargin:t.threshold+"px"};this._observer=new IntersectionObserver(function(t){t.forEach(function(t){if(p(t)){var n=t.target;b(n,e._settings),e._observer.unobserve(n)}}),e._elements=r(e._elements)},n)}},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){b(e,n)}),this._elements=r(this._elements))},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var y=window.lazyLoadOptions;return i&&y&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(h,y),h}); +/*! lazyload v10.19.0 | Copyright (c) 2015 Andrea Verlicchi */var _extends=Object.assign||function(t){for(var e=1;e-1&&(N(t,e),I(t,o.class_loading)),E(t,e),a(t),C(o.callback_set,t))}var e={elements_selector:"img",container:document,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,callback_load:null,callback_error:null,callback_set:null,callback_enter:null,callback_finish:null,to_webp:!1},n=function(t){return _extends({},e,t)},o=function(t,e){return t.getAttribute("data-"+e)},r=function(t,e,n){var o="data-"+e;null!==n?t.setAttribute(o,n):t.removeAttribute(o)},a=function(t){return r(t,"was-processed","true")},i=function(t){return"true"===o(t,"was-processed")},s=function(t,e){return r(t,"ll-timeout",e)},c=function(t){return o(t,"ll-timeout")},l=function(t){return t.filter(function(t){return!i(t)})},u=function(t,e){return t.filter(function(t){return t!==e})},d=function(t,e){var n,o=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},f=function(t,e){return e?t.replace(/\.(jpe?g|png)/gi,".webp"):t},_="undefined"!=typeof window,v=_&&!("onscroll"in window)||/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),g=_&&"IntersectionObserver"in window,h=_&&"classList"in document.createElement("p"),b=_&&function(){var t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))&&0===t.toDataURL("image/webp").indexOf("data:image/webp")}(),m=function(t,e,n,r){for(var a,i=0;a=t.children[i];i+=1)if("SOURCE"===a.tagName){var s=o(a,n);p(a,e,s,r)}},p=function(t,e,n,o){n&&t.setAttribute(e,f(n,o))},y=function(t,e){var n=b&&e.to_webp,r=o(t,e.data_src),a=o(t,e.data_bg);if(r){var i=f(r,n);t.style.backgroundImage='url("'+i+'")'}if(a){var s=f(a,n);t.style.backgroundImage=s}},w={IMG:function(t,e){var n=b&&e.to_webp,r=e.data_srcset,a=t.parentNode;a&&"PICTURE"===a.tagName&&m(a,"srcset",r,n);var i=o(t,e.data_sizes);p(t,"sizes",i);var s=o(t,r);p(t,"srcset",s,n);var c=o(t,e.data_src);p(t,"src",c,n)},IFRAME:function(t,e){var n=o(t,e.data_src);p(t,"src",n)},VIDEO:function(t,e){var n=e.data_src,r=o(t,n);m(t,"src",n),p(t,"src",r),t.load()}},E=function(t,e){var n=e._settings,o=t.tagName,r=w[o];if(r)return r(t,n),e._updateLoadingCount(1),void(e._elements=u(e._elements,t));y(t,n)},I=function(t,e){h?t.classList.add(e):t.className+=(t.className?" ":"")+e},L=function(t,e){h?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},C=function(t,e){t&&t(e)},O=function(t,e,n){t.addEventListener(e,n)},k=function(t,e,n){t.removeEventListener(e,n)},x=function(t,e,n){O(t,"load",e),O(t,"loadeddata",e),O(t,"error",n)},A=function(t,e,n){k(t,"load",e),k(t,"loadeddata",e),k(t,"error",n)},z=function(t,e,n){var o=n._settings,r=e?o.class_loaded:o.class_error,a=e?o.callback_load:o.callback_error,i=t.target;L(i,o.class_loading),I(i,r),C(a,i),n._updateLoadingCount(-1)},N=function(t,e){var n=function n(r){z(r,!0,e),A(t,n,o)},o=function o(r){z(r,!1,e),A(t,n,o)};x(t,n,o)},R=["IMG","IFRAME","VIDEO"],S=function(e,n,o){t(e,o),n.unobserve(e)},M=function(t){var e=c(t);e&&(clearTimeout(e),s(t,null))},j=function(t,e,n){var o=n._settings.load_delay,r=c(t);r||(r=setTimeout(function(){S(t,e,n),M(t)},o),s(t,r))},D=function(t){return t.isIntersecting||t.intersectionRatio>0},T=function(t){return{root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}},U=function(t,e){this._settings=n(t),this._setObserver(),this._loadingCount=0,this.update(e)};return U.prototype={_manageIntersection:function(t){var e=this._observer,n=this._settings.load_delay,o=t.target;n?D(t)?j(o,e,this):M(o):D(t)&&S(o,e,this)},_onIntersection:function(t){t.forEach(this._manageIntersection.bind(this))},_setObserver:function(){g&&(this._observer=new IntersectionObserver(this._onIntersection.bind(this),T(this._settings)))},_updateLoadingCount:function(t){this._loadingCount+=t,0===this._elements.length&&0===this._loadingCount&&C(this._settings.callback_finish)},update:function(t){var e=this,n=this._settings,o=t||n.container.querySelectorAll(n.elements_selector);this._elements=l(Array.prototype.slice.call(o)),!v&&this._observer?this._elements.forEach(function(t){e._observer.observe(t)}):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(e,n){t(e,this,n)},loadAll:function(){var t=this;this._elements.forEach(function(e){t.load(e)})}},_&&function(t,e){if(e)if(e.length)for(var n,o=0;n=e[o];o+=1)d(t,n);else d(t,e)}(U,window.lazyLoadOptions),U}); diff --git a/public/render/al/atago_1.png b/public/render/al/atago_1.png new file mode 100644 index 0000000..4236e41 Binary files /dev/null and b/public/render/al/atago_1.png differ diff --git a/public/render/al/atago_2.png b/public/render/al/atago_2.png new file mode 100644 index 0000000..62f54c1 Binary files /dev/null and b/public/render/al/atago_2.png differ diff --git a/public/render/al/belfast_1.png b/public/render/al/belfast_1.png new file mode 100644 index 0000000..e6d8a42 Binary files /dev/null and b/public/render/al/belfast_1.png differ diff --git a/public/render/al/belfast_2.png b/public/render/al/belfast_2.png new file mode 100644 index 0000000..5a161c7 Binary files /dev/null and b/public/render/al/belfast_2.png differ diff --git a/public/render/al/belfast_3.png b/public/render/al/belfast_3.png new file mode 100644 index 0000000..f90aa51 Binary files /dev/null and b/public/render/al/belfast_3.png differ diff --git a/public/render/al/eldridge_1.png b/public/render/al/eldridge_1.png new file mode 100644 index 0000000..8c05662 Binary files /dev/null and b/public/render/al/eldridge_1.png differ diff --git a/public/render/al/hammann_1.png b/public/render/al/hammann_1.png new file mode 100644 index 0000000..144f70b Binary files /dev/null and b/public/render/al/hammann_1.png differ diff --git a/public/render/al/hammann_2.png b/public/render/al/hammann_2.png new file mode 100644 index 0000000..f264f1f Binary files /dev/null and b/public/render/al/hammann_2.png differ diff --git a/public/render/al/javelin_1.png b/public/render/al/javelin_1.png new file mode 100644 index 0000000..8801ebb Binary files /dev/null and b/public/render/al/javelin_1.png differ diff --git a/public/render/al/kaga_1.png b/public/render/al/kaga_1.png new file mode 100644 index 0000000..8224edb Binary files /dev/null and b/public/render/al/kaga_1.png differ diff --git a/public/render/al/laffey_1.png b/public/render/al/laffey_1.png new file mode 100644 index 0000000..22390b2 Binary files /dev/null and b/public/render/al/laffey_1.png differ diff --git a/public/render/al/prinz_eugen_1.png b/public/render/al/prinz_eugen_1.png new file mode 100644 index 0000000..b242b1f Binary files /dev/null and b/public/render/al/prinz_eugen_1.png differ diff --git a/public/render/al/prinz_eugen_2.png b/public/render/al/prinz_eugen_2.png new file mode 100644 index 0000000..b4eb619 Binary files /dev/null and b/public/render/al/prinz_eugen_2.png differ diff --git a/public/render/al/takao_1.png b/public/render/al/takao_1.png new file mode 100644 index 0000000..592da7f Binary files /dev/null and b/public/render/al/takao_1.png differ diff --git a/public/render/al/takao_2.png b/public/render/al/takao_2.png new file mode 100644 index 0000000..231e1d2 Binary files /dev/null and b/public/render/al/takao_2.png differ diff --git a/public/render/al/unicorn_1.png b/public/render/al/unicorn_1.png new file mode 100644 index 0000000..ab9b3d9 Binary files /dev/null and b/public/render/al/unicorn_1.png differ diff --git a/public/render/al/unicorn_2.png b/public/render/al/unicorn_2.png new file mode 100644 index 0000000..a081bb2 Binary files /dev/null and b/public/render/al/unicorn_2.png differ diff --git a/public/render/al/unicorn_3.png b/public/render/al/unicorn_3.png new file mode 100644 index 0000000..120f37f Binary files /dev/null and b/public/render/al/unicorn_3.png differ diff --git a/public/render/al/unicorn_4.png b/public/render/al/unicorn_4.png new file mode 100644 index 0000000..851743f Binary files /dev/null and b/public/render/al/unicorn_4.png differ diff --git a/public/render/al/unicorn_5.png b/public/render/al/unicorn_5.png new file mode 100644 index 0000000..8472cc3 Binary files /dev/null and b/public/render/al/unicorn_5.png differ diff --git a/public/render/al/yamashiro_1.png b/public/render/al/yamashiro_1.png new file mode 100644 index 0000000..1c7ba69 Binary files /dev/null and b/public/render/al/yamashiro_1.png differ diff --git a/views/_globals.njk b/views/_globals.njk index fef6f03..64f01e2 100644 --- a/views/_globals.njk +++ b/views/_globals.njk @@ -15,9 +15,9 @@ v2: Images and config files (manifest.json, browserconfig.xml, etc). v3: CSS and JS files (libs such as bulma, lazyload, etc). #} -{% set v1 = "6SjzrVGxcS" %} +{% set v1 = "6MfcbDZldp" %} {% set v2 = "Ii3JYKIhb0" %} -{% set v3 = "4TRCinLWfk" %} +{% set v3 = "6MfcbDZldp" %} {# These will be the links in the homepage and the No-JS uploader. diff --git a/views/home.njk b/views/home.njk index f5c786b..c771aa3 100644 --- a/views/home.njk +++ b/views/home.njk @@ -23,6 +23,7 @@ + {% endblock %} {% block content %} @@ -126,7 +127,7 @@ {% include "_partial/links.njk" %} {% if gitHash -%} -

Git commit: {{ gitHash }}

+

Git commit: {{ gitHash }}

{%- endif %}