silvrgit/app/app.js

61 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-03-22 15:48:36 +00:00
(function() {
2016-03-08 21:52:21 +00:00
2017-03-22 15:48:36 +00:00
let formatPassword = function(data) {
let dest$ = $('#passwordOut');
let html = new EJS({url: '/template/password.ejs'}).render(data);
2016-03-08 21:52:21 +00:00
dest$.empty();
dest$.append(html);
dest$.show();
};
2017-03-22 15:48:36 +00:00
let generatePassword = function(from, to) {
let url = '/generate';
2016-03-08 21:52:21 +00:00
$.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'
},
2017-03-22 15:48:36 +00:00
success: function(data) {
2016-03-08 21:52:21 +00:00
formatPassword(data);
},
2017-03-22 15:48:36 +00:00
error: function(xhr, type) {
console.log('ajax error');
2016-03-08 21:52:21 +00:00
console.log(xhr);
console.log(type);
}
});
};
2017-03-22 15:48:36 +00:00
$('#newPassword').on('click', function() {
2016-03-08 21:52:21 +00:00
generatePassword();
});
document.title = 'Slack';
})();
2017-03-22 15:48:36 +00:00
let popitout = function(url) {
let newwindow = window.open(url, 'name', 'height=600,width=570');
2016-03-08 21:52:21 +00:00
if (window.focus) {
2017-03-22 15:48:36 +00:00
newwindow.focus();
2016-03-08 21:52:21 +00:00
}
return false;
};
2017-03-22 15:48:36 +00:00
let popitoutSmall = function(url) {
let newwindow = window.open(url, 'name', 'height=400,width=520');
2016-03-08 21:52:21 +00:00
if (window.focus) {
2016-04-28 09:48:48 +00:00
newwindow.focus();
2016-03-08 21:52:21 +00:00
}
return false;
};