$(document).ready(function(){ //Ini Materialize M.AutoInit(); //Si message à afficher if($("#msg").val().trim() != ''){ var msg = ''; switch($("#msg").attr('data-type')){ case 'err': msg = message_erreur($("#msg").val()); break; case 'ok': msg = message_conf($("#msg").val()); break; default: msg = message_info($("#msg").val()); } float_message(msg); } //Envoyer formulaire $("#valid").on('click', function(){ if($('#save-name').val() == null && $("#name").val().trim() == ''){ float_message(message_erreur('Lanceur vide')); return false; } $("#form").submit(); }); //Rechargement $("#reload").on('click', function(){ //location.href = './'; reload_score(); }).click(); //Recharge toutes les minutes setTimeout(function(){ $("#reload").click(); }, 60 * 1000); //Reset $('#reset').on('click', function(){ location.href = './?reset'; }); //Quit $('#quit').on('click', function(){ location.href = './?quit'; }); $("body").on('click', '.float_message', function () { $(this).slideUp('slow', function () { $(this).html(''); }); }); }); function reload_score(){ $.post("ajx/score.php", null, function(data){ if(data.etat == 'ok'){ $("#tbody").html(data.html); } }, 'json'); } function message_erreur(msg){ var html = ''; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' error' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' ' + msg + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + msg + '
 ' + "\n"; html += '
' + "\n"; html += '
' + "\n"; return html; } function message_info(msg){ var html = ''; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' info' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' ' + msg + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + msg + '
 ' + "\n"; html += '
' + "\n"; html += '
' + "\n"; return html; } function message_warn(msg){ var html = ''; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' warning' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' ' + msg + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + msg + '
 ' + "\n"; html += '
' + "\n"; html += '
' + "\n"; return html; } function message_conf(msg){ var html = ''; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' check_circle' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += ' ' + msg + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + "\n"; html += '
' + msg + '
 ' + "\n"; html += '
' + "\n"; html += '
' + "\n"; return html; } function float_message(text){ $("#float_msg").html(text).slideDown('slow', null); setTimeout(function(){ $("#float_msg").click(); }, '5000'); }