Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/nickname.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-10-16 16:28:42 +00:00
$('#beginning, #ending').change(function() {
generateNickname();
});
$('#input input').keyup(function(event){
if(event.keyCode == 13) {
event.preventDefault();
}
});
$(function() {
generateNickname();
});
$('#copy').click(function() {
$('#nickname').select();
});
$('#nickname').click(function() {
$('#nickname').select();
});
$('#generate').click(function() {
generateNickname();
});
function generateNickname() {
var beginning = $('#beginning').val();
var ending = $('#ending').val();
$.ajax(
{
url: "/tools/generators/nickname_functions",
2018-10-16 16:28:42 +00:00
cache: false,
dataType: 'text',
data: {
beginning: beginning,
ending: ending
},
beforeSend: function() {
$('#generate').button('loading');
},
success: function(data) {
if(data !== "MySQL Error") {
$('#nickname').val(data);
$('#history').append(`<li class="list-group-item">${data}</li>`);
} else {
$('#nickname').val('Es trat ein Fehler beim Generieren des Nicknames auf');
$('#history-container').remove();
}
},
error: function(data) {
$('#nickname').val('Fehler');
}
}).done(function() {
$('#generate').button('reset');
});
}