262 lines
7.7 KiB
JavaScript
262 lines
7.7 KiB
JavaScript
(function flexible (window, document) {
|
|
var docEl = document.documentElement
|
|
var dpr = window.devicePixelRatio || 1
|
|
// console.log(dpr)
|
|
// adjust body font size
|
|
function setBodyFontSize () {
|
|
if (document.body) {
|
|
document.body.style.fontSize = (12 * dpr) + 'px'
|
|
}
|
|
else {
|
|
document.addEventListener('DOMContentLoaded', setBodyFontSize)
|
|
}
|
|
}
|
|
setBodyFontSize();
|
|
|
|
// set 1rem = viewWidth / 10
|
|
function setRemUnit () {
|
|
var rem = docEl.clientWidth / 10
|
|
docEl.style.fontSize = rem + 'px'
|
|
}
|
|
|
|
setRemUnit()
|
|
|
|
// reset rem unit on page resize
|
|
window.addEventListener('resize', setRemUnit)
|
|
window.addEventListener('pageshow', function (e) {
|
|
if (e.persisted) {
|
|
setRemUnit()
|
|
}
|
|
})
|
|
|
|
// detect 0.5px supports
|
|
if (dpr >= 2) {
|
|
var fakeBody = document.createElement('body')
|
|
var testElement = document.createElement('div')
|
|
testElement.style.border = '.5px solid transparent'
|
|
fakeBody.appendChild(testElement)
|
|
docEl.appendChild(fakeBody)
|
|
if (testElement.offsetHeight === 1) {
|
|
docEl.classList.add('hairlines')
|
|
}
|
|
docEl.removeChild(fakeBody)
|
|
}
|
|
}(window, document))
|
|
|
|
|
|
// 定时器弹窗提示
|
|
function alert_box(ale_dynamic,d_time){
|
|
$(".a_lert").remove();
|
|
$("body").append('<div class="a_lert"><div class="a_box"><p></p></div></div>');
|
|
$(".a_lert .a_box p").append(ale_dynamic);
|
|
var d_time = d_time || 3000;
|
|
setTimeout(function(){
|
|
$(".a_lert").remove();
|
|
},d_time);
|
|
}
|
|
|
|
|
|
var pop=new Object
|
|
pop.alert=function (i){
|
|
$(".pop").remove();
|
|
if(i.btn == undefined){
|
|
i.btn = "确定";
|
|
}
|
|
$("body").append(
|
|
'<div class="pop"> <div class="pop-box">'+
|
|
'<p class="txt">'+i.content+'</p>'+
|
|
'<button class="btn off-btn">'+i.btn+'</button> </div>'+
|
|
'</div>')
|
|
$(document).on("click",".off-btn",function(){
|
|
var transmit=i.yes
|
|
if(transmit!=undefined && transmit!=""){
|
|
transmit();
|
|
}
|
|
$(".pop").remove();
|
|
})
|
|
}
|
|
|
|
$(function(){
|
|
$(".play .video-box .linechange").click(function(){
|
|
$(this).fadeOut(100,function(){
|
|
$(".play .video-box .linebox").css("display","block");
|
|
$(".play .video-box .linebox").stop().animate({"left":"0"},300)
|
|
})
|
|
})
|
|
$("#media_area").click(function(){
|
|
$(".play .video-box .linebox").stop().animate({"left":"-100%"},300).fadeOut()
|
|
$(".play .video-box .linechange").fadeIn()
|
|
})
|
|
|
|
$(".play .video-box .linebox span").click(function(){
|
|
$(this).addClass("active").siblings("span").removeClass("active")
|
|
})
|
|
|
|
|
|
var u = navigator.userAgent;
|
|
var audiobutn=false;
|
|
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
|
|
//安卓手机
|
|
|
|
} else if (u.indexOf('iPhone') > -1) {
|
|
audiobutn=true;
|
|
//苹果手机
|
|
$(".play .video-box .linebox p.audio").text(lang.mute)
|
|
$(".play .video-box .linebox p.audio").addClass("on")
|
|
}
|
|
$(".play .video-box .linebox p.audio").click(function(){
|
|
if(audiobutn==true){
|
|
$(this).removeClass("on")
|
|
$(this).text(lang.mute)
|
|
$("#audio").get(0).muted = false
|
|
|
|
audiobutn=false;
|
|
}else{
|
|
$(this).addClass("on")
|
|
audiobutn=true;
|
|
$(this).text(lang.voice)
|
|
$("#audio").get(0).muted = true
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
// // ------------------桌子状态及声音
|
|
|
|
var countDown = function (waitTime){
|
|
$("#second").html(waitTime);
|
|
window.count = waitTime;
|
|
if(waitTime == 5){
|
|
$(".play .video-box .countdown").addClass("slow");
|
|
}
|
|
}
|
|
function stopTheTime(auto){
|
|
audioShow('stopBet');
|
|
$(".play .video-box .countdown").removeClass("slow");
|
|
$(".countdown").hide();
|
|
if(auto==true){
|
|
console.log(auto)
|
|
$(".play .begincard").fadeIn(100,function(){
|
|
$(".play .begincard .box").animate({"top":"50%","opacity":"1"})
|
|
});
|
|
}
|
|
}
|
|
var setBetStatus = function (number_tab_status){
|
|
if(number_tab_status.type == 1){
|
|
//桌子停台状态或者洗牌状态
|
|
Maskplay(number_tab_status.msg,number_tab_status.in_checkout);
|
|
}else if(number_tab_status.type == 2){
|
|
Maskplay();
|
|
$('#number_tab_status').val(number_tab_status.betStatus);
|
|
}
|
|
};
|
|
var setNumberInfo = function (round){
|
|
$('#table_id').val(round.tid);
|
|
$('#boot_dt_id').val(round.boot_id);
|
|
$('#boot_num').html(round.boot_num);
|
|
$('#number_tab_dt_id').val(round.number_tab_id);
|
|
$('#number').html(round.number_tab_number - 1);
|
|
};
|
|
/* 桌子为停台中获知洗牌中的页面状态 */
|
|
function Maskplay(msg,state){
|
|
msg=msg||'';
|
|
state=state||0;
|
|
if(state == 1 || state == 2){
|
|
var table_state = 'table_status_' + state;
|
|
$('body').append('<div class="Maskplay"><span class="msgbox">'+lang[table_state]+'</span>'+'</div>');
|
|
}else{
|
|
$('body').find(".Maskplay").remove();
|
|
}
|
|
}
|
|
// 获取桌子状态 下注状态
|
|
function getState(tableId,userId){
|
|
var getStateData='{"connect":"client","mode":"getState","table_id":'+tableId+',"userid":'+userId+'}';
|
|
webSocket.send(getStateData);
|
|
}
|
|
|
|
|
|
// var audio=$("#audio").get(0);
|
|
// var mp3List;
|
|
// var num=0;
|
|
|
|
// function audioMp3(mp3List){
|
|
// var mp3=new Object();
|
|
// mp3.mp3List=mp3List;
|
|
// mp3.url="/static/online/mp3/";
|
|
// mp3.auto_play=false;
|
|
// mp3.loop=false;
|
|
|
|
// mp3.Play=function(){
|
|
// audio.src=this.url+this.mp3List[0];
|
|
// audio.play();
|
|
// }
|
|
// mp3.Muted=function(){
|
|
// audio.muted ? audio.muted = false : audio.muted = true;
|
|
// }
|
|
// mp3.volumeAdd=function(){
|
|
// if(audio.volume.toFixed(1)>=1){
|
|
// audio.volume=1
|
|
// }else{
|
|
// audio.volume = audio.volume + 0.1;
|
|
// }
|
|
// }
|
|
// mp3.volumeMinus=function(){
|
|
// if(audio.volume.toFixed(1)<=0){
|
|
// audio.volume=0
|
|
// }else{
|
|
// audio.volume = audio.volume - 0.1;
|
|
// }
|
|
// }
|
|
// return mp3;
|
|
// }
|
|
// if(audio!=undefined){
|
|
// audio.addEventListener("ended", nextAudio);
|
|
// }
|
|
|
|
// function nextAudio(){
|
|
// num+=1
|
|
// if(num<mp3List.length){
|
|
// audio.src="/static/online/mp3/"+mp3List[num];
|
|
// audio.play();
|
|
// }else{
|
|
// audio.pause();
|
|
// audio.currentTime = 0.0;
|
|
// num=0;
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// var setShowBet = function (showBet){
|
|
// var old_now_player = parseInt($('#now_player').html()) > 0 ? parseInt($('#now_player').html()) : 0;
|
|
// var old_now_playerpair = parseInt($('#now_playerpair').html()) > 0 ? parseInt($('#now_playerpair').html()) : 0;
|
|
// var old_now_tie = parseInt($('#now_tie').html()) > 0 ? parseInt($('#now_tie').html()) : 0;
|
|
// var old_now_banker = parseInt($('#now_banker').html()) > 0 ? parseInt($('#now_banker').html()) : 0;
|
|
// var old_now_bankerpair = parseInt($('#now_bankerpair').html()) > 0 ? parseInt($('#now_bankerpair').html()) : 0;
|
|
// showBet.player_amount = showBet.player_amount > 0 ? showBet.player_amount : 0;
|
|
// showBet.player_pair_amount = showBet.player_pair_amount > 0 ? showBet.player_pair_amount : 0;
|
|
// showBet.tie_amount = showBet.tie_amount > 0 ? showBet.tie_amount : 0;
|
|
// showBet.banker_amount = showBet.banker_amount > 0 ? showBet.banker_amount : 0;
|
|
// showBet.banker_pair_amount = showBet.banker_pair_amount > 0 ? showBet.banker_pair_amount : 0;
|
|
// $('#now_player').html(showBet.player_amount + old_now_player);
|
|
// $('#now_playerpair').html(showBet.player_pair_amount + old_now_playerpair);
|
|
// $('#now_tie').html(showBet.tie_amount + old_now_tie);
|
|
// $('#now_banker').html(showBet.banker_amount + old_now_banker);
|
|
// $('#now_bankerpair').html(showBet.banker_pair_amount + old_now_bankerpair);
|
|
// }
|
|
// var clearShowBet = function (){
|
|
// $('#now_player').html('0');
|
|
// $('#now_playerpair').html('0');
|
|
// $('#now_tie').html('0');
|
|
// $('#now_banker').html('0');
|
|
// $('#now_bankerpair').html('0');
|
|
// }
|
|
|
|
|