1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

Fix notifications and 404 history cleaning

This commit is contained in:
ksamuel 2020-08-12 16:08:19 +02:00
parent e5faaac077
commit 92251432bd
3 changed files with 39 additions and 29 deletions

View File

@ -102,7 +102,7 @@ const app = new Vue({
app.isUploading = true;
zerobin.upload(files);
} catch (e) {
zerobin.message('error', 'Could no upload the file', 'Error');
zerobin.message('danger', 'Could no upload the file', 'Error');
}
app.isUploading = false;
},
@ -136,14 +136,14 @@ const app = new Vue({
form.forEach((node) => node.disabled = false);
app.isLoading = false
zerobin.message(
'error',
'danger',
'Paste could not be deleted. Please try again later.',
'Error');
}
app.isLoading = false;
}).catch(function (error) {
zerobin.message(
'error',
'danger',
'Paste could not be delete. Please try again later.',
'Error');
app.isLoading = false;
@ -157,9 +157,9 @@ const app = new Vue({
let promise = navigator.clipboard.writeText(pasteContent);
promise.then(function () {
zerobin.message('info', 'The paste is now in your clipboard', '', true);
zerobin.message('primary', 'The paste is now in your clipboard', '', true);
}, function (err) {
zerobin.message('error', 'The paste could not be copied', '', true);
zerobin.message('danger', 'The paste could not be copied', '', true);
});
},
@ -216,7 +216,7 @@ const app = new Vue({
if (oversized) {
app.isLoading = false
form.forEach((node) => node.disabled = false);
zerobin.message('error', ('The encrypted file was <strong class="file-size">' + readableFsize +
zerobin.message('danger', ('The encrypted file was <strong class="file-size">' + readableFsize +
'</strong>KB. You have reached the maximum size limit of ' + readableMaxsize + 'KB.'),
'Warning!', true);
return;
@ -231,7 +231,7 @@ const app = new Vue({
response.json().then((data) => {
if (data.status === 'error') {
zerobin.message('error', data.message, 'Error');
zerobin.message('danger', data.message, 'Error');
form.forEach((node) => node.disabled = false);
app.isLoading = false
} else {
@ -246,7 +246,7 @@ const app = new Vue({
form.forEach((node) => node.disabled = false);
app.isLoading = false
zerobin.message(
'error',
'danger',
'Paste could not be saved. Please try again later.',
'Error');
}
@ -254,7 +254,7 @@ const app = new Vue({
form.forEach((node) => node.disabled = false);
app.isLoading = false
zerobin.message(
'error',
'danger',
'Paste could not be saved. Please try again later.',
'Error');
});
@ -263,7 +263,7 @@ const app = new Vue({
} catch (err) {
form.forEach((node) => node.disabled = false);
app.isLoading = false
zerobin.message('error', 'Paste could not be encrypted. Aborting.',
zerobin.message('danger', 'Paste could not be encrypted. Aborting.',
'Error');
}
}
@ -314,7 +314,7 @@ window.zerobin = {
app.isLoading = false;
zerobin.message('error', 'Paste could not be encrypted. Aborting.',
zerobin.message('danger', 'Paste could not be encrypted. Aborting.',
'Error');
}
if (doneCallback) {
@ -729,7 +729,7 @@ if (content && key) {
/* On error*/
function () {
app.isLoading = false;
zerobin.message('error', 'Could not decrypt data (Wrong key ?)', 'Error');
zerobin.message('danger', 'Could not decrypt data (Wrong key ?)', 'Error');
},
/* Update progress bar */
@ -779,7 +779,7 @@ if (content && key) {
prettyPrint();
} else {
if (content.indexOf('data:image') != 0) {
zerobin.message('dismissible',
zerobin.message('primary',
"The paste did not seem to be code, so it " +
"was not colorized. ",
'', false, undefined, {
@ -815,6 +815,21 @@ window.onload = function () {
app.displayBottomToolBar = height > 400;
})
})
/* Remove expired pasted from history **/
if (app.support.history && app.currentPaste.type === 'not_found') {
var paste_id = zerobin.getPasteId();
var keys = zerobin.getLocalStorageURLKeys();
keys.forEach((key, i) => {
if (localStorage[key].indexOf(paste_id) !== -1) {
localStorage.removeItem(key);
return false;
}
})
}
}
/* Display previous pastes */
@ -834,17 +849,6 @@ if (app.support.fileUpload) {
}
/* Remove expired pasted from history */
if (app.support.history && zerobin.paste_not_found) {
var paste_id = zerobin.getPasteId();
var keys = zerobin.getLocalStorageURLKeys();
keys.forEach((key, i) => {
if (localStorage[key].indexOf(paste_id) !== -1) {
localStorage.removeItem(key);
return false;
}
})
}
/* Autofit text area height */
const tx = document.getElementsByTagName('textarea');

View File

@ -1,8 +1,4 @@
<script type="text/javascript">
zerobin.paste_not_found = true;
</script>
<p class="alert alert-warning alert-dismissible">
<p class="alert alert-warning alert-dismissible" :dummy="currentPaste.type = 'not_found'">
<a class="close" data-dismiss="alert" href="#" @click.prevent="$event.target.parentNode.remove()">×</a>
<strong class="title">404 Error!</strong>
<span class="message">

View File

@ -57,6 +57,16 @@
</noscript>
<div class="container-md" id="wrap-content">
<p :class="'alert alert-' + msg.type" v-for="msg in messages">
<a class="close" data-dismiss="alert" href="#" @click="$event.target.parentNode.remove()">×</a>
<strong class="title" v-if="msg.title" v-html="msg.title"></strong>
<span class="message" v-html="msg.content"></span>
<a v-if="msg.action.message" href="#"
@click.once.prevent="msg.action.callback($event)">{% msg.action.message %}</a>
</p>
<div id='main'>{{!base}}</div>
</div>