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; app.isUploading = true;
zerobin.upload(files); zerobin.upload(files);
} catch (e) { } catch (e) {
zerobin.message('error', 'Could no upload the file', 'Error'); zerobin.message('danger', 'Could no upload the file', 'Error');
} }
app.isUploading = false; app.isUploading = false;
}, },
@ -136,14 +136,14 @@ const app = new Vue({
form.forEach((node) => node.disabled = false); form.forEach((node) => node.disabled = false);
app.isLoading = false app.isLoading = false
zerobin.message( zerobin.message(
'error', 'danger',
'Paste could not be deleted. Please try again later.', 'Paste could not be deleted. Please try again later.',
'Error'); 'Error');
} }
app.isLoading = false; app.isLoading = false;
}).catch(function (error) { }).catch(function (error) {
zerobin.message( zerobin.message(
'error', 'danger',
'Paste could not be delete. Please try again later.', 'Paste could not be delete. Please try again later.',
'Error'); 'Error');
app.isLoading = false; app.isLoading = false;
@ -157,9 +157,9 @@ const app = new Vue({
let promise = navigator.clipboard.writeText(pasteContent); let promise = navigator.clipboard.writeText(pasteContent);
promise.then(function () { 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) { }, 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) { if (oversized) {
app.isLoading = false app.isLoading = false
form.forEach((node) => node.disabled = 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.'), '</strong>KB. You have reached the maximum size limit of ' + readableMaxsize + 'KB.'),
'Warning!', true); 'Warning!', true);
return; return;
@ -231,7 +231,7 @@ const app = new Vue({
response.json().then((data) => { response.json().then((data) => {
if (data.status === 'error') { if (data.status === 'error') {
zerobin.message('error', data.message, 'Error'); zerobin.message('danger', data.message, 'Error');
form.forEach((node) => node.disabled = false); form.forEach((node) => node.disabled = false);
app.isLoading = false app.isLoading = false
} else { } else {
@ -246,7 +246,7 @@ const app = new Vue({
form.forEach((node) => node.disabled = false); form.forEach((node) => node.disabled = false);
app.isLoading = false app.isLoading = false
zerobin.message( zerobin.message(
'error', 'danger',
'Paste could not be saved. Please try again later.', 'Paste could not be saved. Please try again later.',
'Error'); 'Error');
} }
@ -254,7 +254,7 @@ const app = new Vue({
form.forEach((node) => node.disabled = false); form.forEach((node) => node.disabled = false);
app.isLoading = false app.isLoading = false
zerobin.message( zerobin.message(
'error', 'danger',
'Paste could not be saved. Please try again later.', 'Paste could not be saved. Please try again later.',
'Error'); 'Error');
}); });
@ -263,7 +263,7 @@ const app = new Vue({
} catch (err) { } catch (err) {
form.forEach((node) => node.disabled = false); form.forEach((node) => node.disabled = false);
app.isLoading = false app.isLoading = false
zerobin.message('error', 'Paste could not be encrypted. Aborting.', zerobin.message('danger', 'Paste could not be encrypted. Aborting.',
'Error'); 'Error');
} }
} }
@ -314,7 +314,7 @@ window.zerobin = {
app.isLoading = false; app.isLoading = false;
zerobin.message('error', 'Paste could not be encrypted. Aborting.', zerobin.message('danger', 'Paste could not be encrypted. Aborting.',
'Error'); 'Error');
} }
if (doneCallback) { if (doneCallback) {
@ -729,7 +729,7 @@ if (content && key) {
/* On error*/ /* On error*/
function () { function () {
app.isLoading = false; 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 */ /* Update progress bar */
@ -779,7 +779,7 @@ if (content && key) {
prettyPrint(); prettyPrint();
} else { } else {
if (content.indexOf('data:image') != 0) { if (content.indexOf('data:image') != 0) {
zerobin.message('dismissible', zerobin.message('primary',
"The paste did not seem to be code, so it " + "The paste did not seem to be code, so it " +
"was not colorized. ", "was not colorized. ",
'', false, undefined, { '', false, undefined, {
@ -815,6 +815,21 @@ window.onload = function () {
app.displayBottomToolBar = height > 400; 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 */ /* 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 */ /* Autofit text area height */
const tx = document.getElementsByTagName('textarea'); const tx = document.getElementsByTagName('textarea');

View File

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

View File

@ -57,6 +57,16 @@
</noscript> </noscript>
<div class="container-md" id="wrap-content"> <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 id='main'>{{!base}}</div>
</div> </div>