123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- /******* global start *******/
- var _website = 'http://' + window.location.host + '/';
- //调试
- function debug(content) {
- console.log(content);
- }
- //重定向
- function go(location) {
- self.location.href = location;
- }
- //初始化
- function globalInit(fixed) {
- if (fixed == 1) {
- document.addEventListener('touchmove',
- function(e) {
- e.preventDefault();
- },
- false);
- }
- }
- //开始加载进度
- function startLoading() {
- $('#loading').show();
- loading(0.5);
- }
- //加载过程
- var _loading;
- function loading(width) {
- clearTimeout(_loading);
- if (width <= 80) {
- _loading = setTimeout(function() {
- $('.loading-bar').width(width + '%');
- width += 0.5;
- loading(width);
- },
- 20);
- }
- }
- //结束加载进度
- function endLoading() {
- clearTimeout(_loading);
- $('.loading-bar').width('80%');
- setTimeout(function() {
- $('#loading').fadeOut(500);
- },
- 1200);
- }
- //弹出灰色浮层
- function gray() {
- $('#bg-gray').fadeIn(800);
- $(window).resize(function() {
- if ($('#bg-gray').is(':visible')) {
- $('#bg-gray').css({
- 'width': $(document.body).width(),
- 'height': $(document.body).height()
- }).fadeIn(800);
- }
- });
- }
- //关闭灰色浮层
- function grayHide() {
- $('#bg-gray').fadeOut(500);
- }
- /******* global end *******/
- /******* home start *******/
- function initHome(gamedata, auth) {
- var html = '<ul>';
- $.each(gamedata,
- function(key, value) {
- if (value['online'] == 1) {
- html += '<li>';
- html += '<div class="icon">';
- html += '<img src="' + value['game_img'] + '" width="128px" height="128px"/>';
- html += '</div>';
- html += '<div class="game-info">';
- html += '<div class="name">' + value['name'] + '</div>';
- html += '<div class="rank-info">';
- if (auth == true) {
- html += '<span class="home-rank">';
- html += '<span class="rank-icon"></span>';
- html += '<span class="rank-key">好友中排名:</span>';
- html += '<span class="rank-value">' + 1 + '</span>';
- html += '<span class="rank-value">' + value['my_rank'] + '</span>';
- html += '</span>';
- }
- html += '<span class="home-info">';
- html += '<span class="num-cion"></span>';
- html += '<span class="num-value">' + value['total_user'] + '</span>';
- html += '<span class="num-key">人在玩</span>';
- html += '</span>';
- html += '</div>';
- html += '<div class="summary">' + value['summary'] + '</div>';
- html += '<a href="game?gid=' + value['id'] + '" class="challenge">挑战</a>';
- html += '</div>';
- html += '</li>';
- }
- });
- html += '</ul>';
- $('.game-list').html(html);
- }
- /******* home end *******/
- /******* game-play start *******/
- //完成加载统计
- var _first = false;
- function finishLoadLog() {
- if (_first == false) {
- _first = true;
- // $.post('../../api/finishLoadLog');
- }
- }
- function setScore(last_score){}
- function initScore(){}
- function ShareWS() {
- $('.share-w').fadeIn(800);
- }
- function ShareWH() {
- $('.share-w').fadeOut(800);
- }
- //开启微信分享引导
- function weixinShareWS() {
- $('.weixin-share').fadeIn(800);
- setTimeout('weixinShareWH()', 5000);
- gray();
- }
- //关闭微信分享引导
- function weixinShareWH() {
- $('.weixin-share').fadeOut(500);
- grayHide();
- }
- //弹出灰色浮层
- function gray() {
- $('#bg-gray').fadeIn(800);
- $(window).resize(function() {
- if ($('#bg-gray').is(':visible')) {
- $('#bg-gray').css({
- 'width': $(document.body).width(),
- 'height': $(document.body).height()
- }).fadeIn(800);
- }
- });
- }
- //关闭灰色浮层
- function grayHide() {
- $('#bg-gray').fadeOut(500);
- }
|