mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00

* added new indicator icons for create account, create character and change character name * attempt to fix incorrect views counter behavior (its resetting to 0 in some cases) * moved check_* functions to class Validator * from now all validators ajax requests will fire onblur instead of onkeyup * ajax requests returns now json instead of xml * added 404 response when file is not found * fixed gallery
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
$(function() {
|
|
$('#character_name').blur(function() {
|
|
checkName();
|
|
});
|
|
});
|
|
|
|
var eventId = 0;
|
|
var lastSend = 0;
|
|
|
|
function checkName()
|
|
{
|
|
if(eventId != 0)
|
|
{
|
|
clearInterval(eventId)
|
|
eventId = 0;
|
|
}
|
|
|
|
if(document.getElementById("character_name").value=="")
|
|
{
|
|
$('#character_error').html('<font color="red">Please enter new character name.</font>');
|
|
return;
|
|
}
|
|
|
|
//anti flood
|
|
var date = new Date;
|
|
var timeNow = parseInt(date.getTime());
|
|
|
|
if(lastSend != 0)
|
|
{
|
|
if(timeNow - lastSend < 1100)
|
|
{
|
|
eventId = setInterval('checkName()', 1100)
|
|
return;
|
|
}
|
|
}
|
|
|
|
var name = document.getElementById("character_name").value;
|
|
$.getJSON("tools/validate.php", { name: name, uid: Math.random() },
|
|
function(data){
|
|
if(data.hasOwnProperty('success')) {
|
|
$('#character_error').html ('<font color="green">' + data.success + '</font>');
|
|
$('#character_indicator').attr('src', 'images/global/general/ok.gif');
|
|
}
|
|
else if(data.hasOwnProperty('error')) {
|
|
$('#character_error').html('<font color="red">' + data.error + '</font>');
|
|
$('#character_indicator').attr('src', 'images/global/general/nok.gif');
|
|
}
|
|
|
|
lastSend = timeNow;
|
|
});
|
|
} |