mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
Updates
* Some structure updates to the homepage and the No-JS uploader form. Making them both somewhat look better, especially in terms of spacing. * Upload URLs form will now show an error alert when there the form is empty or only filled with whitespaces. * Upload URLs form will now automatically remove empty lines or lines that consist of only whitespaces when the upload button is pressed.
This commit is contained in:
parent
0cf8ff58d0
commit
369b1137a7
@ -1,6 +1,6 @@
|
||||
# lolisafe, a small safe worth protecting
|
||||
|
||||
![safe.fiery.me](https://i.fiery.me/3zrP.png)
|
||||
![safe.fiery.me](https://i.fiery.me/hIty.png)
|
||||
|
||||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/WeebDev/lolisafe/master/LICENSE)
|
||||
[![Chat / Support](https://img.shields.io/badge/Chat%20%2F%20Support-discord-7289DA.svg?style=flat-square)](https://discord.gg/5g6vgwn)
|
||||
|
@ -107,7 +107,12 @@
|
||||
}
|
||||
|
||||
.uploads {
|
||||
margin-bottom: .75rem;
|
||||
padding-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.uploads.nojs {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.uploads progress {
|
||||
|
@ -252,6 +252,7 @@ page.prepareDropzone = () => {
|
||||
})
|
||||
|
||||
page.dropzone.on('addedfile', file => {
|
||||
tabDiv.getElementsByClassName('uploads')[0].style.display = 'block'
|
||||
file.previewElement.querySelector('.name').innerHTML = file.name
|
||||
})
|
||||
|
||||
@ -298,11 +299,21 @@ page.uploadUrls = async button => {
|
||||
if (button.classList.contains('is-loading')) { return }
|
||||
button.classList.add('is-loading')
|
||||
|
||||
const albumid = page.album
|
||||
const previewsContainer = tabDiv.getElementsByClassName('uploads')[0]
|
||||
const files = document.getElementById('urls').value
|
||||
.split(/\r?\n/)
|
||||
.map(url => {
|
||||
await new Promise(async (resolve, reject) => {
|
||||
const albumid = page.album
|
||||
const previewsContainer = tabDiv.getElementsByClassName('uploads')[0]
|
||||
const urls = document.getElementById('urls').value
|
||||
.split(/\r?\n/)
|
||||
.filter(url => url.trim().length)
|
||||
document.getElementById('urls').value = urls.join('\n')
|
||||
|
||||
if (!urls.length) {
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
return reject('You have not entered any URLs.')
|
||||
}
|
||||
|
||||
tabDiv.getElementsByClassName('uploads')[0].style.display = 'block'
|
||||
const files = urls.map(url => {
|
||||
const previewTemplate = document.createElement('template')
|
||||
previewTemplate.innerHTML = page.previewTemplate.trim()
|
||||
const previewElement = previewTemplate.content.firstChild
|
||||
@ -314,7 +325,6 @@ page.uploadUrls = async button => {
|
||||
}
|
||||
})
|
||||
|
||||
await new Promise(resolve => {
|
||||
const post = async i => {
|
||||
if (i === files.length) { return resolve() }
|
||||
const file = files[i]
|
||||
@ -345,6 +355,8 @@ page.uploadUrls = async button => {
|
||||
post(i + 1)
|
||||
}
|
||||
post(0)
|
||||
}).catch(error => {
|
||||
swal('An error occurred!', error.toString(), 'error')
|
||||
})
|
||||
|
||||
button.classList.remove('is-loading')
|
||||
|
@ -13,7 +13,7 @@
|
||||
v2: Images and config files (manifest.json, browserconfig.xml, etc).
|
||||
v3: CSS and JS files (libs such as bulma, lazyload, etc).
|
||||
#}
|
||||
{% set v1 = "HrvcYD3KTh" %}
|
||||
{% set v1 = "dSRVE9qwPF" %}
|
||||
{% set v2 = "Ii3JYKIhb0" %}
|
||||
{% set v3 = "HrvcYD3KTh" %}
|
||||
|
||||
|
@ -46,41 +46,39 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
{% if urlMaxSize -%}
|
||||
<div id="tabs" class="tabs is-centered" style="display: none">
|
||||
<ul>
|
||||
<li data-id="tab-files" class="is-active"><a>Files</a></li>
|
||||
<li data-id="tab-urls"><a>URLs</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{%- endif %}
|
||||
<div id="tab-files" class="tab-content" style="display: none">
|
||||
<div class="field dz-container"></div>
|
||||
<div class="field uploads"></div>
|
||||
</div>
|
||||
{% if urlMaxSize -%}
|
||||
<div id="tab-urls" class="tab-content" style="display: none">
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<textarea id="urls" class="textarea" rows="2"></textarea>
|
||||
</div>
|
||||
<p class="help">Maximum file size for URL upload is {{ urlMaxSize }}.</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control is-expanded">
|
||||
<a id="uploadUrls" class="button is-danger is-fullwidth is-unselectable">
|
||||
<span class="icon">
|
||||
<i class="icon-upload-cloud"></i>
|
||||
</span>
|
||||
<span>Upload URLs</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field uploads"></div>
|
||||
</div>
|
||||
{%- endif %}
|
||||
{% if urlMaxSize -%}
|
||||
<div id="tabs" class="tabs is-centered" style="display: none">
|
||||
<ul>
|
||||
<li data-id="tab-files" class="is-active"><a>Files</a></li>
|
||||
<li data-id="tab-urls"><a>URLs</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{%- endif %}
|
||||
<div id="tab-files" class="tab-content" style="display: none">
|
||||
<div class="field dz-container"></div>
|
||||
<div class="field uploads" style="display: none"></div>
|
||||
</div>
|
||||
{% if urlMaxSize -%}
|
||||
<div id="tab-urls" class="tab-content" style="display: none">
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<textarea id="urls" class="textarea" rows="2"></textarea>
|
||||
</div>
|
||||
<p class="help">Maximum file size for URL upload is {{ urlMaxSize }}.</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control is-expanded">
|
||||
<a id="uploadUrls" class="button is-danger is-fullwidth is-unselectable">
|
||||
<span class="icon">
|
||||
<i class="icon-upload-cloud"></i>
|
||||
</span>
|
||||
<span>Upload URLs</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field uploads" style="display: none"></div>
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
</div>
|
||||
|
@ -23,50 +23,41 @@
|
||||
<div class="columns is-gapless">
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
<div class="column">
|
||||
<div class="content">
|
||||
<p class="subtitle" style="font-size: 1rem">
|
||||
Files uploaded through this No-JS uploader will not be associated to your account, if you have any.
|
||||
</p>
|
||||
</div>
|
||||
<div class="content">
|
||||
{% if renderOptions.uploadDisabled -%}
|
||||
<a class="button is-danger" style="display: flex" href="auth">{{ renderOptions.uploadDisabled }}</a>
|
||||
{%- else -%}
|
||||
<form id="form" action="" method="post" enctype="multipart/form-data">
|
||||
<div class="field">
|
||||
<input type="file" name="files[]" multiple="multiple" style="width: 100%">
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" class="button is-danger" value="Upload" style="width: 100%">
|
||||
</div>
|
||||
</form>
|
||||
{%- endif %}
|
||||
<p class="subtitle" style="font-size: 1rem">
|
||||
Files uploaded through this No-JS uploader will not be associated to your account, if you have any.
|
||||
</p>
|
||||
{% if renderOptions.uploadDisabled -%}
|
||||
<a class="button is-danger" style="display: flex" href="auth">{{ renderOptions.uploadDisabled }}</a>
|
||||
{%- else -%}
|
||||
<form id="form" class="field" action="" method="post" enctype="multipart/form-data">
|
||||
<div class="field">
|
||||
<input type="file" name="files[]" multiple="multiple" style="width: 100%">
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" class="button is-danger" value="Upload" style="width: 100%">
|
||||
</div>
|
||||
</form>
|
||||
{%- endif %}
|
||||
{% if files -%}
|
||||
<div class="field uploads nojs">
|
||||
{% for file in files -%}
|
||||
<div class="field">
|
||||
{% if errorMessage -%}
|
||||
<p class="error">{{ errorMessage | safe }}</p>
|
||||
{%- endif %}
|
||||
{% if file.url -%}
|
||||
<p class="link">
|
||||
<a href="{{ file.url }}" target="_blank" rel="noopener">{{ file.url | safe }}</a>
|
||||
</p>
|
||||
{%- endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
</div>
|
||||
|
||||
{% if files -%}
|
||||
<div id="uploads" style="display: block">
|
||||
{% for file in files -%}
|
||||
<div class="columns">
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
<div class="column">
|
||||
{% if errorMessage -%}
|
||||
<p class="error">{{ errorMessage | safe }}</p>
|
||||
{%- endif %}
|
||||
{% if file.url -%}
|
||||
<p class="link">
|
||||
<a href="{{ file.url }}" target="_blank" rel="noopener">{{ file.url | safe }}</a>
|
||||
</p>
|
||||
{%- endif %}
|
||||
</div>
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
{% set plain_links = true %}
|
||||
{% include "_partial/links.njk" %}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user