* 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:
Bobby Wibowo 2018-05-13 05:13:26 +07:00
parent 0cf8ff58d0
commit 369b1137a7
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
6 changed files with 88 additions and 82 deletions

View File

@ -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)

View File

@ -107,7 +107,12 @@
}
.uploads {
margin-bottom: .75rem;
padding-top: 1rem;
margin-bottom: 1rem;
}
.uploads.nojs {
margin-bottom: 0;
}
.uploads progress {

View File

@ -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')

View File

@ -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" %}

View File

@ -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>

View File

@ -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>