|
|
|
@ -3,8 +3,27 @@
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getQueryStrings() {
|
|
|
|
|
var vars = [], hash;
|
|
|
|
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
|
|
|
|
for(var i = 0; i < hashes.length; i++)
|
|
|
|
|
{
|
|
|
|
|
hash = hashes[i].split('=');
|
|
|
|
|
vars.push(hash[0]);
|
|
|
|
|
vars[hash[0]] = hash[1];
|
|
|
|
|
}
|
|
|
|
|
return vars;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$( document ).ready(function(){
|
|
|
|
|
$('body').removeClass('is-preload');
|
|
|
|
|
|
|
|
|
|
// Check if query strings were passed to automatically show the secret
|
|
|
|
|
let token = getQueryStrings()['token'];
|
|
|
|
|
if ( token ) {
|
|
|
|
|
showSecret(token);
|
|
|
|
|
$('#retrieve-secret').hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#create-secret').on('submit', function(event) {
|
|
|
|
@ -27,8 +46,9 @@ $('#create-secret').on('submit', function(event) {
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
data: JSON.stringify(data),
|
|
|
|
|
success: function (res){
|
|
|
|
|
let url = '{{ site.url }}{{ site.baseurl }}/retrieve?token=' + res['token']
|
|
|
|
|
$('#create-secret').trigger('reset');
|
|
|
|
|
$('#secret-response').html('Secret token: ' + res['token']);
|
|
|
|
|
$('#secret-response').html('<a href="' + url + '">' + url + '</a>');
|
|
|
|
|
$('#secret-response').removeClass('hidden');
|
|
|
|
|
},
|
|
|
|
|
error: function (res){
|
|
|
|
@ -39,30 +59,34 @@ $('#create-secret').on('submit', function(event) {
|
|
|
|
|
}, 750);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showSecret(token) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '{{ site.secret_endpoint }}?token=' + token,
|
|
|
|
|
crossDomain: 'true',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
success: function (res){
|
|
|
|
|
$('#retrieve-secret').trigger('reset');
|
|
|
|
|
$('#secret-response').removeClass('hidden');
|
|
|
|
|
$('#response-username').html(res['username']);
|
|
|
|
|
$('#response-password').html(res['password']);
|
|
|
|
|
$('#response-message').html(res['message']);
|
|
|
|
|
$('#response-expiration').html(res['expiration']);
|
|
|
|
|
},
|
|
|
|
|
error: function (res){
|
|
|
|
|
$('#secret-response').html('Something went wrong: ' + JSON.stringify(res.responseJSON));
|
|
|
|
|
$('#secret-response').removeClass('hidden');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#retrieve-secret').on('submit', function(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
window.setTimeout(function() {
|
|
|
|
|
|
|
|
|
|
var token = $('#secret-token').val();
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '{{ site.secret_endpoint }}?token=' + token,
|
|
|
|
|
crossDomain: 'true',
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
success: function (res){
|
|
|
|
|
$('#retrieve-secret').trigger('reset');
|
|
|
|
|
$('#secret-response').removeClass('hidden');
|
|
|
|
|
$('#response-username').html(res['username']);
|
|
|
|
|
$('#response-password').html(res['password']);
|
|
|
|
|
$('#response-message').html(res['message']);
|
|
|
|
|
$('#response-expiration').html(res['expiration']);
|
|
|
|
|
},
|
|
|
|
|
error: function (res){
|
|
|
|
|
$('#secret-response').html('Something went wrong: ' + JSON.stringify(res.responseJSON));
|
|
|
|
|
$('#secret-response').removeClass('hidden');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
var token = $('#secret-token').val();
|
|
|
|
|
showSecret(token);
|
|
|
|
|
}, 750);
|
|
|
|
|
});
|
|
|
|
|