Add view to confirm display and destroy of the secret

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-08-19 15:49:15 +02:00
parent b6331ac902
commit 937a119027
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
6 changed files with 67 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -29,6 +29,14 @@ hashLoad = () ->
if hash.length == 0 if hash.length == 0
return return
$('#panelNewSecret').hide()
$('#panelSecretURL').hide()
$('#notfound').hide()
$('#somethingwrong').hide()
$('#panelReadSecretPre').show()
requestSecret = () ->
hash = window.location.hash
hash = decodeURIComponent(hash) hash = decodeURIComponent(hash)
parts = hash.split '|' parts = hash.split '|'
@ -47,6 +55,7 @@ initBinds = () ->
$('#formCreateSecret').bind 'submit', createSecret $('#formCreateSecret').bind 'submit', createSecret
$('#newSecret, .navbar-brand').bind 'click', newSecret $('#newSecret, .navbar-brand').bind 'click', newSecret
$(window).bind 'hashchange', hashLoad $(window).bind 'hashchange', hashLoad
$('#revealSecret').bind 'click', requestSecret
newSecret = () -> newSecret = () ->
location.href = location.href.split('#')[0] location.href = location.href.split('#')[0]
@ -59,6 +68,7 @@ secretCreated = (data) ->
url = "#{location.href.split('#')[0]}##{secretHash}" url = "#{location.href.split('#')[0]}##{secretHash}"
$('#panelNewSecret').hide() $('#panelNewSecret').hide()
$('#panelReadSecretPre').hide()
$('#panelSecretURL').show() $('#panelSecretURL').show()
$('#panelSecretURL').find('input').val url $('#panelSecretURL').find('input').val url
$('#panelSecretURL').find('input').focus() $('#panelSecretURL').find('input').focus()
@ -75,6 +85,7 @@ showData = (data) ->
$('#panelSecretURL').hide() $('#panelSecretURL').hide()
$('#notfound').hide() $('#notfound').hide()
$('#somethingwrong').hide() $('#somethingwrong').hide()
$('#panelReadSecretPre').hide()
$('#panelReadSecret').show() $('#panelReadSecret').show()
$('#panelReadSecret').find('textarea').val secret $('#panelReadSecret').find('textarea').val secret

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.12.4 // Generated by CoffeeScript 1.12.4
(function() { (function() {
var createSecret, dataNotFound, hashLoad, initBinds, newSecret, secretCreated, securePassword, showData, somethingWrong; var createSecret, dataNotFound, hashLoad, initBinds, newSecret, requestSecret, secretCreated, securePassword, showData, somethingWrong;
securePassword = null; securePassword = null;
@ -33,11 +33,21 @@
}; };
hashLoad = function() { hashLoad = function() {
var hash, id, parts; var hash;
hash = window.location.hash; hash = window.location.hash;
if (hash.length === 0) { if (hash.length === 0) {
return; return;
} }
$('#panelNewSecret').hide();
$('#panelSecretURL').hide();
$('#notfound').hide();
$('#somethingwrong').hide();
return $('#panelReadSecretPre').show();
};
requestSecret = function() {
var hash, id, parts;
hash = window.location.hash;
hash = decodeURIComponent(hash); hash = decodeURIComponent(hash);
parts = hash.split('|'); parts = hash.split('|');
if (parts.length === 2) { if (parts.length === 2) {
@ -57,7 +67,8 @@
initBinds = function() { initBinds = function() {
$('#formCreateSecret').bind('submit', createSecret); $('#formCreateSecret').bind('submit', createSecret);
$('#newSecret, .navbar-brand').bind('click', newSecret); $('#newSecret, .navbar-brand').bind('click', newSecret);
return $(window).bind('hashchange', hashLoad); $(window).bind('hashchange', hashLoad);
return $('#revealSecret').bind('click', requestSecret);
}; };
newSecret = function() { newSecret = function() {
@ -73,6 +84,7 @@
} }
url = (location.href.split('#')[0]) + "#" + secretHash; url = (location.href.split('#')[0]) + "#" + secretHash;
$('#panelNewSecret').hide(); $('#panelNewSecret').hide();
$('#panelReadSecretPre').hide();
$('#panelSecretURL').show(); $('#panelSecretURL').show();
$('#panelSecretURL').find('input').val(url); $('#panelSecretURL').find('input').val(url);
$('#panelSecretURL').find('input').focus(); $('#panelSecretURL').find('input').focus();
@ -90,6 +102,7 @@
$('#panelSecretURL').hide(); $('#panelSecretURL').hide();
$('#notfound').hide(); $('#notfound').hide();
$('#somethingwrong').hide(); $('#somethingwrong').hide();
$('#panelReadSecretPre').hide();
$('#panelReadSecret').show(); $('#panelReadSecret').show();
return $('#panelReadSecret').find('textarea').val(secret); return $('#panelReadSecret').find('textarea').val(secret);
}; };

View File

@ -23,7 +23,7 @@
<![endif]--> <![endif]-->
<style> <style>
#somethingwrong, #notfound, #panelReadSecret, #panelSecretURL { #somethingwrong, #notfound, #panelReadSecret, #panelSecretURL, #panelReadSecretPre {
display: none; display: none;
} }
.footer { .footer {
@ -105,6 +105,21 @@
</div> </div>
</div> </div>
<div class="panel panel-primary" id="panelReadSecretPre">
<div class="panel-heading">
<h3 class="panel-title">{{T "title-reading-secret"}}</h3>
</div>
<div class="panel-body">
<p>
{{T "text-pre-reveal-hint"}}
</p>
<p>
<button class="btn btn-success" id="revealSecret">{{T "btn-reveal-secret"}}</button>
</p>
</div>
</div>
<div class="panel panel-primary" id="panelReadSecret"> <div class="panel panel-primary" id="panelReadSecret">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">{{T "title-reading-secret"}}</h3> <h3 class="panel-title">{{T "title-reading-secret"}}</h3>

View File

@ -11,6 +11,9 @@
"btn-new-secret": { "btn-new-secret": {
"other": "Neues Secret" "other": "Neues Secret"
}, },
"btn-reveal-secret": {
"other": "Zeig mir das Secret!"
},
"label-secret-data": { "label-secret-data": {
"other": "Inhalt des Secrets:" "other": "Inhalt des Secrets:"
}, },
@ -23,6 +26,9 @@
"text-powered-by": { "text-powered-by": {
"other": "Läuft mit" "other": "Läuft mit"
}, },
"text-pre-reveal-hint": {
"other": "Um das Secret anzuzeigen klicke diesen Button aber denk dran, dass das Secret nur einmal angezeigt und dabei gelöscht wird."
},
"text-pre-url": { "text-pre-url": {
"other": "Dein Secret wurde angelegt und unter folgender URL gespeichert:" "other": "Dein Secret wurde angelegt und unter folgender URL gespeichert:"
}, },

View File

@ -11,6 +11,9 @@
"btn-new-secret": { "btn-new-secret": {
"other": "New Secret" "other": "New Secret"
}, },
"btn-reveal-secret": {
"other": "Show me the secret!"
},
"label-secret-data": { "label-secret-data": {
"other": "Secret data:" "other": "Secret data:"
}, },
@ -23,6 +26,9 @@
"text-powered-by": { "text-powered-by": {
"other": "Powered by" "other": "Powered by"
}, },
"text-pre-reveal-hint": {
"other": "To reveal the secret click this button but be aware doing so will destroy the secret. You can only view it once!"
},
"text-pre-url": { "text-pre-url": {
"other": "Your secret was created and stored using this URL:" "other": "Your secret was created and stored using this URL:"
}, },