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

Asks for password on page load (if encrypted)

Former-commit-id: d3359afc82912db24f9f58c1bdaedaf7da0a83f1 [formerly 1d0c7deccf184d53d6b7ee9a6941debc797eba27] [formerly 6c31542a665d32a10ae076685fbd323f6ba54f55 [formerly d7441a31522a70e092d3967032879be4610179a2 [formerly 00f28d7544]]]
Former-commit-id: 401b98d78bd410e167af3a3647ba40bb22067208 [formerly 71f8b0ffb3c38cdd036061fce3fd969a83653876]
Former-commit-id: 288985cbcaba05fefc8622ead8e939aa3abb564d
Former-commit-id: d4e9938296
This commit is contained in:
Zack Scholl 2016-03-14 11:43:28 -04:00
parent e3327d1520
commit fe0db5759a

View File

@ -72,18 +72,45 @@ a.deleteable {
<script>
$( document ).ready(function() {
var texi = document.getElementsByClassName("texi");
Array.prototype.forEach.call(texi, function(el) {
katex.render(el.getAttribute("data-expr"), el, { displayMode: false });
});
var texp = document.getElementsByClassName("texp");
Array.prototype.forEach.call(texp, function(el) {
katex.render(el.getAttribute("data-expr"), el, { displayMode: true });
});
$('.postdecrypt').click(function(event) {
{{ if .Encrypted }}
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");
}
}
});
});
$('.postdecrypt').click(function(event) {
var pass1 = "";
event.preventDefault();
swal({
@ -121,6 +148,21 @@ $( document ).ready(function() {
});
});
});
{{ end }}
var texi = document.getElementsByClassName("texi");
Array.prototype.forEach.call(texi, function(el) {
katex.render(el.getAttribute("data-expr"), el, { displayMode: false });
});
var texp = document.getElementsByClassName("texp");
Array.prototype.forEach.call(texp, function(el) {
katex.render(el.getAttribute("data-expr"), el, { displayMode: true });
});
});