57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
$('#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",
|
|
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');
|
|
});
|
|
} |