common.min.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /******* global start *******/
  2. var _website = 'http://' + window.location.host + '/';
  3. //调试
  4. function debug(content) {
  5. console.log(content);
  6. }
  7. //重定向
  8. function go(location) {
  9. self.location.href = location;
  10. }
  11. //初始化
  12. function globalInit(fixed) {
  13. if (fixed == 1) {
  14. document.addEventListener('touchmove',
  15. function(e) {
  16. e.preventDefault();
  17. },
  18. false);
  19. }
  20. }
  21. //开始加载进度
  22. function startLoading() {
  23. $('#loading').show();
  24. loading(0.5);
  25. }
  26. //加载过程
  27. var _loading;
  28. function loading(width) {
  29. clearTimeout(_loading);
  30. if (width <= 80) {
  31. _loading = setTimeout(function() {
  32. $('.loading-bar').width(width + '%');
  33. width += 0.5;
  34. loading(width);
  35. },
  36. 20);
  37. }
  38. }
  39. //结束加载进度
  40. function endLoading() {
  41. clearTimeout(_loading);
  42. $('.loading-bar').width('80%');
  43. setTimeout(function() {
  44. $('#loading').fadeOut(500);
  45. },
  46. 1200);
  47. }
  48. //弹出灰色浮层
  49. function gray() {
  50. $('#bg-gray').fadeIn(800);
  51. $(window).resize(function() {
  52. if ($('#bg-gray').is(':visible')) {
  53. $('#bg-gray').css({
  54. 'width': $(document.body).width(),
  55. 'height': $(document.body).height()
  56. }).fadeIn(800);
  57. }
  58. });
  59. }
  60. //关闭灰色浮层
  61. function grayHide() {
  62. $('#bg-gray').fadeOut(500);
  63. }
  64. /******* global end *******/
  65. /******* home start *******/
  66. function initHome(gamedata, auth) {
  67. var html = '<ul>';
  68. $.each(gamedata,
  69. function(key, value) {
  70. if (value['online'] == 1) {
  71. html += '<li>';
  72. html += '<div class="icon">';
  73. html += '<img src="' + value['game_img'] + '" width="128px" height="128px"/>';
  74. html += '</div>';
  75. html += '<div class="game-info">';
  76. html += '<div class="name">' + value['name'] + '</div>';
  77. html += '<div class="rank-info">';
  78. if (auth == true) {
  79. html += '<span class="home-rank">';
  80. html += '<span class="rank-icon"></span>';
  81. html += '<span class="rank-key">好友中排名:</span>';
  82. html += '<span class="rank-value">' + 1 + '</span>';
  83. html += '<span class="rank-value">' + value['my_rank'] + '</span>';
  84. html += '</span>';
  85. }
  86. html += '<span class="home-info">';
  87. html += '<span class="num-cion"></span>';
  88. html += '<span class="num-value">' + value['total_user'] + '</span>';
  89. html += '<span class="num-key">人在玩</span>';
  90. html += '</span>';
  91. html += '</div>';
  92. html += '<div class="summary">' + value['summary'] + '</div>';
  93. html += '<a href="game?gid=' + value['id'] + '" class="challenge">挑战</a>';
  94. html += '</div>';
  95. html += '</li>';
  96. }
  97. });
  98. html += '</ul>';
  99. $('.game-list').html(html);
  100. }
  101. /******* home end *******/
  102. /******* game-play start *******/
  103. //完成加载统计
  104. var _first = false;
  105. function finishLoadLog() {
  106. if (_first == false) {
  107. _first = true;
  108. // $.post('../../api/finishLoadLog');
  109. }
  110. }
  111. function setScore(last_score){}
  112. function initScore(){}
  113. function ShareWS() {
  114. $('.share-w').fadeIn(800);
  115. }
  116. function ShareWH() {
  117. $('.share-w').fadeOut(800);
  118. }
  119. //开启微信分享引导
  120. function weixinShareWS() {
  121. $('.weixin-share').fadeIn(800);
  122. setTimeout('weixinShareWH()', 5000);
  123. gray();
  124. }
  125. //关闭微信分享引导
  126. function weixinShareWH() {
  127. $('.weixin-share').fadeOut(500);
  128. grayHide();
  129. }
  130. //弹出灰色浮层
  131. function gray() {
  132. $('#bg-gray').fadeIn(800);
  133. $(window).resize(function() {
  134. if ($('#bg-gray').is(':visible')) {
  135. $('#bg-gray').css({
  136. 'width': $(document.body).width(),
  137. 'height': $(document.body).height()
  138. }).fadeIn(800);
  139. }
  140. });
  141. }
  142. //关闭灰色浮层
  143. function grayHide() {
  144. $('#bg-gray').fadeOut(500);
  145. }