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

Added encryption/decryption

This commit is contained in:
Zack Scholl
2016-03-14 09:42:19 -04:00
parent 4509722cbf
commit e97bfb05a9
6 changed files with 307 additions and 54 deletions

View File

@@ -15,6 +15,8 @@ a.deleteable {
cursor: pointer;
}
</style>
<script src="/static/js/sweetalert-dev.js"></script>
<link rel="stylesheet" href="/static/css/sweetalert.css">
</head>
<body>
@@ -44,6 +46,10 @@ a.deleteable {
<li><a href="/{{ $.Title }}/view?version={{ .VersionNum }}">{{ .VersionDate }}</a></li>
{{ end }}
<li><a href="/{{ .Title }}/view">Current</a></li>
{{ if .Encrypted }}
<li class="dropdown-header">Options</li>
<li><a href="#" class="postdecrypt">Decrypt</a></li>
{{ end }}
</ul>
</li>
<li><a href="/{{ .Title }}/list"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span> List</a></li>
@@ -71,6 +77,46 @@ $( document ).ready(function() {
katex.render(el.getAttribute("data-expr"), el, { displayMode: true });
});
$('.postdecrypt').click(function(event) {
var pass1 = "";
event.preventDefault();
swal({
title: "Encryption",
text: "Enter your passphrase:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
inputPlaceholder: "Write something"
}, function(inputValue) {
if (inputValue === false) return false;
if (inputValue === "") {
swal.showInputError("You need to write something!");
return false
}
pass1 = inputValue;
$.ajax({
type: "POST",
//the url where you want to sent the userName and password to
url: '/{{ .Title }}/decrypt',
dataType: 'json',
data: JSON.stringify({
text: " ",
password: pass1
}),
success: function (data) {
if (data['success'] == true) {
swal("Decryption", "Decrypted!", "success");
window.location.href = '/{{ .Title }}/view';
} else {
swal("Decryption", data['status'], "error");
}
}
});
});
});
});
$(document).keydown(function(e){
@@ -88,6 +134,7 @@ $(document).keydown(function(e){
}
});
{{ if .AdminKey }}
$('.deleteable').click(function(event) {
event.preventDefault();