$(function () { $(".ksj").unbind('mouseenter').unbind('mouseleave').unbind('mouseover'); getNav(); $(window).resize(getNav); //监听body滚动条距离顶部的高度,当scrollTop>10时显示回到顶部按钮 $(document).scroll(function() { if($(this).scrollTop() > 10) { $("#gotop").css('display','block'); } else { $("#gotop").hide(); } }); //回到顶部 $("#gotop").click(function() { $("html,body").animate({ scrollTop: 0 }, 500); }); setTimeout(function () { var h = $("header").eq(0).height(); //console.log("h=" + h); $(".main").eq(0).css("margin-top", h + "px"); }, 100) $(".hot-lottery-title").click(function () { if ($("body").width() <= 768) { var h = $(".hot-lottery-content").height(); if (h > 95) { $(".hot-lottery-content").height(95); $(this).find(".lot-more").find(".iconfont").removeClass("icon-right").addClass("icon-arrowdown"); } else { $(".hot-lottery-content").css("height", "auto"); $(this).find(".lot-more").find(".iconfont").removeClass("icon-arrowdown").addClass("icon-right"); } } }) $(".nav-content").click(function () { if ($("body").width() <= 768) { if ($(this).find(".ksj-wrapper").length == 1) { console.log($(this).find(".ksj-wrapper").css("display")) if ($(this).find(".ksj-wrapper").css("display") == "none") { $(this).find(".ksj-wrapper").show() } else { $(this).find(".ksj-wrapper").hide(); } } var h = $(".hot-lottery-content").height(); if (h > 95) { $(".hot-lottery-content").height(95); } else { $(".hot-lottery-content").css("height", "auto"); } } }) }) window.onresize=function(){ var h=$("header").eq(0).height(); $(".main").eq(0).css("margin-top",h+"px"); } function getPath(){ return "http://m.api.55128.cn"; } //时间戳 function getTime(){ return Math.round(new Date().getTime()/1000); } //判断浏览器宽度是否为移动端 function getNav() { var w = $(document).width(); if(w < 768) { $("#mnav").addClass("show"); $("#pnav").removeClass("show"); $(".nav-content").addClass("col-xs-4"); $("#lots").hide(); $("#mobile").hide(); } else { $("#mnav").removeClass("show"); $("#pnav").addClass("show"); $(".nav-content").removeClass("col-xs-4"); $("#lots").show(); $("#mobile").show(); } } //移动端显示或隐藏全部导航 function toggleNav(obj) { if($(obj).hasClass("icon-daohang")) { $(obj).removeClass("icon-daohang").addClass("icon-daohangguanbi-"); $("#pnav").addClass("show") } else { $(obj).removeClass("icon-daohangguanbi-").addClass("icon-daohang"); $("#pnav").removeClass("show") } } //返回时间差格式:xx天xx时xx分xx秒 function formatTime(t) { var lastTime=new Date(Date.parse(t.replace(/-/g, "/"))) var nowTime = new Date().getTime(); var timediff = parseInt((lastTime - nowTime) / 1000); if(timediff > 0) { var d = Math.floor(timediff / 3600 / 24); var h = Math.floor((timediff - d * 24 * 3600) / 3600); var m = Math.floor((timediff - d * 24 * 3600 - h * 3600) / 60); var s = Math.floor((timediff - d * 24 * 3600 - h * 3600 - m * 60)); var countdown = ""; if(d != 0) { if(d < 10) { countdown = countdown + "" + "0" + d + "天" } else { countdown = countdown + "" + "0" + d + "天" }; } if(h != 0) { if(h < 10) { countdown = countdown + "" + "0" + h + "小时" } else { countdown = countdown + "" + h + "小时" }; } if(m < 10) { countdown = countdown + "" + "0" + m + "分" } else { countdown = countdown + "" + m + "分" }; if(s < 10) { countdown = countdown + "" + "0" + s + "秒" } else { countdown = countdown + "" + s + "秒" }; if(s < 10) { s = "" + "0" + s }; return countdown; } else { return false; } } //返回时间差格式 function getTimediff(t, n) { var lastTime = new Date(t).getTime(); var nowTime = new Date(n).getTime(); var timediff = parseInt((lastTime - nowTime) / 1000); if(timediff > 0) { var d = Math.floor(timediff / 3600 / 24); var h = Math.floor((timediff - d * 24 * 3600) / 3600); var m = Math.floor((timediff - d * 24 * 3600 - h * 3600) / 60); var s = Math.floor((timediff - d * 24 * 3600 - h * 3600 - m * 60)); if(d < 10 && d >= 0) { d = "0" + d; }; if(h < 10 && h >= 0) { h = "0" + h; }; if(m < 10 && m >= 0) { m = "0" + m; }; if(s < 10 && s >= 0) { s = "0" + s; }; return { d: d, h: h, m: m, s: s }; } else { return false; } } //获取[min,max]之间的随机数 function getRandomNum(min,max){ var num=Math.floor(Math.random()*(max-min+1)+min); return num; } //设为首页 function setHome(){ var url=window.location.href; try{ document.body.style.behavior='url(#default#homepage)'; document.body.setHomePage(url); }catch(e){ if(window.netscape){ try{ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }catch(e){ alert("抱歉,此操作被浏览器拒绝!\n\n请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'"); } }else{ alert("抱歉,您所使用的浏览器无法完成此操作。\n\n您需要手动将【"+url+"】设置为首页。"); } } } //收藏本站 function addFavorite() { var url=window.location.href; var title=document.title; try { window.external.addFavorite(url, title); } catch (e) { try { window.sidebar.addPanel(title, url, ""); } catch (e) { alert("抱歉,您所使用的浏览器无法完成此操作。\n\n加入收藏失败,请使用Ctrl+D进行添加"); } } } //保存到桌面 function toDesktop(){ var sUrl=window.location.href; var sName=document.title; try { var WshShell = new ActiveXObject("WScript.Shell"); var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "\\" + sName + ".url"); oUrlLink.TargetPath = sUrl; oUrlLink.Save(); } catch(e){ alert("当前安全级别不允许操作!"); } } //格式化小球数据 function formatBallList(balllist) { if(balllist && balllist.length > 0) { balllist.forEach(function(curData, index) { switch(curData.BallType) { case 1: curData.BallType = 'red'; break; case 2: curData.BallType = 'blue'; break; case 3: curData.BallType = 'shengxiao'; switch(curData.OpenCode) { case '01': curData.OpenCode = '鼠'; break; case '02': curData.OpenCode = '牛'; break; case '03': curData.OpenCode = '虎'; break; case '04': curData.OpenCode = '兔'; break; case '05': curData.OpenCode = '龙'; break; case '06': curData.OpenCode = '蛇'; break; case '07': curData.OpenCode = '马'; break; case '08': curData.OpenCode = '羊'; break; case '09': curData.OpenCode = '猴'; break; case '10': curData.OpenCode = '鸡'; break; case '11': curData.OpenCode = '狗'; break; case '12': curData.OpenCode = '猪'; break; } break; case 4: curData.BallType = 'jijie'; switch(curData.OpenCode) { case '01': curData.OpenCode = '春'; break; case '02': curData.OpenCode = '夏'; break; case '03': curData.OpenCode = '秋'; break; case '04': curData.OpenCode = '冬'; break; } break; case 5: curData.BallType = 'fangwei'; switch(curData.OpenCode) { case '01': curData.OpenCode = '东'; break; case '02': curData.OpenCode = '南'; break; case '03': curData.OpenCode = '西'; break; case '04': curData.OpenCode = '北'; break; } break; case 6:curData.BallType="PK3"; switch(curData.OpenCode.substring(0,1)){ case '1':curData.OpenIcon='fangpian';break; case '2':curData.OpenIcon='hongtao';break; case '3':curData.OpenIcon='meihua';break; case '4':curData.OpenIcon='heitao';break; } switch(curData.OpenCode.substring(1)){ case '01':curData.openCode='A';break; case '02':curData.openCode='2';break; case '03':curData.openCode='3';break; case '04':curData.openCode='4';break; case '05':curData.openCode='5';break; case '06':curData.openCode='6';break; case '07':curData.openCode='7';break; case '08':curData.openCode='8';break; case '09':curData.openCode='9';break; case '10':curData.openCode='10';break; case '11':curData.openCode='J';break; case '12':curData.openCode='Q';break; case '13':curData.openCode='K';break; } break; } }); } }