Advertisement
Nexon

Мониторинг в реальном времени (JS)

Sep 4th, 2012
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
  3. if (!mobile) {
  4. jQuery.getJSON("mon/online.json", {}, function(json){
  5.     for (var item in json) {
  6.                        jQuery("mon").append("<div id='mon'><div class='progress-bar' id='onlinebar_" + item + "'><b><dfg>" + item + "</dfg></b><span style='min-width: 10%;width: 10%;max-width: 75%;'><b id='onlinebarin_" + item + "'><center>" + json[item].players + "</center></b></span>    </div>");
  7.     }
  8. });
  9. setInterval(function() {
  10. jQuery.getJSON("mon/online.json", {}, function(json){
  11.     for (var item in json) {
  12.                          if (json[item].status == 1 && json[item].maxplayers >= 1) {                      
  13.                        jQuery('#onlinebar_' + item).children('span').animate({width: json[item].players + '%' }, 500 );
  14.                        jQuery('#onlinebar_' + item).css('background-image','url(http://world4play.com/public/style_images/nacht/online.png)');
  15.                        jQuery('#onlinebarin_' + item).html('');
  16.                        jQuery('#onlinebarin_' + item).append('<center>' + json[item].players + '</center>');
  17.                        }                    
  18.                  if (json[item].status == 0) {                      
  19.                jQuery('#onlinebar_' + item).children('span').animate({width: '100%' }, 500 );
  20.                        jQuery('#onlinebar_' + item).css('background-image','url(http://world4play.com/public/style_images/nacht/offline.png)');
  21.                        jQuery('#onlinebarin_' + item).html('');
  22.                        jQuery('#onlinebarin_' + item).append('<center>Отключен</center>');
  23.                        }                    
  24.              if (json[item].status == 1 && json[item].maxplayers == 0) {                      
  25.                jQuery('#onlinebar_' + item).children('span').animate({width: '100%' }, 500 );
  26.                        jQuery('#onlinebar_' + item).css('background-image','url(http://world4play.com/public/style_images/nacht/work.png)');
  27.                        jQuery('#onlinebarin_' + item).html('');
  28.                        jQuery('#onlinebarin_' + item).append('<center>Профилактика</center>');
  29.                        }    
  30.     }
  31. });
  32. }, 2500);
  33. }
  34. </script>
  35. <mon></mon>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement