silvrgit/app/app.js
2017-04-11 14:30:48 +01:00

61 lines
1.3 KiB
JavaScript

(function() {
let formatPassword = function(data) {
let dest$ = $('#passwordOut');
let html = new EJS({url: '/template/password.ejs'}).render(data);
dest$.empty();
dest$.append(html);
dest$.show();
};
let generatePassword = function(from, to) {
let url = '/generate';
$.ajax({
type: 'GET',
url: url,
data: '',
dataType: 'json',
timeout: 10000,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type'
},
success: function(data) {
formatPassword(data);
},
error: function(xhr, type) {
console.log('ajax error');
console.log(xhr);
console.log(type);
}
});
};
$('#newPassword').on('click', function() {
generatePassword();
});
document.title = 'Slack';
})();
let popitout = function(url) {
let newwindow = window.open(url, 'name', 'height=600,width=570');
if (window.focus) {
newwindow.focus();
}
return false;
};
let popitoutSmall = function(url) {
let newwindow = window.open(url, 'name', 'height=400,width=520');
if (window.focus) {
newwindow.focus();
}
return false;
};