$(document).ready(function(){ function loadingSpinner(text){ $('#cmain').html('

' + text + '

') var wc = document.getElementById('wd'); var wd = setInterval(function() { if ((wc.innerHTML += '.').length == 4) wc.innerHTML = ''; }, 100); } if ($('#cmain').hasClass('ulg')){ loadingSpinner('Loading') $.post('api/get_news') .done(function(data){ $('#cmain').html('

' + data['content_title'] + '

') }) .always(function(){ clearInterval(wd) }) } if (window.location.hash == '#login') { showLogin(); }; if (window.location.hash == '#register') { showRegister(); }; $('#hp-login-btn').click(function(){ window.location.hash = '#login'; showLogin(true); }); $('#hp-register-btn').click(function(){ window.location.hash = '#register'; showRegister(true); }); $('#me-mottobox').keypress(function(e) { if(e.which == 13){ $('#me-mottobox').blur(); $('#sb-motto-btn').click(); } }); // update our person every 15 seconds setInterval(function() { $.post('api/user_info') .done(function(data){ // old stats var o_credits = $('#uicd').val(); var o_motto = $('#me-mottobox').attr('placeholder'); var o_look = $('#sidebar-avatar').attr('data-look'); if (data['credits'].toString() != o_credits){ $('#uicd').html(data['credits'].toString()); } if (data['motto'] != o_motto){ if(data['motto'] == ''){ $('#me-mottobox').attr('placeholder', 'Update your motto...'); } else { $('#me-mottobox').attr('placeholder', data['motto']); }} if (data['look'] != o_look){ $('#sidebar-avatar').attr('src', 'https://www.habbo.com/habbo-imaging/avatarimage?figure='+data['look']+'&direction=4&head_direction=4&gesture=sml'); $('#sidebar-avatar').attr('data-look', data['look']); } }) }, 15000); $('#side-nav').click(function(c){ if (c.target.id == 'sb-logout'){ var prevcon = $('#cmain').html(); $('#cmain').html('

Are you sure you want to log out?

\ \
') $('#logout-cancel').click(function(){ $('#cmain').html(prevcon); }) $('#logout-confirm').click(function(){ loadingSpinner('Logging out') }) return } loadingSpinner('Loading'); var mod = c.target.id.replace('sb-', ''); var wc = document.getElementById('wd'); var wd = setInterval(function() { if ((wc.innerHTML += '.').length == 4) wc.innerHTML = ''; }, 100); $.post('api/get_' + mod) .done(function(data){ $('#cmain').html('

' + data['content_title'] + '

') }) .always(function(){ clearInterval(wd) }) }) $('#sb-motto-btn').click(function(){ $('#sb-motto-btn').html('
'); $('#sb-motto-btn').attr('disabled', 'disabled'); $('#me-mottobox').attr('disabled', 'disabled'); $.post('api/update_motto', {'new_motto': $('#me-mottobox').val()}) .done(function(data){ $('#notif-area').prepend('
\ ' + data['message'] + '
'); if($('#me-mottobox').val() == ''){ $('#me-mottobox').attr('placeholder', 'Update your motto...'); } else { $('#me-mottobox').attr('placeholder', $('#me-mottobox').val()); } $('#me-mottobox').val(''); }) .fail(function(xhr, textStatus, errorThrown){ $('#notif-area').prepend('
\ ' + JSON.parse(xhr.responseText)['error'] + '
') }) .always(function(data){ $('#sb-motto-btn').html(''); $('#sb-motto-btn').removeAttr('disabled'); $('#me-mottobox').removeAttr('disabled');} )}); }); function showLogin(fade){ $('#hp-login-btn').hide(); $('#hp-register-btn').hide(); $('#ws-content').hide(); if(typeof(fade)==='undefined') { $('#hp-login-form').show(); } else { $('#hp-login-form').fadeIn('slow'); }; }; function showRegister(fade){ $('#hp-login-btn').hide(); $('#hp-register-btn').hide(); $('#ws-content').hide(); if(typeof(fade)==='undefined') { $('#hp-register-form').show(); } else { $('#hp-register-form').fadeIn('slow'); }; };