Revert static/demo.js since it is not transpiled
This commit is contained in:
parent
21118c0b1d
commit
20593a0adc
@ -1,13 +1,12 @@
|
|||||||
/* eslint strict: 0 */
|
/* eslint-disable */
|
||||||
/* global jQuery */
|
|
||||||
|
|
||||||
(function($) {
|
;(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$('.progress-bar').css('width', '100%');
|
$('.progress-bar').css('width', '100%');
|
||||||
|
|
||||||
// POST key form
|
// POST key form
|
||||||
$('#addKey form').submit(e => {
|
$('#addKey form').submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#addKey .alert').addClass('hidden');
|
$('#addKey .alert').addClass('hidden');
|
||||||
$('#addKey .progress').removeClass('hidden');
|
$('#addKey .progress').removeClass('hidden');
|
||||||
@ -16,38 +15,39 @@
|
|||||||
url: '/api/v1/key',
|
url: '/api/v1/key',
|
||||||
data: JSON.stringify({ publicKeyArmored:$('#addKey textarea').val() }),
|
data: JSON.stringify({ publicKeyArmored:$('#addKey textarea').val() }),
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
}).done((data, textStatus, xhr) => {
|
}).done(function(data, textStatus, xhr) {
|
||||||
if (xhr.status === 304) {
|
if (xhr.status === 304) {
|
||||||
alert('addKey', 'danger', 'Key already exists!');
|
alert('addKey', 'danger', 'Key already exists!');
|
||||||
} else {
|
} else {
|
||||||
alert('addKey', 'success', xhr.responseText);
|
alert('addKey', 'success', xhr.responseText);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(xhr => {
|
.fail(function(xhr) {
|
||||||
alert('addKey', 'danger', xhr.responseText);
|
alert('addKey', 'danger', xhr.responseText);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// DELETE key form
|
// DELETE key form
|
||||||
$('#removeKey form').submit(e => {
|
$('#removeKey form').submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#removeKey .alert').addClass('hidden');
|
$('#removeKey .alert').addClass('hidden');
|
||||||
$('#removeKey .progress').removeClass('hidden');
|
$('#removeKey .progress').removeClass('hidden');
|
||||||
const email = $('#removeKey input[type="email"]').val();
|
var email = $('#removeKey input[type="email"]').val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: `/api/v1/key?email=${encodeURIComponent(email)}`
|
url: '/api/v1/key?email=' + encodeURIComponent(email)
|
||||||
}).done((data, textStatus, xhr) => {
|
}).done(function(data, textStatus, xhr) {
|
||||||
alert('removeKey', 'success', xhr.responseText);
|
alert('removeKey', 'success', xhr.responseText);
|
||||||
})
|
})
|
||||||
.fail(xhr => {
|
.fail(function(xhr) {
|
||||||
alert('removeKey', 'danger', xhr.responseText);
|
alert('removeKey', 'danger', xhr.responseText);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function alert(region, outcome, text) {
|
function alert(region, outcome, text) {
|
||||||
$(`#${region} .progress`).addClass('hidden');
|
$('#' + region + ' .progress').addClass('hidden');
|
||||||
$(`#${region} .alert-${outcome} span`).text(text);
|
$('#' + region + ' .alert-' + outcome + ' span').text(text);
|
||||||
$(`#${region} .alert-${outcome}`).removeClass('hidden');
|
$('#' + region + ' .alert-' + outcome).removeClass('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
Loading…
Reference in New Issue
Block a user