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 00f28d7544
]]
Former-commit-id: 401b98d78bd410e167af3a3647ba40bb22067208 [formerly 71f8b0ffb3c38cdd036061fce3fd969a83653876]
Former-commit-id: 288985cbcaba05fefc8622ead8e939aa3abb564d
This commit is contained in:
parent
0307b56724
commit
d4e9938296
@ -72,17 +72,44 @@ 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 });
|
||||
|
||||
{{ 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");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
var pass1 = "";
|
||||
event.preventDefault();
|
||||
@ -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 });
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user