Guest User

Untitled

a guest
Feb 17th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. var topic_id;
  2. var menuHomeTime;
  3. var current_votes_count;
  4. var current_votes_sum;
  5.  
  6. function menuHome()
  7. {
  8. if(menuHomeTime > Math.floor((new Date()).getTime() / 1000))
  9. return;
  10. menuHomeTime = Math.floor((new Date()).getTime() / 1000) + 30;
  11. $.mobile.loading('show');
  12. clearInterval(refreshInterval);
  13. $.post("http://sarg.lt/app/server_status.php", {code: "0ay3j5as1Zua55f9T9s2upo"}, function( data ) {
  14. var value = parseINIString(data);
  15.  
  16. if(value["status"])
  17. document.getElementById("serverStatus").innerHTML = '<span class="label label-success">Serveris įjungtas</span>';
  18. else
  19. document.getElementById("serverStatus").innerHTML = '<span class="label label-danger">Serveris išjungtas</span>';
  20.  
  21. if(value["players"] != "")
  22. {
  23. output = 'Žaidėjai: ' + value["players"] + '/' + value["maxplayers"] + '<br>';
  24. output += 'Versija: ' + value["gamemode"] + '<br>';
  25. document.getElementById("serverInfo").innerHTML = output;
  26.  
  27. document.getElementById("serverUpdate").innerHTML = value["lastupdate"];
  28. }
  29. else
  30. {
  31. menuHomeTime = 0;
  32. }
  33. if(topic_id != value["topic_id"])
  34. {
  35. topic_id = value["topic_id"];
  36.  
  37. if(window.localStorage.getItem("score" + topic_id) > 0)
  38. {
  39. $.post("http://sarg.lt/app/get_rate.php", {code: "0ay3j5as1Zua55f9T9s2upo", topic_id: topic_id}, function( data )
  40. {
  41. var value = parseINIString(data);
  42. if(value["votes_count"] > 0 && current_votes_count != value["votes_count"])
  43. {
  44. current_votes_count = value["votes_count"];
  45. current_votes_sum = value["votes_sum"];
  46. $('#rate').raty({readOnly: true, score: Math.round(current_votes_sum/current_votes_count)});
  47. document.getElementById("rate_bottom_text").innerHTML = 'Balsavo: ' + current_votes_count;
  48. }
  49. $.mobile.loading('hide');
  50. }
  51. );
  52. document.getElementById("rate_top_text").innerHTML = 'Ačiū už įvertinimą';
  53. }
  54. else
  55. {
  56. $.mobile.loading('show');
  57. document.getElementById("rate_top_text").innerHTML = 'Įvertinkite atnaujinimą';
  58. $('#rate').raty({score: 0, click: function(score, evt)
  59. {
  60. $('#rate').raty({readOnly: true, score: 0});
  61. window.localStorage.setItem("score" + topic_id, score);
  62.  
  63. document.getElementById("rate_top_text").innerHTML = 'Palaukite...';
  64. $.post("http://sarg.lt/app/rate.php", {uid: topic_id, rate: score, code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
  65. {
  66. $.mobile.loading('hide');
  67. var value = parseINIString(data);
  68. if(value["votes_count"] > 0)
  69. {
  70. current_votes_count = value["votes_count"];
  71. current_votes_sum = value["votes_sum"];
  72. $('#rate').raty({readOnly: true, score: Math.round(current_votes_sum/current_votes_count)});
  73. document.getElementById("rate_bottom_text").innerHTML = 'Balsavo: ' + current_votes_count;
  74.  
  75. showMsg("Ačiū už įvertinimą");
  76. document.getElementById("rate_top_text").innerHTML = 'Ačiū už įvertinimą';
  77. }
  78. else
  79. {
  80. showMsg("Serveris neatsako");
  81. document.getElementById("rate_top_text").innerHTML = 'Pamėginkite vėliau';
  82. }
  83. }
  84. );
  85. }
  86. });
  87. }
  88. }
  89. else
  90. $.mobile.loading('hide');
  91. });
  92. }
Add Comment
Please, Sign In to add comment