init: 从宝塔同步到 Gitea
This commit is contained in:
@@ -0,0 +1,707 @@
|
||||
var getOnlineNumber = function (connections){
|
||||
var query = new Object();
|
||||
query.connections = connections;
|
||||
$.ajax({
|
||||
url:'/index/get_online_number',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
$('#onlineNumber').html(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var getResultToatl = function (TableId,BootId){
|
||||
var query = new Object();
|
||||
query.table_id = TableId;
|
||||
query.boot_id = BootId;
|
||||
$.ajax({
|
||||
url:'/index/get_result_total',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
var resultToatl = data.data;
|
||||
$('#result_total_player').html(resultToatl.player);
|
||||
$('#result_total_banker').html(resultToatl.banker);
|
||||
$('#result_total_tie').html(resultToatl.tie);
|
||||
$('#result_total_bankerpair').html(resultToatl.bankerPair);
|
||||
$('#result_total_playerpair').html(resultToatl.playerPair);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var showPng = function (opening, pair){
|
||||
if(opening == 1 && pair == 0) $('#openingPng').attr('src','/static/console/img/banker.png');
|
||||
if(opening == 1 && pair == 1) $('#openingPng').attr('src','/static/console/img/banker_bankerpair.png');
|
||||
if(opening == 1 && pair == 2) $('#openingPng').attr('src','/static/console/img/banker_playerpair.png');
|
||||
if(opening == 1 && pair == 3) $('#openingPng').attr('src','/static/console/img/banker_bothpair.png');
|
||||
|
||||
if(opening == 2 && pair == 0) $('#openingPng').attr('src','/static/console/img/player.png');
|
||||
if(opening == 2 && pair == 1) $('#openingPng').attr('src','/static/console/img/player_bankerpair.png');
|
||||
if(opening == 2 && pair == 2) $('#openingPng').attr('src','/static/console/img/player_playerpair.png');
|
||||
if(opening == 2 && pair == 3) $('#openingPng').attr('src','/static/console/img/player_bothpair.png');
|
||||
|
||||
if(opening == 3 && pair == 0) $('#openingPng').attr('src','/static/console/img/tie.png');
|
||||
if(opening == 3 && pair == 1) $('#openingPng').attr('src','/static/console/img/tie_bankerpair.png');
|
||||
if(opening == 3 && pair == 2) $('#openingPng').attr('src','/static/console/img/tie_playerpair.png');
|
||||
if(opening == 3 && pair == 3) $('#openingPng').attr('src','/static/console/img/tie_bothpair.png');
|
||||
$('#openingElement').show().delay(1000).hide(300);
|
||||
}
|
||||
$(document).on("click","#next_banker",function(){
|
||||
var next = new Object;
|
||||
next.result = 'banker';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
$(document).on("click","#next_player",function(){
|
||||
var next = new Object;
|
||||
next.result = 'player';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.result = "allData";
|
||||
data.table = TableId;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
console.log(data);
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(window).resize(function(){
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
});
|
||||
|
||||
// canvas 路单
|
||||
function resizeCanvas(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single1'),
|
||||
ctb=table.getContext('2d');
|
||||
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
|
||||
Tab_w=tab_width/tab_cols
|
||||
tab_height=Tab_w*tab_rows||183
|
||||
Font_Size =Math.floor(Tab_w/1.8)+"px Arial"
|
||||
Font_Size_s=Math.floor(Tab_w/2.8)+"px Arial"
|
||||
|
||||
$("#single1").attr("height",tab_height+0.4)
|
||||
$("#single1").attr("width",canvaswidth+0.4)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var twin=twinkledata.bigRoad.show_location,
|
||||
twinlength=twin.length-1
|
||||
twinkle(ctb,twin[twinlength].show_x,twin[twinlength].show_y,twin[twinlength].result);
|
||||
}
|
||||
// 获取本地session里的路单数据
|
||||
var waybill = ludan;
|
||||
if(waybill == false) return false;
|
||||
var bigRoad = waybill.bigRoad;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 第一局为和,大路展示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined && showRoad.first_tie_num != undefined && showRoad.first_tie_num > 0){
|
||||
b_Tie(showRoad.first_tie_num);
|
||||
}
|
||||
//if(bigRoad.first_tie_num == 1 && bigRoad.show_location.length == 1){
|
||||
// b_Tie(bigRoad.show_location[0].tie_num);
|
||||
//}
|
||||
|
||||
// 大路路单展示
|
||||
if( bigRoad != undefined && bigRoad.show_location != undefined){
|
||||
for(var i=0; i<bigRoad.show_location.length; i++){
|
||||
//庄赢
|
||||
if(bigRoad.show_location[i].result == "banker"){
|
||||
// 判断是否有和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2);
|
||||
}
|
||||
}
|
||||
|
||||
// 闲赢
|
||||
if(bigRoad.show_location[i].result == "player"){
|
||||
// 判断是否是和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1);
|
||||
}
|
||||
}
|
||||
// 和
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
if(bigRoad.first_tie_num != undefined && bigRoad.first_tie_num == 1 && i == 0 && bigRoad.show_location[i].result == 'tie'){
|
||||
b_Tie(bigRoad.show_location[i].tie_num)
|
||||
}else{
|
||||
if(bigRoad.show_location[i].result == 'banker'){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctb.closePath();
|
||||
// 局数 数,文字X坐标,文字Y坐标,文字大小风格
|
||||
function Font_tie(num,Font_x,Font_y,fontsize){
|
||||
if(num!==undefined){
|
||||
ctb.beginPath();
|
||||
ctb.font=fontsize;
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillStyle ="#000" ;
|
||||
ctb.fillText(num,Font_x,Font_y);
|
||||
ctb.stroke();
|
||||
}
|
||||
}
|
||||
function b_Tab(x,y,type,slash,order){
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(Tab_w*x_z-Tab_w/2.1, Tab_w*y_z-Tab_w/2.1, Tab_w*0.9, Tab_w*0.9);
|
||||
if(type=="1"){
|
||||
var color="#331a98";
|
||||
}else if(type=="2"){
|
||||
var color="#fb2603"
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;
|
||||
ctb.strokeStyle = color;
|
||||
ctb.arc(Tab_w*x_z-0.5, Tab_w*y_z-0.5, Tab_w*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
|
||||
|
||||
if(slash=="1"){
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
ctb.lineCap = "round";
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.moveTo(x_z*Tab_w-linewidth,Tab_w*y_z+linewidth);
|
||||
ctb.lineTo(x_z*Tab_w+linewidth,Tab_w*y_z-linewidth);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w*x_z, Tab_w*y_z,Font_Size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// b区第一局 和
|
||||
function b_Tie(order){
|
||||
ctb.clearRect(Tab_w/20, 1, Tab_w*0.9, Tab_w*0.9);
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 3.5;//线条宽度
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.lineCap = "round";
|
||||
ctb.moveTo(Tab_w/20,Tab_w/2);
|
||||
ctb.lineTo(Tab_w*0.9,Tab_w/2);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w/2, Tab_w/2,Font_Size);
|
||||
}
|
||||
// 问路
|
||||
function twinkle(ctb,show_x,show_y,result){
|
||||
var b=10
|
||||
num1=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num1);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
if(result=="banker"){
|
||||
b_Tab(show_x,show_y,2)
|
||||
}else if(result=="player"){
|
||||
b_Tab(show_x,show_y,1)
|
||||
}
|
||||
// // 数据
|
||||
ctb.globalAlpha=0.5
|
||||
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas2(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single2'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
tab_b_cols = 6,
|
||||
Tab_w=tab_width/tab_cols,
|
||||
tab_height=Tab_w*tab_rows||183;
|
||||
|
||||
$("#single2").attr("height",tab_height+0.8)
|
||||
$("#single2").attr("width",canvaswidth+0.4)
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
var waybill = ludan;
|
||||
if(!waybill) return false;
|
||||
var bigEyeRoad = waybill.bigEyeRoad; // 大眼路数据
|
||||
var pathway = waybill.pathway; // 小路数据
|
||||
var roach = waybill.roach;
|
||||
// 小强路数据
|
||||
if(twinkledata!=undefined){
|
||||
twinkle(ctb,twinkledata);
|
||||
}
|
||||
|
||||
// 大眼路数据
|
||||
if(bigEyeRoad != undefined && bigEyeRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<bigEyeRoad.show_location.length; i++){
|
||||
// 红圈
|
||||
if(bigEyeRoad.show_location[i].result == 'red'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(bigEyeRoad.show_location[i].result == 'blue'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 小路数据
|
||||
if(pathway != undefined && pathway.show_location != undefined){
|
||||
|
||||
for(var i=0; i<pathway.show_location.length; i++){
|
||||
// 红圈
|
||||
if(pathway.show_location[i].result == 'red'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(pathway.show_location[i].result == 'blue'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 小强路数据
|
||||
if(roach != undefined && roach.show_location != undefined){
|
||||
|
||||
for(var i=0; i<roach.show_location.length; i++){
|
||||
// 红圈
|
||||
if(roach.show_location[i].result == 'red'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(roach.show_location[i].result == 'blue'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
// c区
|
||||
function c_Tab(x,y,type){
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), tab_c*(y-1), tab_c, tab_c);
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;
|
||||
ctb.arc(tab_c*x_z, tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
|
||||
// d区
|
||||
function d_Tab(x,y,type){
|
||||
|
||||
var d_y=Tab_w*tab_b_cols/2,
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), d_y+tab_c*(y-1), tab_c, tab_c);
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.2;
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
ctb.fillStyle='#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
ctb.fillStyle='#ff0000';
|
||||
}
|
||||
ctb.arc(tab_c*x_z, d_y+tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// e区
|
||||
function e_Tab(x,y,type){
|
||||
var d_x=20*Tab_w,
|
||||
linewidth=Tab_w/3;
|
||||
x_z=x-0.2,
|
||||
y_z=y-0.2,
|
||||
tab_d_x=Tab_w/2;
|
||||
ctb.clearRect(d_x+tab_d_x*(x-1), tab_d_x*(y-1), tab_d_x, tab_d_x);
|
||||
ctb.beginPath();
|
||||
ctb.lineCap = "butt";
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
|
||||
//线条颜色
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#331a98';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#fd2203';
|
||||
}
|
||||
|
||||
ctb.moveTo(d_x+tab_d_x*x_z,linewidth+tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.lineTo(d_x-linewidth+tab_d_x*x_z,tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,twinkledata){
|
||||
var b=10,
|
||||
bigEyeRoad=twinkledata.bigEyeRoad.show_location,
|
||||
pathway=twinkledata.pathway.show_location,
|
||||
roach=twinkledata.roach.show_location
|
||||
|
||||
|
||||
num2=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num2);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
//
|
||||
if(bigEyeRoad!=undefined){
|
||||
var bigEyeRoadlength=bigEyeRoad.length-1
|
||||
if(bigEyeRoad[bigEyeRoadlength].result=="blue"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,1)
|
||||
}else if(bigEyeRoad[bigEyeRoadlength].result=="red"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,2)
|
||||
}
|
||||
}
|
||||
|
||||
if(pathway!=undefined){
|
||||
var pathwaylength=pathway.length-1
|
||||
if(pathway[pathwaylength].result=="blue"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,1)
|
||||
}else if(pathway[pathwaylength].result=="red"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,2)
|
||||
}
|
||||
}
|
||||
|
||||
if(roach!=undefined){
|
||||
var roachlength=roach.length-1
|
||||
if(roach[roachlength].result=="blue"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,1)
|
||||
}else if(roach[roachlength].result=="red"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,2)
|
||||
}
|
||||
}
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas3(show_x,show_y,type,corners,twinkledata){
|
||||
|
||||
var canvaswidth= $(".baccarat_head").width()*0.5;
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single3'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=20,
|
||||
tab_rows=6,
|
||||
|
||||
tab_x=tab_width/tab_cols
|
||||
tab_y=tab_x,
|
||||
tab_height=tab_y*tab_rows
|
||||
|
||||
$("#single3").attr("height",tab_height+1)
|
||||
$("#single3").attr("width",canvaswidth+0.5)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,tab_x);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var showRoads=twinkledata.showRoad.show_location
|
||||
showRoadlength=showRoads.length-1
|
||||
twinkle(ctb,showRoads[showRoadlength].show_x,showRoads[showRoadlength].show_y,showRoads[showRoadlength].result,showRoads[showRoadlength].pair);
|
||||
}
|
||||
|
||||
var show_x=show_x,
|
||||
show_y=show_y;
|
||||
type=type
|
||||
if(show_x!=""||undefined){
|
||||
Tab(show_x,show_y,type,corners);
|
||||
}
|
||||
var waybill = ludan;
|
||||
|
||||
if(!waybill) return false;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 展示路的路单显示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<showRoad.show_location.length; i++){
|
||||
|
||||
if(showRoad.show_location[i].result == "banker"){
|
||||
// 展示路
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "player"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "tie"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
function Tab(x,y,type,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
var x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_x*(x-1), tab_x*(y-1), tab_x, tab_x);
|
||||
if(type=="banker"){
|
||||
var color='#e12217',
|
||||
fonts='庄';
|
||||
}else if(type=="player"){
|
||||
var color='#0030ff',
|
||||
fonts='闲';
|
||||
}else if(type=="tie"){
|
||||
var color='#27cf00',
|
||||
fonts='和';
|
||||
}
|
||||
ctb.arc(tab_x*x_z, tab_x*y_z, tab_x*0.45, 0, Math.PI * 2);
|
||||
ctb.fillStyle=color;
|
||||
ctb.fill();
|
||||
Font_Size =Math.floor(tab_x/1.8)+"px Arial"
|
||||
ctb.font=Font_Size;
|
||||
ctb.fillStyle ="#fff" ; // 颜色
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,tab_x*x_z,tab_x*y_z);
|
||||
ctb.stroke();
|
||||
var corner_xy=tab_x/3.2
|
||||
if(corners=="1"){
|
||||
corner(x_z,y_z,corner_xy,'#1944ff');
|
||||
}else if(corners=="2"){
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}else if(corners=="3"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
}else if(corners=="4"){
|
||||
corner(x_z,y_z,-corner_xy,'#ff2202');
|
||||
}else if(corners=="5"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}
|
||||
}
|
||||
|
||||
// a区角标
|
||||
function corner(x_z,y_z,corner_xy,corner_color){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
ctb.arc(tab_x*x_z-corner_xy, tab_x*y_z-corner_xy, tab_x*0.14, 0, Math.PI * 2);
|
||||
ctb.fillStyle=corner_color;
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,show_x,show_y,result,pair){
|
||||
var b=10
|
||||
num3=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num3);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
// Tab(1,1,"banker",2)
|
||||
Tab(show_x,show_y,result)
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
/* 时钟 */
|
||||
function startTime(){
|
||||
var today=new Date();
|
||||
var yyyy = today.getFullYear();
|
||||
var MM = today.getMonth()+1;
|
||||
var dd = today.getDate();
|
||||
var hh=today.getHours();
|
||||
var mm=today.getMinutes();
|
||||
var ss=today.getSeconds();
|
||||
MM=checkTime(MM);
|
||||
dd=checkTime(dd);
|
||||
mm=checkTime(mm);
|
||||
ss=checkTime(ss);
|
||||
var day;
|
||||
if(today.getDay()==0) day = "星期日"
|
||||
if(today.getDay()==1) day = "星期一"
|
||||
if(today.getDay()==2) day = "星期二"
|
||||
if(today.getDay()==3) day = "星期三"
|
||||
if(today.getDay()==4) day = "星期四"
|
||||
if(today.getDay()==5) day = "星期五"
|
||||
if(today.getDay()==6) day = "星期六"
|
||||
$('#nowDateSpan').html( yyyy+"-"+MM +"-"+ dd);
|
||||
$('#nowTimeSpan').html(hh+":"+mm+":"+ss);
|
||||
$('#nowWeekSpan').html(day);
|
||||
setTimeout('startTime()',1000);
|
||||
}
|
||||
function checkTime(i){
|
||||
if (i<10){
|
||||
i="0" + i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/* 时钟 end */
|
||||
|
||||
function canvasbg(ctb,CanvasId,tab_width,tab_height,tab_rows,tab_cols,Tab_w) {
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#999";
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(tab_width, 0.5);
|
||||
for (var col = 1; col <= tab_rows; col++) {
|
||||
var y = col * Tab_w;
|
||||
ctb.moveTo(0,y-0.5);
|
||||
ctb.lineTo(tab_width,y-0.5);
|
||||
}
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, tab_height);
|
||||
for (var row = 1; row <= tab_cols; row++) {
|
||||
var x = row * Tab_w;
|
||||
ctb.moveTo(x-0.5,0);
|
||||
ctb.lineTo(x-0.5,tab_height);
|
||||
}
|
||||
ctb.stroke();
|
||||
var image = new Image();
|
||||
image.src = CanvasId.toDataURL("image/png");
|
||||
CanvasId.style.backgroundImage = 'url(' + image.src +')';
|
||||
ctb.clearRect(0, 0, 10000, 10000);
|
||||
}
|
||||
|
||||
|
||||
function audio(url){
|
||||
var mp3="../static/index/mp3/"+url;
|
||||
var audiohtml= '<audio style="visibility: hidden;" id="chatAudio"><source src="'+mp3+'" type="audio/mpeg"></audio>'
|
||||
$(audiohtml).appendTo('body');
|
||||
$("#chatAudio")[0].play()
|
||||
setTimeout(function(){
|
||||
$("#chatAudio").remove();
|
||||
},1000);
|
||||
}
|
||||
@@ -0,0 +1,707 @@
|
||||
var getOnlineNumber = function (connections){
|
||||
var query = new Object();
|
||||
query.connections = connections;
|
||||
$.ajax({
|
||||
url:'/index/get_online_number',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
$('#onlineNumber').html(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var getResultToatl = function (TableId,BootId){
|
||||
var query = new Object();
|
||||
query.table_id = TableId;
|
||||
query.boot_id = BootId;
|
||||
$.ajax({
|
||||
url:'/index/get_result_total',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
var resultToatl = data.data;
|
||||
$('#result_total_player').html(resultToatl.player);
|
||||
$('#result_total_banker').html(resultToatl.banker);
|
||||
$('#result_total_tie').html(resultToatl.tie);
|
||||
$('#result_total_bankerpair').html(resultToatl.bankerPair);
|
||||
$('#result_total_playerpair').html(resultToatl.playerPair);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var showPng = function (opening, pair){
|
||||
if(opening == 1 && pair == 0) $('#openingPng').attr('src','/static/console/img/banker.png');
|
||||
if(opening == 1 && pair == 1) $('#openingPng').attr('src','/static/console/img/banker_bankerpair.png');
|
||||
if(opening == 1 && pair == 2) $('#openingPng').attr('src','/static/console/img/banker_playerpair.png');
|
||||
if(opening == 1 && pair == 3) $('#openingPng').attr('src','/static/console/img/banker_bothpair.png');
|
||||
|
||||
if(opening == 2 && pair == 0) $('#openingPng').attr('src','/static/console/img/player.png');
|
||||
if(opening == 2 && pair == 1) $('#openingPng').attr('src','/static/console/img/player_bankerpair.png');
|
||||
if(opening == 2 && pair == 2) $('#openingPng').attr('src','/static/console/img/player_playerpair.png');
|
||||
if(opening == 2 && pair == 3) $('#openingPng').attr('src','/static/console/img/player_bothpair.png');
|
||||
|
||||
if(opening == 3 && pair == 0) $('#openingPng').attr('src','/static/console/img/tie.png');
|
||||
if(opening == 3 && pair == 1) $('#openingPng').attr('src','/static/console/img/tie_bankerpair.png');
|
||||
if(opening == 3 && pair == 2) $('#openingPng').attr('src','/static/console/img/tie_playerpair.png');
|
||||
if(opening == 3 && pair == 3) $('#openingPng').attr('src','/static/console/img/tie_bothpair.png');
|
||||
$('#openingElement').show().delay(1000).hide(300);
|
||||
}
|
||||
$(document).on("click","#next_banker",function(){
|
||||
var next = new Object;
|
||||
next.result = 'banker';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
$(document).on("click","#next_player",function(){
|
||||
var next = new Object;
|
||||
next.result = 'player';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.result = "allData";
|
||||
data.table = TableId;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
console.log(data);
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(window).resize(function(){
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
});
|
||||
|
||||
// canvas 路单
|
||||
function resizeCanvas(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single1'),
|
||||
ctb=table.getContext('2d');
|
||||
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
|
||||
Tab_w=tab_width/tab_cols
|
||||
tab_height=Tab_w*tab_rows||183
|
||||
Font_Size =Math.floor(Tab_w/1.8)+"px Arial"
|
||||
Font_Size_s=Math.floor(Tab_w/2.8)+"px Arial"
|
||||
|
||||
$("#single1").attr("height",tab_height+0.4)
|
||||
$("#single1").attr("width",canvaswidth+0.4)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var twin=twinkledata.bigRoad.show_location,
|
||||
twinlength=twin.length-1
|
||||
twinkle(ctb,twin[twinlength].show_x,twin[twinlength].show_y,twin[twinlength].result);
|
||||
}
|
||||
// 获取本地session里的路单数据
|
||||
var waybill = ludan;
|
||||
if(waybill == false) return false;
|
||||
var bigRoad = waybill.bigRoad;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 第一局为和,大路展示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined && showRoad.first_tie_num != undefined && showRoad.first_tie_num > 0){
|
||||
b_Tie(showRoad.first_tie_num);
|
||||
}
|
||||
//if(bigRoad.first_tie_num == 1 && bigRoad.show_location.length == 1){
|
||||
// b_Tie(bigRoad.show_location[0].tie_num);
|
||||
//}
|
||||
|
||||
// 大路路单展示
|
||||
if( bigRoad != undefined && bigRoad.show_location != undefined){
|
||||
for(var i=0; i<bigRoad.show_location.length; i++){
|
||||
//庄赢
|
||||
if(bigRoad.show_location[i].result == "banker"){
|
||||
// 判断是否有和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2);
|
||||
}
|
||||
}
|
||||
|
||||
// 闲赢
|
||||
if(bigRoad.show_location[i].result == "player"){
|
||||
// 判断是否是和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1);
|
||||
}
|
||||
}
|
||||
// 和
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
if(bigRoad.first_tie_num != undefined && bigRoad.first_tie_num == 1 && i == 0 && bigRoad.show_location[i].result == 'tie'){
|
||||
b_Tie(bigRoad.show_location[i].tie_num)
|
||||
}else{
|
||||
if(bigRoad.show_location[i].result == 'banker'){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctb.closePath();
|
||||
// 局数 数,文字X坐标,文字Y坐标,文字大小风格
|
||||
function Font_tie(num,Font_x,Font_y,fontsize){
|
||||
if(num!==undefined){
|
||||
ctb.beginPath();
|
||||
ctb.font=fontsize;
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillStyle ="#000" ;
|
||||
ctb.fillText(num,Font_x,Font_y);
|
||||
ctb.stroke();
|
||||
}
|
||||
}
|
||||
function b_Tab(x,y,type,slash,order){
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(Tab_w*x_z-Tab_w/2.1, Tab_w*y_z-Tab_w/2.1, Tab_w*0.9, Tab_w*0.9);
|
||||
if(type=="1"){
|
||||
var color="#331a98";
|
||||
}else if(type=="2"){
|
||||
var color="#fb2603"
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;
|
||||
ctb.strokeStyle = color;
|
||||
ctb.arc(Tab_w*x_z-0.5, Tab_w*y_z-0.5, Tab_w*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
|
||||
|
||||
if(slash=="1"){
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
ctb.lineCap = "round";
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.moveTo(x_z*Tab_w-linewidth,Tab_w*y_z+linewidth);
|
||||
ctb.lineTo(x_z*Tab_w+linewidth,Tab_w*y_z-linewidth);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w*x_z, Tab_w*y_z,Font_Size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// b区第一局 和
|
||||
function b_Tie(order){
|
||||
ctb.clearRect(Tab_w/20, 1, Tab_w*0.9, Tab_w*0.9);
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 3.5;//线条宽度
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.lineCap = "round";
|
||||
ctb.moveTo(Tab_w/20,Tab_w/2);
|
||||
ctb.lineTo(Tab_w*0.9,Tab_w/2);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w/2, Tab_w/2,Font_Size);
|
||||
}
|
||||
// 问路
|
||||
function twinkle(ctb,show_x,show_y,result){
|
||||
var b=10
|
||||
num1=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num1);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
if(result=="banker"){
|
||||
b_Tab(show_x,show_y,2)
|
||||
}else if(result=="player"){
|
||||
b_Tab(show_x,show_y,1)
|
||||
}
|
||||
// // 数据
|
||||
ctb.globalAlpha=0.5
|
||||
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas2(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single2'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
tab_b_cols = 6,
|
||||
Tab_w=tab_width/tab_cols,
|
||||
tab_height=Tab_w*tab_rows||183;
|
||||
|
||||
$("#single2").attr("height",tab_height+0.8)
|
||||
$("#single2").attr("width",canvaswidth+0.4)
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
var waybill = ludan;
|
||||
if(!waybill) return false;
|
||||
var bigEyeRoad = waybill.bigEyeRoad; // 大眼路数据
|
||||
var pathway = waybill.pathway; // 小路数据
|
||||
var roach = waybill.roach;
|
||||
// 小强路数据
|
||||
if(twinkledata!=undefined){
|
||||
twinkle(ctb,twinkledata);
|
||||
}
|
||||
|
||||
// 大眼路数据
|
||||
if(bigEyeRoad != undefined && bigEyeRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<bigEyeRoad.show_location.length; i++){
|
||||
// 红圈
|
||||
if(bigEyeRoad.show_location[i].result == 'red'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(bigEyeRoad.show_location[i].result == 'blue'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 小路数据
|
||||
if(pathway != undefined && pathway.show_location != undefined){
|
||||
|
||||
for(var i=0; i<pathway.show_location.length; i++){
|
||||
// 红圈
|
||||
if(pathway.show_location[i].result == 'red'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(pathway.show_location[i].result == 'blue'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 小强路数据
|
||||
if(roach != undefined && roach.show_location != undefined){
|
||||
|
||||
for(var i=0; i<roach.show_location.length; i++){
|
||||
// 红圈
|
||||
if(roach.show_location[i].result == 'red'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(roach.show_location[i].result == 'blue'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
// c区
|
||||
function c_Tab(x,y,type){
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), tab_c*(y-1), tab_c, tab_c);
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;
|
||||
ctb.arc(tab_c*x_z, tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
|
||||
// d区
|
||||
function d_Tab(x,y,type){
|
||||
|
||||
var d_y=Tab_w*tab_b_cols/2,
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), d_y+tab_c*(y-1), tab_c, tab_c);
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.2;
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
ctb.fillStyle='#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
ctb.fillStyle='#ff0000';
|
||||
}
|
||||
ctb.arc(tab_c*x_z, d_y+tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// e区
|
||||
function e_Tab(x,y,type){
|
||||
var d_x=20*Tab_w,
|
||||
linewidth=Tab_w/3;
|
||||
x_z=x-0.2,
|
||||
y_z=y-0.2,
|
||||
tab_d_x=Tab_w/2;
|
||||
ctb.clearRect(d_x+tab_d_x*(x-1), tab_d_x*(y-1), tab_d_x, tab_d_x);
|
||||
ctb.beginPath();
|
||||
ctb.lineCap = "butt";
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
|
||||
//线条颜色
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#331a98';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#fd2203';
|
||||
}
|
||||
|
||||
ctb.moveTo(d_x+tab_d_x*x_z,linewidth+tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.lineTo(d_x-linewidth+tab_d_x*x_z,tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,twinkledata){
|
||||
var b=10,
|
||||
bigEyeRoad=twinkledata.bigEyeRoad.show_location,
|
||||
pathway=twinkledata.pathway.show_location,
|
||||
roach=twinkledata.roach.show_location
|
||||
|
||||
|
||||
num2=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num2);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
//
|
||||
if(bigEyeRoad!=undefined){
|
||||
var bigEyeRoadlength=bigEyeRoad.length-1
|
||||
if(bigEyeRoad[bigEyeRoadlength].result=="blue"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,1)
|
||||
}else if(bigEyeRoad[bigEyeRoadlength].result=="red"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,2)
|
||||
}
|
||||
}
|
||||
|
||||
if(pathway!=undefined){
|
||||
var pathwaylength=pathway.length-1
|
||||
if(pathway[pathwaylength].result=="blue"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,1)
|
||||
}else if(pathway[pathwaylength].result=="red"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,2)
|
||||
}
|
||||
}
|
||||
|
||||
if(roach!=undefined){
|
||||
var roachlength=roach.length-1
|
||||
if(roach[roachlength].result=="blue"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,1)
|
||||
}else if(roach[roachlength].result=="red"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,2)
|
||||
}
|
||||
}
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas3(show_x,show_y,type,corners,twinkledata){
|
||||
|
||||
var canvaswidth= $(".baccarat_head").width()*0.5;
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single3'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=20,
|
||||
tab_rows=6,
|
||||
|
||||
tab_x=tab_width/tab_cols
|
||||
tab_y=tab_x,
|
||||
tab_height=tab_y*tab_rows
|
||||
|
||||
$("#single3").attr("height",tab_height+1)
|
||||
$("#single3").attr("width",canvaswidth+0.5)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,tab_x);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var showRoads=twinkledata.showRoad.show_location
|
||||
showRoadlength=showRoads.length-1
|
||||
twinkle(ctb,showRoads[showRoadlength].show_x,showRoads[showRoadlength].show_y,showRoads[showRoadlength].result,showRoads[showRoadlength].pair);
|
||||
}
|
||||
|
||||
var show_x=show_x,
|
||||
show_y=show_y;
|
||||
type=type
|
||||
if(show_x!=""||undefined){
|
||||
Tab(show_x,show_y,type,corners);
|
||||
}
|
||||
var waybill = ludan;
|
||||
|
||||
if(!waybill) return false;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 展示路的路单显示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<showRoad.show_location.length; i++){
|
||||
|
||||
if(showRoad.show_location[i].result == "banker"){
|
||||
// 展示路
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "player"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "tie"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
function Tab(x,y,type,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
var x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_x*(x-1), tab_x*(y-1), tab_x, tab_x);
|
||||
if(type=="banker"){
|
||||
var color='#e12217',
|
||||
fonts='庄';
|
||||
}else if(type=="player"){
|
||||
var color='#0030ff',
|
||||
fonts='闲';
|
||||
}else if(type=="tie"){
|
||||
var color='#27cf00',
|
||||
fonts='和';
|
||||
}
|
||||
ctb.arc(tab_x*x_z, tab_x*y_z, tab_x*0.45, 0, Math.PI * 2);
|
||||
ctb.fillStyle=color;
|
||||
ctb.fill();
|
||||
Font_Size =Math.floor(tab_x/1.8)+"px Arial"
|
||||
ctb.font=Font_Size;
|
||||
ctb.fillStyle ="#fff" ; // 颜色
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,tab_x*x_z,tab_x*y_z);
|
||||
ctb.stroke();
|
||||
var corner_xy=tab_x/3.2
|
||||
if(corners=="1"){
|
||||
corner(x_z,y_z,corner_xy,'#1944ff');
|
||||
}else if(corners=="2"){
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}else if(corners=="3"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
}else if(corners=="4"){
|
||||
corner(x_z,y_z,-corner_xy,'#ff2202');
|
||||
}else if(corners=="5"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}
|
||||
}
|
||||
|
||||
// a区角标
|
||||
function corner(x_z,y_z,corner_xy,corner_color){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
ctb.arc(tab_x*x_z-corner_xy, tab_x*y_z-corner_xy, tab_x*0.14, 0, Math.PI * 2);
|
||||
ctb.fillStyle=corner_color;
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,show_x,show_y,result,pair){
|
||||
var b=10
|
||||
num3=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num3);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
// Tab(1,1,"banker",2)
|
||||
Tab(show_x,show_y,result)
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
/* 时钟 */
|
||||
function startTime(){
|
||||
var today=new Date();
|
||||
var yyyy = today.getFullYear();
|
||||
var MM = today.getMonth()+1;
|
||||
var dd = today.getDate();
|
||||
var hh=today.getHours();
|
||||
var mm=today.getMinutes();
|
||||
var ss=today.getSeconds();
|
||||
MM=checkTime(MM);
|
||||
dd=checkTime(dd);
|
||||
mm=checkTime(mm);
|
||||
ss=checkTime(ss);
|
||||
var day;
|
||||
if(today.getDay()==0) day = "星期日"
|
||||
if(today.getDay()==1) day = "星期一"
|
||||
if(today.getDay()==2) day = "星期二"
|
||||
if(today.getDay()==3) day = "星期三"
|
||||
if(today.getDay()==4) day = "星期四"
|
||||
if(today.getDay()==5) day = "星期五"
|
||||
if(today.getDay()==6) day = "星期六"
|
||||
$('#nowDateSpan').html( yyyy+"-"+MM +"-"+ dd);
|
||||
$('#nowTimeSpan').html(hh+":"+mm+":"+ss);
|
||||
$('#nowWeekSpan').html(day);
|
||||
setTimeout('startTime()',1000);
|
||||
}
|
||||
function checkTime(i){
|
||||
if (i<10){
|
||||
i="0" + i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/* 时钟 end */
|
||||
|
||||
function canvasbg(ctb,CanvasId,tab_width,tab_height,tab_rows,tab_cols,Tab_w) {
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#999";
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(tab_width, 0.5);
|
||||
for (var col = 1; col <= tab_rows; col++) {
|
||||
var y = col * Tab_w;
|
||||
ctb.moveTo(0,y-0.5);
|
||||
ctb.lineTo(tab_width,y-0.5);
|
||||
}
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, tab_height);
|
||||
for (var row = 1; row <= tab_cols; row++) {
|
||||
var x = row * Tab_w;
|
||||
ctb.moveTo(x-0.5,0);
|
||||
ctb.lineTo(x-0.5,tab_height);
|
||||
}
|
||||
ctb.stroke();
|
||||
var image = new Image();
|
||||
image.src = CanvasId.toDataURL("image/png");
|
||||
CanvasId.style.backgroundImage = 'url(' + image.src +')';
|
||||
ctb.clearRect(0, 0, 10000, 10000);
|
||||
}
|
||||
|
||||
|
||||
function audio(url){
|
||||
var mp3="../static/index/mp3/"+url;
|
||||
var audiohtml= '<audio style="visibility: hidden;" id="chatAudio"><source src="'+mp3+'" type="audio/mpeg"></audio>'
|
||||
$(audiohtml).appendTo('body');
|
||||
$("#chatAudio")[0].play()
|
||||
setTimeout(function(){
|
||||
$("#chatAudio").remove();
|
||||
},1000);
|
||||
}
|
||||
@@ -0,0 +1,680 @@
|
||||
var getOnlineNumber = function (connections){
|
||||
var query = new Object();
|
||||
query.connections = connections;
|
||||
$.ajax({
|
||||
url:'/index/get_online_number',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
$('#onlineNumber').html(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var getResultToatl = function (TableId,BootId){
|
||||
var query = new Object();
|
||||
query.table_id = TableId;
|
||||
query.boot_id = BootId;
|
||||
$.ajax({
|
||||
url:'/index/get_result_total',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
var resultToatl = data.data;
|
||||
$('#result_total_player').html(resultToatl.player);
|
||||
$('#result_total_banker').html(resultToatl.banker);
|
||||
$('#result_total_tie').html(resultToatl.tie);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var showPng = function (opening){
|
||||
if(opening == 1) $('#openingPng').attr('src','/static/console/img/dragon.png');
|
||||
if(opening == 2) $('#openingPng').attr('src','/static/console/img/tiger.png');
|
||||
if(opening == 3) $('#openingPng').attr('src','/static/console/img/tie.png');
|
||||
$('#openingElement').show().delay(1000).hide(300);
|
||||
}
|
||||
$(document).on("click","#next_banker",function(){
|
||||
var next = new Object;
|
||||
next.result = 'banker';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
$(document).on("click","#next_player",function(){
|
||||
var next = new Object;
|
||||
next.result = 'player';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.result = "allData";
|
||||
data.table = TableId;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(window).resize(function(){
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
});
|
||||
|
||||
// canvas 路单
|
||||
function resizeCanvas(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single1'),
|
||||
ctb=table.getContext('2d');
|
||||
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
|
||||
Tab_w=tab_width/tab_cols
|
||||
tab_height=Tab_w*tab_rows||183
|
||||
Font_Size =Math.floor(Tab_w/1.8)+"px Arial"
|
||||
Font_Size_s=Math.floor(Tab_w/2.8)+"px Arial"
|
||||
|
||||
$("#single1").attr("height",tab_height+0.4)
|
||||
$("#single1").attr("width",canvaswidth+0.4)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var twin=twinkledata.bigRoad.show_location,
|
||||
twinlength=twin.length-1
|
||||
twinkle(ctb,twin[twinlength].show_x,twin[twinlength].show_y,twin[twinlength].result);
|
||||
}
|
||||
// 获取本地session里的路单数据
|
||||
var waybill = ludan;
|
||||
if(waybill == false) return false;
|
||||
var bigRoad = waybill.bigRoad;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 第一局为和,大路展示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined && showRoad.first_tie_num != undefined && showRoad.first_tie_num > 0){
|
||||
b_Tie(showRoad.first_tie_num);
|
||||
}
|
||||
|
||||
// 大路路单展示
|
||||
if( bigRoad != undefined && bigRoad.show_location != undefined){
|
||||
for(var i=0; i<bigRoad.show_location.length; i++){
|
||||
//庄赢
|
||||
if(bigRoad.show_location[i].result == "banker"){
|
||||
// 判断是否有和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2);
|
||||
}
|
||||
}
|
||||
|
||||
// 闲赢
|
||||
if(bigRoad.show_location[i].result == "player"){
|
||||
// 判断是否是和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
// 和
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
if(bigRoad.first_tie_num != undefined && bigRoad.first_tie_num == 1 && i == 0){
|
||||
b_Tie(bigRoad.show_location[i].tie_num)
|
||||
}else{
|
||||
if(bigRoad.show_location[i].result == 'banker'){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctb.closePath();
|
||||
// 局数 数,文字X坐标,文字Y坐标,文字大小风格
|
||||
function Font_tie(num,Font_x,Font_y,fontsize){
|
||||
if(num!==undefined){
|
||||
ctb.beginPath();
|
||||
ctb.font=fontsize;
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillStyle ="#000" ;
|
||||
ctb.fillText(num,Font_x,Font_y);
|
||||
ctb.stroke();
|
||||
}
|
||||
}
|
||||
function b_Tab(x,y,type,slash,order){
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(Tab_w*x_z-Tab_w/2.1, Tab_w*y_z-Tab_w/2.1, Tab_w*0.9, Tab_w*0.9);
|
||||
if(type=="1"){
|
||||
var color="#331a98";
|
||||
}else if(type=="2"){
|
||||
var color="#fb2603"
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;
|
||||
ctb.strokeStyle = color;
|
||||
ctb.arc(Tab_w*x_z-0.5, Tab_w*y_z-0.5, Tab_w*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
|
||||
|
||||
if(slash=="1"){
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
ctb.lineCap = "round";
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.moveTo(x_z*Tab_w-linewidth,Tab_w*y_z+linewidth);
|
||||
ctb.lineTo(x_z*Tab_w+linewidth,Tab_w*y_z-linewidth);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w*x_z, Tab_w*y_z,Font_Size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// b区第一局 和
|
||||
function b_Tie(order){
|
||||
ctb.clearRect(Tab_w/20, 1, Tab_w*0.9, Tab_w*0.9);
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 3.5;//线条宽度
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.lineCap = "round";
|
||||
ctb.moveTo(Tab_w/20,Tab_w/2);
|
||||
ctb.lineTo(Tab_w*0.9,Tab_w/2);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w/2, Tab_w/2,Font_Size);
|
||||
}
|
||||
// 问路
|
||||
function twinkle(ctb,show_x,show_y,result){
|
||||
var b=10
|
||||
num1=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num1);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
if(result=="banker"){
|
||||
b_Tab(show_x,show_y,2)
|
||||
}else if(result=="player"){
|
||||
b_Tab(show_x,show_y,1)
|
||||
}
|
||||
// // 数据
|
||||
ctb.globalAlpha=0.5
|
||||
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas2(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single2'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
tab_b_cols = 6,
|
||||
Tab_w=tab_width/tab_cols,
|
||||
tab_height=Tab_w*tab_rows||183;
|
||||
|
||||
$("#single2").attr("height",tab_height+0.8)
|
||||
$("#single2").attr("width",canvaswidth+0.4)
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
var waybill = ludan;
|
||||
if(!waybill) return false;
|
||||
var bigEyeRoad = waybill.bigEyeRoad; // 大眼路数据
|
||||
var pathway = waybill.pathway; // 小路数据
|
||||
var roach = waybill.roach;
|
||||
// 小强路数据
|
||||
if(twinkledata!=undefined){
|
||||
twinkle(ctb,twinkledata);
|
||||
}
|
||||
|
||||
// 大眼路数据
|
||||
if(bigEyeRoad != undefined && bigEyeRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<bigEyeRoad.show_location.length; i++){
|
||||
// 红圈
|
||||
if(bigEyeRoad.show_location[i].result == 'red'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(bigEyeRoad.show_location[i].result == 'blue'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 小路数据
|
||||
if(pathway != undefined && pathway.show_location != undefined){
|
||||
|
||||
for(var i=0; i<pathway.show_location.length; i++){
|
||||
// 红圈
|
||||
if(pathway.show_location[i].result == 'red'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(pathway.show_location[i].result == 'blue'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 小强路数据
|
||||
if(roach != undefined && roach.show_location != undefined){
|
||||
|
||||
for(var i=0; i<roach.show_location.length; i++){
|
||||
// 红圈
|
||||
if(roach.show_location[i].result == 'red'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(roach.show_location[i].result == 'blue'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
// c区
|
||||
function c_Tab(x,y,type){
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), tab_c*(y-1), tab_c, tab_c);
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;
|
||||
ctb.arc(tab_c*x_z, tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
|
||||
// d区
|
||||
function d_Tab(x,y,type){
|
||||
|
||||
var d_y=Tab_w*tab_b_cols/2,
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), d_y+tab_c*(y-1), tab_c, tab_c);
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.2;
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
ctb.fillStyle='#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
ctb.fillStyle='#ff0000';
|
||||
}
|
||||
ctb.arc(tab_c*x_z, d_y+tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// e区
|
||||
function e_Tab(x,y,type){
|
||||
var d_x=20*Tab_w,
|
||||
linewidth=Tab_w/3;
|
||||
x_z=x-0.2,
|
||||
y_z=y-0.2,
|
||||
tab_d_x=Tab_w/2;
|
||||
ctb.clearRect(d_x+tab_d_x*(x-1), tab_d_x*(y-1), tab_d_x, tab_d_x);
|
||||
ctb.beginPath();
|
||||
ctb.lineCap = "butt";
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
|
||||
//线条颜色
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#331a98';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#fd2203';
|
||||
}
|
||||
|
||||
ctb.moveTo(d_x+tab_d_x*x_z,linewidth+tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.lineTo(d_x-linewidth+tab_d_x*x_z,tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,twinkledata){
|
||||
var b=10,
|
||||
bigEyeRoad=twinkledata.bigEyeRoad.show_location,
|
||||
pathway=twinkledata.pathway.show_location,
|
||||
roach=twinkledata.roach.show_location
|
||||
|
||||
|
||||
num2=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num2);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
//
|
||||
if(bigEyeRoad!=undefined){
|
||||
var bigEyeRoadlength=bigEyeRoad.length-1
|
||||
if(bigEyeRoad[bigEyeRoadlength].result=="blue"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,1)
|
||||
}else if(bigEyeRoad[bigEyeRoadlength].result=="red"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,2)
|
||||
}
|
||||
}
|
||||
|
||||
if(pathway!=undefined){
|
||||
var pathwaylength=pathway.length-1
|
||||
if(pathway[pathwaylength].result=="blue"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,1)
|
||||
}else if(pathway[pathwaylength].result=="red"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,2)
|
||||
}
|
||||
}
|
||||
|
||||
if(roach!=undefined){
|
||||
var roachlength=roach.length-1
|
||||
if(roach[roachlength].result=="blue"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,1)
|
||||
}else if(roach[roachlength].result=="red"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,2)
|
||||
}
|
||||
}
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas3(show_x,show_y,type,corners,twinkledata){
|
||||
|
||||
var canvaswidth= $(".baccarat_head").width()*0.5;
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single3'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=20,
|
||||
tab_rows=6,
|
||||
|
||||
tab_x=tab_width/tab_cols
|
||||
tab_y=tab_x,
|
||||
tab_height=tab_y*tab_rows
|
||||
|
||||
$("#single3").attr("height",tab_height+1)
|
||||
$("#single3").attr("width",canvaswidth+0.5)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,tab_x);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var showRoads=twinkledata.showRoad.show_location
|
||||
showRoadlength=showRoads.length-1
|
||||
twinkle(ctb,showRoads[showRoadlength].show_x,showRoads[showRoadlength].show_y,showRoads[showRoadlength].result,showRoads[showRoadlength].pair);
|
||||
}
|
||||
|
||||
var show_x=show_x,
|
||||
show_y=show_y;
|
||||
type=type
|
||||
if(show_x!=""||undefined){
|
||||
Tab(show_x,show_y,type,corners);
|
||||
}
|
||||
var waybill = ludan;
|
||||
|
||||
if(!waybill) return false;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 展示路的路单显示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<showRoad.show_location.length; i++){
|
||||
|
||||
if(showRoad.show_location[i].result == "banker"){
|
||||
// 展示路
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "player"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "tie"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
function Tab(x,y,type,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
var x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_x*(x-1), tab_x*(y-1), tab_x, tab_x);
|
||||
if(type=="banker"){
|
||||
var color='#e12217',
|
||||
fonts='龙';
|
||||
}else if(type=="player"){
|
||||
var color='#0030ff',
|
||||
fonts='虎';
|
||||
}else if(type=="tie"){
|
||||
var color='#27cf00',
|
||||
fonts='和';
|
||||
}
|
||||
ctb.arc(tab_x*x_z, tab_x*y_z, tab_x*0.45, 0, Math.PI * 2);
|
||||
ctb.fillStyle=color;
|
||||
ctb.fill();
|
||||
Font_Size =Math.floor(tab_x/1.8)+"px Arial"
|
||||
ctb.font=Font_Size;
|
||||
ctb.fillStyle ="#fff" ; // 颜色
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,tab_x*x_z,tab_x*y_z);
|
||||
ctb.stroke();
|
||||
var corner_xy=tab_x/3.2
|
||||
if(corners=="1"){
|
||||
corner(x_z,y_z,corner_xy,'#1944ff');
|
||||
}else if(corners=="2"){
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}else if(corners=="3"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
}else if(corners=="4"){
|
||||
corner(x_z,y_z,-corner_xy,'#ff2202');
|
||||
}else if(corners=="5"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}
|
||||
}
|
||||
|
||||
// a区角标
|
||||
function corner(x_z,y_z,corner_xy,corner_color){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
ctb.arc(tab_x*x_z-corner_xy, tab_x*y_z-corner_xy, tab_x*0.14, 0, Math.PI * 2);
|
||||
ctb.fillStyle=corner_color;
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,show_x,show_y,result,pair){
|
||||
var b=10
|
||||
num3=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num3);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
// Tab(1,1,"banker",2)
|
||||
Tab(show_x,show_y,result)
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
/* 时钟 */
|
||||
function startTime(){
|
||||
var today=new Date();
|
||||
var yyyy = today.getFullYear();
|
||||
var MM = today.getMonth()+1;
|
||||
var dd = today.getDate();
|
||||
var hh=today.getHours();
|
||||
var mm=today.getMinutes();
|
||||
var ss=today.getSeconds();
|
||||
MM=checkTime(MM);
|
||||
dd=checkTime(dd);
|
||||
mm=checkTime(mm);
|
||||
ss=checkTime(ss);
|
||||
var day;
|
||||
if(today.getDay()==0) day = "星期日"
|
||||
if(today.getDay()==1) day = "星期一"
|
||||
if(today.getDay()==2) day = "星期二"
|
||||
if(today.getDay()==3) day = "星期三"
|
||||
if(today.getDay()==4) day = "星期四"
|
||||
if(today.getDay()==5) day = "星期五"
|
||||
if(today.getDay()==6) day = "星期六"
|
||||
$('#nowDateSpan').html( yyyy+"-"+MM +"-"+ dd);
|
||||
$('#nowTimeSpan').html(hh+":"+mm+":"+ss);
|
||||
$('#nowWeekSpan').html(day);
|
||||
setTimeout('startTime()',1000);
|
||||
}
|
||||
function checkTime(i){
|
||||
if (i<10){
|
||||
i="0" + i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/* 时钟 end */
|
||||
|
||||
function canvasbg(ctb,CanvasId,tab_width,tab_height,tab_rows,tab_cols,Tab_w) {
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#999";
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(tab_width, 0.5);
|
||||
for (var col = 1; col <= tab_rows; col++) {
|
||||
var y = col * Tab_w;
|
||||
ctb.moveTo(0,y-0.5);
|
||||
ctb.lineTo(tab_width,y-0.5);
|
||||
}
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, tab_height);
|
||||
for (var row = 1; row <= tab_cols; row++) {
|
||||
var x = row * Tab_w;
|
||||
ctb.moveTo(x-0.5,0);
|
||||
ctb.lineTo(x-0.5,tab_height);
|
||||
}
|
||||
ctb.stroke();
|
||||
var image = new Image();
|
||||
image.src = CanvasId.toDataURL("image/png");
|
||||
CanvasId.style.backgroundImage = 'url(' + image.src +')';
|
||||
ctb.clearRect(0, 0, 10000, 10000);
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
/* 键盘操作 */
|
||||
$(document).keydown(function (e){
|
||||
if(e.keyCode == 13){
|
||||
opening();
|
||||
}
|
||||
if(e.keyCode == 97){
|
||||
$('#opening').val('1');
|
||||
}
|
||||
if(e.keyCode == 98){
|
||||
$('#opening').val('2');
|
||||
}
|
||||
if(e.keyCode == 99){
|
||||
$('#opening').val('3');
|
||||
}
|
||||
if(e.keyCode == 100){
|
||||
$('#result_banker_pair').val('1');
|
||||
}
|
||||
if(e.keyCode == 101){
|
||||
$('#result_player_pair').val('2');
|
||||
}
|
||||
if(e.keyCode == 107){
|
||||
startBet();
|
||||
}
|
||||
})
|
||||
/* 键盘操作 end */
|
||||
$(document).on("click","#next_banker",function(){
|
||||
var next = new Object;
|
||||
next.result = 'banker';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
$(document).on("click","#next_player",function(){
|
||||
var next = new Object;
|
||||
next.result = 'player';
|
||||
next.table = TableId;
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
success:function(data){
|
||||
var twinkledata=data;
|
||||
resizeCanvas(twinkledata);
|
||||
resizeCanvas2(twinkledata);
|
||||
resizeCanvas3("","","","",twinkledata);
|
||||
}
|
||||
});
|
||||
})
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.result = "allData";
|
||||
data.table = TableId;
|
||||
$.ajax({
|
||||
url:"/waybill/waybill.php",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(window).resize(function(){
|
||||
resizeCanvas();
|
||||
resizeCanvas2();
|
||||
resizeCanvas3();
|
||||
});
|
||||
|
||||
// canvas 路单
|
||||
function resizeCanvas(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single1'),
|
||||
ctb=table.getContext('2d');
|
||||
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
|
||||
Tab_w=tab_width/tab_cols
|
||||
tab_height=Tab_w*tab_rows||183
|
||||
Font_Size =Math.floor(Tab_w/1.8)+"px Arial"
|
||||
Font_Size_s=Math.floor(Tab_w/2.8)+"px Arial"
|
||||
|
||||
$("#single1").attr("height",tab_height+0.4)
|
||||
$("#single1").attr("width",canvaswidth+0.4)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var twin=twinkledata.bigRoad.show_location,
|
||||
twinlength=twin.length-1
|
||||
twinkle(ctb,twin[twinlength].show_x,twin[twinlength].show_y,twin[twinlength].result);
|
||||
}
|
||||
// 获取本地session里的路单数据
|
||||
var waybill = ludan;
|
||||
if(waybill == false) return false;
|
||||
var bigRoad = waybill.bigRoad;
|
||||
var showRoad = waybill.showRoad;
|
||||
|
||||
// 第一局为和,大路展示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined && showRoad.first_tie_num != undefined && showRoad.first_tie_num > 0){
|
||||
b_Tie(showRoad.first_tie_num);
|
||||
}
|
||||
|
||||
// 大路路单展示
|
||||
if( bigRoad != undefined && bigRoad.show_location != undefined){
|
||||
for(var i=0; i<bigRoad.show_location.length; i++){
|
||||
//庄赢
|
||||
if(bigRoad.show_location[i].result == "banker"){
|
||||
// 判断是否有和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,2);
|
||||
}
|
||||
}
|
||||
|
||||
// 闲赢
|
||||
if(bigRoad.show_location[i].result == "player"){
|
||||
// 判断是否是和局
|
||||
if(bigRoad.show_location[i].tie_num > 0){
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1,1,bigRoad.show_location[i].tie_num);
|
||||
}else{
|
||||
b_Tab(bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 和
|
||||
if(bigRoad.show_location[i].result == "tie"){
|
||||
b_Tab(false,bigRoad.show_location[i].show_x,bigRoad.show_location[i].show_y,tie_num)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctb.closePath();
|
||||
// 局数 数,文字X坐标,文字Y坐标,文字大小风格
|
||||
function Font_tie(num,Font_x,Font_y,fontsize){
|
||||
if(num!==undefined){
|
||||
ctb.beginPath();
|
||||
ctb.font=fontsize;
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillStyle ="#000" ;
|
||||
ctb.fillText(num,Font_x,Font_y);
|
||||
ctb.stroke();
|
||||
}
|
||||
}
|
||||
function b_Tab(x,y,type,slash,order){
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(Tab_w*x_z-Tab_w/2.1, Tab_w*y_z-Tab_w/2.1, Tab_w*0.9, Tab_w*0.9);
|
||||
if(type=="1"){
|
||||
var color="#331a98";
|
||||
}else if(type=="2"){
|
||||
var color="#fb2603"
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;
|
||||
ctb.strokeStyle = color;
|
||||
ctb.arc(Tab_w*x_z-0.5, Tab_w*y_z-0.5, Tab_w*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
|
||||
|
||||
if(slash=="1"){
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
ctb.lineCap = "round";
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.moveTo(x_z*Tab_w-linewidth,Tab_w*y_z+linewidth);
|
||||
ctb.lineTo(x_z*Tab_w+linewidth,Tab_w*y_z-linewidth);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w*x_z, Tab_w*y_z,Font_Size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// b区第一局 和
|
||||
function b_Tie(order){
|
||||
ctb.clearRect(Tab_w/20, 1, Tab_w*0.9, Tab_w*0.9);
|
||||
ctb.beginPath();
|
||||
linewidth=Tab_w/4;
|
||||
ctb.lineWidth = 3.5;//线条宽度
|
||||
ctb.strokeStyle = "#3EA542";//线条颜色
|
||||
ctb.lineCap = "round";
|
||||
ctb.moveTo(Tab_w/20,Tab_w/2);
|
||||
ctb.lineTo(Tab_w*0.9,Tab_w/2);
|
||||
ctb.stroke();
|
||||
Font_tie(order,Tab_w/2, Tab_w/2,Font_Size);
|
||||
}
|
||||
// 问路
|
||||
function twinkle(ctb,show_x,show_y,result){
|
||||
var b=10
|
||||
num1=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num1);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
if(result=="banker"){
|
||||
b_Tab(show_x,show_y,2)
|
||||
}else if(result=="player"){
|
||||
b_Tab(show_x,show_y,1)
|
||||
}
|
||||
// // 数据
|
||||
ctb.globalAlpha=0.5
|
||||
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas2(twinkledata){
|
||||
var canvaswidth= parseInt($(".baccarat_mian ").width()-30);
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single2'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
tab_cols=60,
|
||||
tab_rows=6,
|
||||
tab_b_cols = 6,
|
||||
Tab_w=tab_width/tab_cols,
|
||||
tab_height=Tab_w*tab_rows||183;
|
||||
|
||||
$("#single2").attr("height",tab_height+0.8)
|
||||
$("#single2").attr("width",canvaswidth+0.4)
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,Tab_w);
|
||||
var waybill = ludan;
|
||||
if(!waybill) return false;
|
||||
var bigEyeRoad = waybill.bigEyeRoad; // 大眼路数据
|
||||
var pathway = waybill.pathway; // 小路数据
|
||||
var roach = waybill.roach;
|
||||
// 小强路数据
|
||||
if(twinkledata!=undefined){
|
||||
twinkle(ctb,twinkledata);
|
||||
}
|
||||
|
||||
// 大眼路数据
|
||||
if(bigEyeRoad != undefined && bigEyeRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<bigEyeRoad.show_location.length; i++){
|
||||
// 红圈
|
||||
if(bigEyeRoad.show_location[i].result == 'red'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(bigEyeRoad.show_location[i].result == 'blue'){
|
||||
c_Tab(bigEyeRoad.show_location[i].show_x,bigEyeRoad.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 小路数据
|
||||
if(pathway != undefined && pathway.show_location != undefined){
|
||||
|
||||
for(var i=0; i<pathway.show_location.length; i++){
|
||||
// 红圈
|
||||
if(pathway.show_location[i].result == 'red'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(pathway.show_location[i].result == 'blue'){
|
||||
d_Tab(pathway.show_location[i].show_x,pathway.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 小强路数据
|
||||
if(roach != undefined && roach.show_location != undefined){
|
||||
|
||||
for(var i=0; i<roach.show_location.length; i++){
|
||||
// 红圈
|
||||
if(roach.show_location[i].result == 'red'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,2);
|
||||
}
|
||||
|
||||
// 蓝圈
|
||||
if(roach.show_location[i].result == 'blue'){
|
||||
e_Tab(roach.show_location[i].show_x,roach.show_location[i].show_y,1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
// c区
|
||||
function c_Tab(x,y,type){
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), tab_c*(y-1), tab_c, tab_c);
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
}
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;
|
||||
ctb.arc(tab_c*x_z, tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
|
||||
// d区
|
||||
function d_Tab(x,y,type){
|
||||
|
||||
var d_y=Tab_w*tab_b_cols/2,
|
||||
tab_c=Tab_w/2,
|
||||
x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_c*(x-1), d_y+tab_c*(y-1), tab_c, tab_c);
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.2;
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#3b39f2';
|
||||
ctb.fillStyle='#3b39f2';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#ff0000';
|
||||
ctb.fillStyle='#ff0000';
|
||||
}
|
||||
ctb.arc(tab_c*x_z, d_y+tab_c*y_z, tab_c*0.38, 0, Math.PI * 2);
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// e区
|
||||
function e_Tab(x,y,type){
|
||||
var d_x=20*Tab_w,
|
||||
linewidth=Tab_w/3;
|
||||
x_z=x-0.2,
|
||||
y_z=y-0.2,
|
||||
tab_d_x=Tab_w/2;
|
||||
ctb.clearRect(d_x+tab_d_x*(x-1), tab_d_x*(y-1), tab_d_x, tab_d_x);
|
||||
ctb.beginPath();
|
||||
ctb.lineCap = "butt";
|
||||
ctb.lineWidth = 2;//线条宽度
|
||||
|
||||
//线条颜色
|
||||
if(type=="1"){
|
||||
ctb.strokeStyle = '#331a98';
|
||||
}else if(type=="2"){
|
||||
ctb.strokeStyle = '#fd2203';
|
||||
}
|
||||
|
||||
ctb.moveTo(d_x+tab_d_x*x_z,linewidth+tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.lineTo(d_x-linewidth+tab_d_x*x_z,tab_d_x*y_z-Tab_w*0.3);
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,twinkledata){
|
||||
var b=10,
|
||||
bigEyeRoad=twinkledata.bigEyeRoad.show_location,
|
||||
pathway=twinkledata.pathway.show_location,
|
||||
roach=twinkledata.roach.show_location
|
||||
|
||||
|
||||
num2=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num2);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
//
|
||||
if(bigEyeRoad!=undefined){
|
||||
var bigEyeRoadlength=bigEyeRoad.length-1
|
||||
if(bigEyeRoad[bigEyeRoadlength].result=="blue"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,1)
|
||||
}else if(bigEyeRoad[bigEyeRoadlength].result=="red"){
|
||||
c_Tab(bigEyeRoad[bigEyeRoadlength].show_x,bigEyeRoad[bigEyeRoadlength].show_y,1)
|
||||
}
|
||||
}
|
||||
|
||||
if(pathway!=undefined){
|
||||
var pathwaylength=pathway.length-1
|
||||
if(pathway[pathwaylength].result=="blue"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,1)
|
||||
}else if(pathway[pathwaylength].result=="red"){
|
||||
d_Tab(pathway[pathwaylength].show_x,pathway[pathwaylength].show_y,1)
|
||||
}
|
||||
}
|
||||
|
||||
if(roach!=undefined){
|
||||
var roachlength=roach.length-1
|
||||
if(roach[roachlength].result=="blue"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,1)
|
||||
}else if(roach[roachlength].result=="red"){
|
||||
e_Tab(roach[roachlength].show_x,roach[roachlength].show_y,1)
|
||||
}
|
||||
}
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeCanvas3(show_x,show_y,type,corners,twinkledata){
|
||||
|
||||
var canvaswidth= $(".baccarat_head").width()*0.5;
|
||||
$(".index .canvas-box .canvas").width(canvaswidth);
|
||||
var table=document.getElementById('single3'),
|
||||
ctb=table.getContext('2d');
|
||||
// ctb.beginPath();
|
||||
var tab_width=canvaswidth,
|
||||
|
||||
tab_cols=20,
|
||||
tab_rows=6,
|
||||
|
||||
tab_x=tab_width/tab_cols
|
||||
tab_y=tab_x,
|
||||
tab_height=tab_y*tab_rows
|
||||
|
||||
$("#single3").attr("height",tab_height+1)
|
||||
$("#single3").attr("width",canvaswidth+0.5)
|
||||
|
||||
canvasbg(ctb,table,tab_width,tab_height,tab_rows,tab_cols,tab_x);
|
||||
|
||||
if(twinkledata!=undefined){
|
||||
var showRoads=twinkledata.showRoad.show_location
|
||||
showRoadlength=showRoads.length-1
|
||||
twinkle(ctb,showRoads[showRoadlength].show_x,showRoads[showRoadlength].show_y,showRoads[showRoadlength].result,showRoads[showRoadlength].pair);
|
||||
}
|
||||
|
||||
var show_x=show_x,
|
||||
show_y=show_y;
|
||||
type=type
|
||||
if(show_x!=""||undefined){
|
||||
Tab(show_x,show_y,type,corners);
|
||||
}
|
||||
var waybill = ludan;
|
||||
|
||||
if(!waybill) return false;
|
||||
var showRoad = waybill.showRoad;
|
||||
// 展示路的路单显示
|
||||
if(showRoad != undefined && showRoad.show_location != undefined){
|
||||
|
||||
for(var i=0; i<showRoad.show_location.length; i++){
|
||||
|
||||
if(showRoad.show_location[i].result == "banker"){
|
||||
// 展示路
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'banker',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "player"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'player',5);
|
||||
}
|
||||
}
|
||||
|
||||
if(showRoad.show_location[i].result == "tie"){
|
||||
if(showRoad.show_location[i]['pair'] == 'none'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie');
|
||||
}else if(showRoad.show_location[i]['pair'] == 'bankerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',3);
|
||||
}else if(showRoad.show_location[i]['pair'] == 'playerPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',2);
|
||||
}
|
||||
else if(showRoad.show_location[i]['pair'] == 'bothPair'){
|
||||
Tab(showRoad.show_location[i]['show_x'],showRoad.show_location[i]['show_y'],'tie',5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ctb.closePath();
|
||||
function Tab(x,y,type,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
var x_z=x-0.5,
|
||||
y_z=y-0.5;
|
||||
ctb.clearRect(tab_x*(x-1), tab_x*(y-1), tab_x, tab_x);
|
||||
if(type=="banker"){
|
||||
var color='#e12217',
|
||||
fonts='庄';
|
||||
}else if(type=="player"){
|
||||
var color='#0030ff',
|
||||
fonts='闲';
|
||||
}else if(type=="tie"){
|
||||
var color='#27cf00',
|
||||
fonts='和';
|
||||
}
|
||||
ctb.arc(tab_x*x_z, tab_x*y_z, tab_x*0.45, 0, Math.PI * 2);
|
||||
ctb.fillStyle=color;
|
||||
ctb.fill();
|
||||
Font_Size =Math.floor(tab_x/1.8)+"px Arial"
|
||||
ctb.font=Font_Size;
|
||||
ctb.fillStyle ="#fff" ; // 颜色
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,tab_x*x_z,tab_x*y_z);
|
||||
ctb.stroke();
|
||||
var corner_xy=tab_x/3.2
|
||||
if(corners=="1"){
|
||||
corner(x_z,y_z,corner_xy,'#1944ff');
|
||||
}else if(corners=="2"){
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}else if(corners=="3"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
}else if(corners=="4"){
|
||||
corner(x_z,y_z,-corner_xy,'#ff2202');
|
||||
}else if(corners=="5"){
|
||||
corner(x_z,y_z,corner_xy,'#ff2202');
|
||||
corner(x_z,y_z,-corner_xy,'#1944ff');
|
||||
}
|
||||
}
|
||||
|
||||
// a区角标
|
||||
function corner(x_z,y_z,corner_xy,corner_color){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#fff";
|
||||
ctb.arc(tab_x*x_z-corner_xy, tab_x*y_z-corner_xy, tab_x*0.14, 0, Math.PI * 2);
|
||||
ctb.fillStyle=corner_color;
|
||||
ctb.fill();
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
function twinkle(ctb,show_x,show_y,result,pair){
|
||||
var b=10
|
||||
num3=setInterval(function(){
|
||||
b--;
|
||||
var num=b%2;
|
||||
if(b<0){
|
||||
clearInterval(num3);
|
||||
// $("#player_ask,#banker_ask").removeAttr("disabled");
|
||||
}else{
|
||||
ctb.globalAlpha=num;
|
||||
// 数据
|
||||
// Tab(1,1,"banker",2)
|
||||
Tab(show_x,show_y,result)
|
||||
// 数据
|
||||
ctb.globalAlpha=0.5
|
||||
}
|
||||
},200);
|
||||
}
|
||||
}
|
||||
|
||||
/* 时钟 */
|
||||
function startTime(){
|
||||
var today=new Date();
|
||||
var yyyy = today.getFullYear();
|
||||
var MM = today.getMonth()+1;
|
||||
var dd = today.getDate();
|
||||
var hh=today.getHours();
|
||||
var mm=today.getMinutes();
|
||||
var ss=today.getSeconds();
|
||||
MM=checkTime(MM);
|
||||
dd=checkTime(dd);
|
||||
mm=checkTime(mm);
|
||||
ss=checkTime(ss);
|
||||
var day;
|
||||
if(today.getDay()==0) day = "星期日"
|
||||
if(today.getDay()==1) day = "星期一"
|
||||
if(today.getDay()==2) day = "星期二"
|
||||
if(today.getDay()==3) day = "星期三"
|
||||
if(today.getDay()==4) day = "星期四"
|
||||
if(today.getDay()==5) day = "星期五"
|
||||
if(today.getDay()==6) day = "星期六"
|
||||
$('#nowDateSpan').html( yyyy+"-"+MM +"-"+ dd);
|
||||
$('#nowTimeSpan').html(hh+":"+mm+":"+ss);
|
||||
$('#nowWeekSpan').html(day);
|
||||
setTimeout('startTime()',1000);
|
||||
}
|
||||
function checkTime(i){
|
||||
if (i<10){
|
||||
i="0" + i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/* 时钟 end */
|
||||
|
||||
function canvasbg(ctb,CanvasId,tab_width,tab_height,tab_rows,tab_cols,Tab_w) {
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#999";
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(tab_width, 0.5);
|
||||
for (var col = 1; col <= tab_rows; col++) {
|
||||
var y = col * Tab_w;
|
||||
ctb.moveTo(0,y-0.5);
|
||||
ctb.lineTo(tab_width,y-0.5);
|
||||
}
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, tab_height);
|
||||
for (var row = 1; row <= tab_cols; row++) {
|
||||
var x = row * Tab_w;
|
||||
ctb.moveTo(x-0.5,0);
|
||||
ctb.lineTo(x-0.5,tab_height);
|
||||
}
|
||||
ctb.stroke();
|
||||
var image = new Image();
|
||||
image.src = CanvasId.toDataURL("image/png");
|
||||
CanvasId.style.backgroundImage = 'url(' + image.src +')';
|
||||
ctb.clearRect(0, 0, 10000, 10000);
|
||||
}
|
||||
|
||||
|
||||
function audio(url){
|
||||
var mp3="../static/index/mp3/"+url;
|
||||
var audiohtml= '<audio style="visibility: hidden;" id="chatAudio"><source src="'+mp3+'" type="audio/mpeg"></audio>'
|
||||
$(audiohtml).appendTo('body');
|
||||
$("#chatAudio")[0].play()
|
||||
setTimeout(function(){
|
||||
$("#chatAudio").remove();
|
||||
},1000);
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/* @license
|
||||
* jQuery.print, version 1.3.2
|
||||
* (c) Sathvik Ponangi, Doers' Guild
|
||||
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
|
||||
*--------------------------------------------------------------------------*/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
// A nice closure for our definitions
|
||||
function getjQueryObject(string) {
|
||||
// Make string a vaild jQuery thing
|
||||
var jqObj = $("");
|
||||
try {
|
||||
jqObj = $(string)
|
||||
.clone();
|
||||
} catch (e) {
|
||||
jqObj = $("<span />")
|
||||
.html(string);
|
||||
}
|
||||
return jqObj;
|
||||
}
|
||||
|
||||
function printFrame(frameWindow) {
|
||||
// Print the selected window/iframe
|
||||
var def = $.Deferred();
|
||||
try {
|
||||
setTimeout(function () {
|
||||
// Fix for IE : Allow it to render the iframe
|
||||
frameWindow.focus();
|
||||
try {
|
||||
// Fix for IE11 - printng the whole page instead of the iframe content
|
||||
if (!frameWindow.document.execCommand('print', false, null)) {
|
||||
// document.execCommand returns false if it failed -http://stackoverflow.com/a/21336448/937891
|
||||
frameWindow.print();
|
||||
}
|
||||
} catch (e) {
|
||||
frameWindow.print();
|
||||
}
|
||||
frameWindow.close();
|
||||
def.resolve();
|
||||
}, 250);
|
||||
} catch (err) {
|
||||
def.reject(err);
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
function printContentInNewWindow(content) {
|
||||
// Open a new window and print selected content
|
||||
var w = window.open();
|
||||
w.document.write(content);
|
||||
w.document.close();
|
||||
return printFrame(w);
|
||||
}
|
||||
|
||||
function isNode(o) {
|
||||
/* http://stackoverflow.com/a/384380/937891 */
|
||||
return !!(typeof Node === "object" ? o instanceof Node : o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string");
|
||||
}
|
||||
$.print = $.fn.print = function () {
|
||||
// Print a given set of elements
|
||||
var options, $this, self = this;
|
||||
// console.log("Printing", this, arguments);
|
||||
if (self instanceof $) {
|
||||
// Get the node if it is a jQuery object
|
||||
self = self.get(0);
|
||||
}
|
||||
if (isNode(self)) {
|
||||
// If `this` is a HTML element, i.e. for
|
||||
// $(selector).print()
|
||||
$this = $(self);
|
||||
if (arguments.length > 0) {
|
||||
options = arguments[0];
|
||||
}
|
||||
} else {
|
||||
if (arguments.length > 0) {
|
||||
// $.print(selector,options)
|
||||
$this = $(arguments[0]);
|
||||
if (isNode($this[0])) {
|
||||
if (arguments.length > 1) {
|
||||
options = arguments[1];
|
||||
}
|
||||
} else {
|
||||
// $.print(options)
|
||||
options = arguments[0];
|
||||
$this = $("html");
|
||||
}
|
||||
} else {
|
||||
// $.print()
|
||||
$this = $("html");
|
||||
}
|
||||
}
|
||||
// Default options
|
||||
var defaults = {
|
||||
globalStyles: true,
|
||||
mediaPrint: false,
|
||||
stylesheet: null,
|
||||
noPrintSelector: ".no-print",
|
||||
iframe: true,
|
||||
append: null,
|
||||
prepend: null,
|
||||
manuallyCopyFormValues: true,
|
||||
deferred: $.Deferred()
|
||||
};
|
||||
// Merge with user-options
|
||||
options = $.extend({}, defaults, (options || {}));
|
||||
var $styles = $("");
|
||||
if (options.globalStyles) {
|
||||
// Apply the stlyes from the current sheet to the printed page
|
||||
$styles = $("style, link, meta, title");
|
||||
} else if (options.mediaPrint) {
|
||||
// Apply the media-print stylesheet
|
||||
$styles = $("link[media=print]");
|
||||
}
|
||||
if (options.stylesheet) {
|
||||
// Add a custom stylesheet if given
|
||||
$styles = $.merge($styles, $('<link rel="stylesheet" href="' + options.stylesheet + '">'));
|
||||
}
|
||||
// Create a copy of the element to print
|
||||
var copy = $this.clone();
|
||||
// Wrap it in a span to get the HTML markup string
|
||||
copy = $("<span/>")
|
||||
.append(copy);
|
||||
// Remove unwanted elements
|
||||
copy.find(options.noPrintSelector)
|
||||
.remove();
|
||||
// Add in the styles
|
||||
copy.append($styles.clone());
|
||||
// Appedned content
|
||||
copy.append(getjQueryObject(options.append));
|
||||
// Prepended content
|
||||
copy.prepend(getjQueryObject(options.prepend));
|
||||
if (options.manuallyCopyFormValues) {
|
||||
// Manually copy form values into the HTML for printing user-modified input fields
|
||||
// http://stackoverflow.com/a/26707753
|
||||
copy.find("input")
|
||||
.each(function () {
|
||||
var $field = $(this);
|
||||
if ($field.is("[type='radio']") || $field.is("[type='checkbox']")) {
|
||||
if ($field.prop("checked")) {
|
||||
$field.attr("checked", "checked");
|
||||
}
|
||||
} else {
|
||||
$field.attr("value", $field.val());
|
||||
}
|
||||
});
|
||||
copy.find("select").each(function () {
|
||||
var $field = $(this);
|
||||
$field.find(":selected").attr("selected", "selected");
|
||||
});
|
||||
copy.find("textarea").each(function () {
|
||||
// Fix for https://github.com/DoersGuild/jQuery.print/issues/18#issuecomment-96451589
|
||||
var $field = $(this);
|
||||
$field.text($field.val());
|
||||
});
|
||||
}
|
||||
// Get the HTML markup string
|
||||
var content = copy.html();
|
||||
// Notify with generated markup & cloned elements - useful for logging, etc
|
||||
try {
|
||||
options.deferred.notify('generated_markup', content, copy);
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
// Destroy the copy
|
||||
copy.remove();
|
||||
if (options.iframe) {
|
||||
// Use an iframe for printing
|
||||
try {
|
||||
var $iframe = $(options.iframe + "");
|
||||
var iframeCount = $iframe.length;
|
||||
if (iframeCount === 0) {
|
||||
// Create a new iFrame if none is given
|
||||
$iframe = $('<iframe height="0" width="0" border="0" wmode="Opaque"/>')
|
||||
.prependTo('body')
|
||||
.css({
|
||||
"position": "absolute",
|
||||
"top": -999,
|
||||
"left": -999
|
||||
});
|
||||
}
|
||||
var w, wdoc;
|
||||
w = $iframe.get(0);
|
||||
w = w.contentWindow || w.contentDocument || w;
|
||||
wdoc = w.document || w.contentDocument || w;
|
||||
wdoc.open();
|
||||
wdoc.write(content);
|
||||
wdoc.close();
|
||||
printFrame(w)
|
||||
.done(function () {
|
||||
// Success
|
||||
setTimeout(function () {
|
||||
// Wait for IE
|
||||
if (iframeCount === 0) {
|
||||
// Destroy the iframe if created here
|
||||
$iframe.remove();
|
||||
}
|
||||
}, 100);
|
||||
})
|
||||
.fail(function (err) {
|
||||
// Use the pop-up method if iframe fails for some reason
|
||||
console.error("Failed to print from iframe", err);
|
||||
printContentInNewWindow(content);
|
||||
})
|
||||
.always(function () {
|
||||
try {
|
||||
options.deferred.resolve();
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// Use the pop-up method if iframe fails for some reason
|
||||
console.error("Failed to print from iframe", e.stack, e.message);
|
||||
printContentInNewWindow(content)
|
||||
.always(function () {
|
||||
try {
|
||||
options.deferred.resolve();
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Use a new window for printing
|
||||
printContentInNewWindow(content)
|
||||
.always(function () {
|
||||
try {
|
||||
options.deferred.resolve();
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this;
|
||||
};
|
||||
})(jQuery);
|
||||
File diff suppressed because one or more lines are too long
+3092
File diff suppressed because it is too large
Load Diff
Executable
+1508
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,841 @@
|
||||
var smallH=0,smallW=0,bigH=0,bigW=0;
|
||||
var unitsmall=0,unitbig=0,colsmall=0,colbig=0;
|
||||
var roll=0;LiWidth=0;
|
||||
var BetStatus;
|
||||
var askData = false;
|
||||
$(function(){
|
||||
$(window).resize(function(){
|
||||
requestData(ludan);
|
||||
})
|
||||
requestData(ludan);
|
||||
getTime();
|
||||
// 滚动广告
|
||||
$(".notice ul li").each(function(){
|
||||
LiWidth+=$(this).innerWidth()
|
||||
})
|
||||
$(".notice ul").append($(".notice ul").html())
|
||||
var timer = setInterval(notice, 20);
|
||||
$(".notice").hover(function() {
|
||||
clearInterval(timer);
|
||||
},function() {
|
||||
timer = setInterval(notice, 20);
|
||||
})
|
||||
// 日期
|
||||
setInterval(function(){
|
||||
getTime();
|
||||
}, 1000);
|
||||
// 侧栏控台
|
||||
$(".control-box").hover(function(){
|
||||
$(this).stop().animate({right:"0"})
|
||||
},function(){
|
||||
$(this).stop().animate({right:"-410px"})
|
||||
})
|
||||
|
||||
|
||||
/* 键盘操作 */
|
||||
$(document).keydown(function (e){
|
||||
//alert(e.keyCode);
|
||||
//return false;
|
||||
if(e.keyCode == 98){
|
||||
$('#times').val('2');
|
||||
}
|
||||
if(e.keyCode == 99){
|
||||
$('#times').val('3');
|
||||
}
|
||||
if(e.keyCode == 100){
|
||||
$('#times').val('4');
|
||||
}
|
||||
if(e.keyCode == 101){
|
||||
$('#times').val('5');
|
||||
}
|
||||
if(e.keyCode == 13){
|
||||
opening();
|
||||
}
|
||||
if(e.keyCode == 97){
|
||||
$('#opening').val('1');
|
||||
showPng_noVoice(1);
|
||||
}
|
||||
if(e.keyCode == 102){
|
||||
$('#opening').val('2');
|
||||
showPng_noVoice(2);
|
||||
}
|
||||
if(e.keyCode == 107){
|
||||
startBet();
|
||||
}
|
||||
if(e.keyCode == 111){
|
||||
endBet();
|
||||
}
|
||||
if(e.keyCode == 109){
|
||||
$('#opening').val('0');
|
||||
$('#times').val('1');
|
||||
$('#openingPng').attr('src','');
|
||||
}
|
||||
if(e.keyCode == 103){
|
||||
$('#update_ludan').toggle();
|
||||
}
|
||||
//修改当前状态
|
||||
if(e.keyCode == 96){
|
||||
$('#update_ludan').toggle();
|
||||
}
|
||||
})
|
||||
|
||||
$("#confirm_update_ludan").click(function (){
|
||||
retreated();
|
||||
});
|
||||
$("#cancel_update_ludan").click(function (){
|
||||
$('#update_ludan').hide();
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
|
||||
var keyT;
|
||||
window.onkeydown = function(e){
|
||||
var timeout;
|
||||
if(!keyT){
|
||||
keyT=true;
|
||||
if(e.keyCode==105 || e.keyCode==57 || e.keyCode==33){
|
||||
timeout=setTimeout(function(){
|
||||
keyT=false;
|
||||
},500)
|
||||
}
|
||||
}else{
|
||||
keyT=false;
|
||||
if(e.keyCode==105 || e.keyCode==57 || e.keyCode==33){
|
||||
var image = new Image();
|
||||
var nid = $('#number_tab_dt_id').val();
|
||||
// var game_id = "{$table.game_id}";
|
||||
var game_id = $('#game_id').val();
|
||||
image.src1 = $("#canvas1")[0].toDataURL("image/png");
|
||||
image.src2 = $("#canvas2")[0].toDataURL("image/png");
|
||||
var canvas_bg=$("#canvas1").css("background");
|
||||
sessionStorage.setItem("canvas1",image.src1);
|
||||
sessionStorage.setItem("canvas2",image.src2);
|
||||
sessionStorage.setItem("canvas_bg",canvas_bg);
|
||||
$('#print_iframe').attr('src', '/index/stamp?nid='+nid+'&game_id='+game_id);
|
||||
$(".iframe-box").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
function close_print(){
|
||||
$(".iframe-box").hide();
|
||||
}
|
||||
|
||||
var getOnlineNumber = function (connections){
|
||||
var query = new Object();
|
||||
query.connections = connections;
|
||||
$.ajax({
|
||||
url:'/index/get_online_number',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
$('#onlineNumber').html(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var showPng = function (opening){
|
||||
if(opening == 1) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/banker.png');
|
||||
mp3List = ['banker_win.mp3'];
|
||||
}
|
||||
if(opening == 2) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/player.png');
|
||||
mp3List = ['player_win.mp3'];
|
||||
|
||||
}
|
||||
if(opening == 3) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/tie.png');
|
||||
mp3List = ['tie.mp3'];
|
||||
}
|
||||
audioMp3(mp3List).Play();
|
||||
$('#openingElement').show().delay(3000).hide(300);
|
||||
}
|
||||
|
||||
var showPng_noVoice = function (opening){
|
||||
var status = $('#number_tab_status').val();
|
||||
if(status == '2'){
|
||||
if(opening == 1) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/banker.png');
|
||||
}
|
||||
if(opening == 2) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/player.png');
|
||||
|
||||
}
|
||||
if(opening == 3) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/tie.png');
|
||||
}
|
||||
$('#openingElement').show();
|
||||
}else{
|
||||
layer.msg('开结果失败,请确认该铺是处于停止下注的状态');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
var audio=$("#audio").get(0);
|
||||
var mp3List;
|
||||
var num=0;
|
||||
|
||||
|
||||
function audioMp3(mp3List){
|
||||
var mp3=new Object();
|
||||
mp3.mp3List=mp3List;
|
||||
mp3.url="/static/console/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;
|
||||
}
|
||||
audio.addEventListener("ended", nextAudio);
|
||||
function nextAudio(){
|
||||
num+=1
|
||||
if(num<mp3List.length){
|
||||
audio.src="/static/console/mp3/"+mp3List[num];
|
||||
audio.play();
|
||||
}else{
|
||||
audio.pause();
|
||||
audio.currentTime = 0.0;
|
||||
// console.log("播完")
|
||||
num=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// WebSocket 数据交互
|
||||
var number_tab_id;
|
||||
if(window.WebSocket){
|
||||
var webSocket = new WebSocket(websocketUrl);
|
||||
webSocket.onerror = function(event){
|
||||
layer.alert('您已断开链接,请返回重新进入。',{icon:2,closeBtn:0});
|
||||
}
|
||||
webSocket.onopen = function (event) {
|
||||
var userid = $('#userid').val();
|
||||
var account = $('#account').val();
|
||||
var online_token = $('#online_token').val();
|
||||
if(parseInt(userid) > 0 && account != '' && online_token != ''){
|
||||
webSocket.send('{"connect":"space","mode":"onlineLogin","account":"'+account+'","userid":"'+userid+'","online_token":"'+online_token+'"}');
|
||||
}else{
|
||||
webSocket.close();
|
||||
layer.alert('您已断开链接,请返回重新进入。',{icon:2,closeBtn:0});
|
||||
}
|
||||
};
|
||||
// 桌子状态
|
||||
var setBetStatus = function (BetStatus){
|
||||
// console.log(BetStatus)
|
||||
if(BetStatus.type == 1){
|
||||
$('#betstatus').html(BetStatus.msg);
|
||||
}else if(BetStatus.type == 2){
|
||||
$('#number_tab_status').val(BetStatus.betStatus);
|
||||
$('#betstatus').html(BetStatus.betMsg);
|
||||
$('#opening_result').html('');
|
||||
}
|
||||
};
|
||||
// 获取桌子数据
|
||||
var setNumberInfo = function (round){
|
||||
number_tab_id=round.number_tab_id
|
||||
$('#boot_num').val(round.boot_num);//靴数
|
||||
$('#number').val(round.number_tab_number);// 局数
|
||||
$('#number_tab_dt_id').val(round.number_tab_id);
|
||||
$('#boot_id').val(round.boot_id);
|
||||
getResultToatl(round.tid,round.boot_id);
|
||||
};
|
||||
// 重置下注
|
||||
var clearBetAmount = function (){
|
||||
$('#banker_amount').html(0);
|
||||
$('#player_amount').html(0);
|
||||
$('#tie_amount').html(0);
|
||||
$('#all_amount').html(0);
|
||||
};
|
||||
// 获取 庄、闲、和、对 开局次数
|
||||
var getResultToatl = function (TableId,BootId){
|
||||
var query = new Object();
|
||||
query.table_id = TableId;
|
||||
query.boot_id = BootId;
|
||||
$.ajax({
|
||||
url:'/index/get_result_total',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
var resultToatl = data.data;
|
||||
$('#result_total_player').html(resultToatl.player);
|
||||
$('#result_total_banker').html(resultToatl.banker);
|
||||
$('#result_total_tie').html(resultToatl.tie);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var setBetAmount = function (amount){
|
||||
if(parseInt($('#all_amount').html()) > 0){
|
||||
var o_all_amount = parseInt($('#all_amount').html());
|
||||
}else{
|
||||
var o_all_amount = 0;
|
||||
}
|
||||
var all_amount = o_all_amount + amount.banker_amount + amount.player_amount + amount.banker_doub_amount + amount.player_doub_amount;
|
||||
$('#all_amount').html(all_amount);
|
||||
};
|
||||
|
||||
webSocket.onmessage = function (event) {
|
||||
var data = $.parseJSON(event.data);
|
||||
if(data.sendMode == 'onlineLogin'){
|
||||
if(data.status === true){
|
||||
//登录成功
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status)
|
||||
clearBetAmount();
|
||||
waybillFunc();
|
||||
// showForecast(); // 自动问路
|
||||
}else{
|
||||
//登录失败
|
||||
webSocket.close();
|
||||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||||
}
|
||||
}else if(data.sendMode == 'resetBoot' || data.sendMode == 'changeBoot'){
|
||||
//console.log(data);
|
||||
if(data.status === true){
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
clearBetAmount();
|
||||
waybillFunc();
|
||||
hiddenForecast(); //隐藏自动问路
|
||||
}else{
|
||||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||||
}
|
||||
}else if(data.sendMode == 'startBet'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
}else{
|
||||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||||
}
|
||||
}else if(data.sendMode == 'startBetCountDown'){
|
||||
if(data.status === true && data.countDown >= 0){
|
||||
countDown(data.countDown);
|
||||
}else{
|
||||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||||
}
|
||||
}else if(data.sendMode == 'endBet'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
clearTimeout(t);
|
||||
c = parseInt($('#wait_time').val());
|
||||
}else{
|
||||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||||
}
|
||||
}else if(data.sendMode == 'toBet'){
|
||||
if(data.status === true){
|
||||
setBetAmount(data.betAmountMsgAdd);
|
||||
}
|
||||
}else if(data.sendMode == 'inCheckout'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
clearBetAmount();
|
||||
}else{
|
||||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||||
}
|
||||
}else if(data.sendMode == 'openingDn'){
|
||||
if(data.status === true){
|
||||
showPng(data.round.opening);
|
||||
$('#opening').val(0);
|
||||
$('#times').val(1);
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
clearBetAmount();
|
||||
waybillFunc();
|
||||
// showForecast(); // 自动问路
|
||||
//autoBet(); // 自动开始下注
|
||||
}else{
|
||||
$('#opening').val(0);
|
||||
$('#times').val(1);
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'sendOnlienNumberExit' || data.sendMode == 'sendOnlienNumberEntry' || data.sendMode == 'sendOnlienNumberSpaceEntry'){
|
||||
$('#onlineNumber').html(data.number);
|
||||
if(data.sendMode == 'sendOnlienNumberEntry'){
|
||||
if(data.betStatus == 0){
|
||||
//mp3List = ['welcome.mp3'];
|
||||
//audioMp3(mp3List).Play();
|
||||
//autoBet(true);
|
||||
}
|
||||
}
|
||||
}else if(data.sendMode == 'retreated'){
|
||||
if(data.status === true){
|
||||
$("#update_ludan").hide();
|
||||
waybillFunc();
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
}else if(data.sendMode == 'RepeatedEntry'){
|
||||
webSocket.close();
|
||||
layer.msg(lang[data.msg]);
|
||||
setTimeout(function (){
|
||||
window.location.href='/login/logout';
|
||||
},2000);
|
||||
}
|
||||
};
|
||||
var inCheckout = function(){
|
||||
layer.confirm('是否需要将桌子的状态设置为"洗牌中"?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"inCheckout","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
var resetBoot = function(){
|
||||
layer.confirm('是否需要进行日结算?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"resetBoot","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var changeBoot = function(){
|
||||
layer.confirm('是否需要进行换靴?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"changeBoot","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var startBet = function(){
|
||||
webSocket.send('{"connect":"space","mode":"startBet","number_tab_id":"'+parseInt(number_tab_id)+'"}');
|
||||
|
||||
|
||||
var betStatus=$("#number_tab_status").val()
|
||||
if(betStatus==0){
|
||||
mp3List = ['start.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
};
|
||||
var endBet = function (){
|
||||
|
||||
webSocket.send('{"connect":"space","mode":"endBet","number_tab_id":"'+parseInt(number_tab_id)+'"}');
|
||||
var betStatus=$("#number_tab_status").val()
|
||||
if(betStatus==1){
|
||||
$(".countdown .num").html($("#wait_time").val())
|
||||
$(".countdown").fadeOut();
|
||||
mp3List = ['stop_2.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
};
|
||||
var opening = function(){
|
||||
$('.control-box .btn-box2 span').removeClass('on');
|
||||
var opening = $('#opening').val();
|
||||
var times = $('#times').val();
|
||||
var number_tab_dt_id = $('#number_tab_dt_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"openingDn","number_tab_id":"'+parseInt(number_tab_dt_id)+'","opening":"'+opening+'","times":"'+parseInt(times)+'"}');
|
||||
$('#openingElement').addClass("blink")
|
||||
setTimeout(function(){
|
||||
$('#openingElement').removeClass("blink").delay(3000).hide(1);
|
||||
},2900)
|
||||
};
|
||||
//回档方法
|
||||
var retreated = function(){
|
||||
var game_id = parseInt($('#game_id').val());
|
||||
var table_id = parseInt($('#table_id').val());
|
||||
var boot_id = parseInt($('#boot_id').val());
|
||||
var number_tab_id = parseInt($('#number_tab_dt_id').val());
|
||||
var update_ludan_result = $('#update_ludan_result').val();
|
||||
if(update_ludan_result == ''){
|
||||
layer.msg('请选择要修改的结果');
|
||||
return false;
|
||||
}
|
||||
webSocket.send('{"connect":"space","mode":"retreated","number_tab_id":"'+number_tab_id+'","boot_id":"'+boot_id+'","table_id":"'+table_id+'","game_id":"'+game_id+'","result":"'+update_ludan_result+'"}');
|
||||
}
|
||||
/* *** 确认提交结果方法 *** */
|
||||
var confirmResult = function(id,result){
|
||||
$('.control-box .btn-box2 span').eq(0).removeClass('on');
|
||||
$('.control-box .btn-box2 span').eq(1).removeClass('on');
|
||||
$('.control-box .btn-box2 span').eq(2).removeClass('on');
|
||||
var is_on=$("#"+id).hasClass("on");
|
||||
if(is_on){
|
||||
$("#"+id).removeClass("on")
|
||||
}else{
|
||||
$("#"+id).addClass("on")
|
||||
}
|
||||
$('#opening').val(result);
|
||||
showPng_noVoice(result);
|
||||
};
|
||||
/* *** 确认提交结果方法 *** */
|
||||
}else{
|
||||
layer.alert('您的浏览器不支持WebSocket',{icon:2,closeBtn:0});
|
||||
}
|
||||
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.boot_id = $('#boot_id').val();
|
||||
data.game_id = $('#game_id').val();
|
||||
$.ajax({
|
||||
url:"/index/waybill",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
requestData(ludan);
|
||||
}
|
||||
});
|
||||
}
|
||||
//庄问路
|
||||
var getLudanBanker = function(){
|
||||
var next = new Object;
|
||||
next.boot_id = $('#boot_id').val();
|
||||
next.game_id = $('#game_id').val();
|
||||
next.forecast = 1;
|
||||
$.ajax({
|
||||
url:"/index/waybill",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
async:false,
|
||||
success:function(data){
|
||||
askData = data;
|
||||
}
|
||||
});
|
||||
return askData
|
||||
}
|
||||
//闲问路
|
||||
var getLudanPlayer = function(){
|
||||
var next = new Object;
|
||||
next.boot_id = $('#boot_id').val();
|
||||
next.game_id = $('#game_id').val();
|
||||
next.forecast = 2;
|
||||
$.ajax({
|
||||
url:"/index/waybill",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:next,
|
||||
async:false,
|
||||
success:function(data){
|
||||
askData = data;
|
||||
}
|
||||
});
|
||||
return askData
|
||||
}
|
||||
|
||||
// 自动问路
|
||||
// 自动问路
|
||||
// var showForecast = function(){
|
||||
// var len = 0;
|
||||
// // 庄自动问路
|
||||
// var bankerResult = getLudanBanker();
|
||||
// if(bankerResult.status == true){
|
||||
// var bankerResult = bankerResult.waybill;
|
||||
// // 大眼路
|
||||
// if(bankerResult.bigEyeRoad!=""){
|
||||
// len = bankerResult.bigEyeRoad.length - 1;
|
||||
// if(bankerResult.bigEyeRoad[len].result == 1){
|
||||
// $('#bankerask').find('.circle').css('border-color','red').css('opacity',1);
|
||||
// }else if(bankerResult.bigEyeRoad[len].result == 2){
|
||||
// $('#bankerask').find('.circle').css('border-color','blue').css('opacity',1);
|
||||
// }
|
||||
// }
|
||||
// // 小路
|
||||
// if(bankerResult.pathway!=""){
|
||||
// len = bankerResult.pathway.length - 1;
|
||||
// if(bankerResult.pathway[len].result == 1){
|
||||
// $('#bankerask').find('.round').css('border-color','red').css('background-color','red').css('opacity',1);
|
||||
// }else if(bankerResult.pathway[len].result == 2){
|
||||
// $('#bankerask').find('.round').css('border-color','blue').css('background-color','blue').css('opacity',1);
|
||||
// }
|
||||
// }
|
||||
// // 曱甴路
|
||||
// if(bankerResult.roach!=""){
|
||||
// len = bankerResult.roach.length - 1;
|
||||
// if(bankerResult.roach[len].result == 1){
|
||||
// $('#bankerask').find('.bar').removeClass('blue').removeClass('red');
|
||||
// $('#bankerask').find('.bar').addClass('red').css('opacity',1);
|
||||
// }else if(bankerResult.roach[len].result == 2){
|
||||
// $('#bankerask').find('.bar').removeClass('blue').removeClass('red');
|
||||
// $('#bankerask').find('.bar').addClass('blue').css('opacity',1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 闲自动问路
|
||||
// var playerResult = getLudanPlayer();
|
||||
// if(playerResult.status == true){
|
||||
// var playerResult = playerResult.waybill;
|
||||
// // 大眼路
|
||||
// if(playerResult.bigEyeRoad!=""){
|
||||
// var len = playerResult.bigEyeRoad.length - 1;
|
||||
// if(playerResult.bigEyeRoad[len].result == 1){
|
||||
// $('#playerask').find('.circle').css('border-color','red').css('opacity',1);
|
||||
// }else if(playerResult.bigEyeRoad[len].result == 2){
|
||||
// $('#playerask').find('.circle').css('border-color','blue').css('opacity',1);
|
||||
// }
|
||||
// }
|
||||
// // 小路
|
||||
// if(playerResult.pathway!=""){
|
||||
// len = playerResult.pathway.length - 1;
|
||||
// if(playerResult.pathway[len].result == 1){
|
||||
// $('#playerask').find('.round').css('border-color','red').css('background-color','red').css('opacity',1);
|
||||
// }else if(playerResult.pathway[len].result == 2){
|
||||
// $('#playerask').find('.round').css('border-color','blue').css('background-color','blue').css('opacity',1);
|
||||
// }
|
||||
// }
|
||||
// // 曱甴路
|
||||
// if(playerResult.roach!=""){
|
||||
// len = playerResult.roach.length - 1;
|
||||
// if(playerResult.roach[len].result == 1){
|
||||
// $('#playerask').find('.bar').removeClass('blue').removeClass('red');
|
||||
// $('#playerask').find('.bar').addClass('red').css('opacity',1);
|
||||
// }else if(playerResult.roach[len].result == 2){
|
||||
// $('#playerask').find('.bar').removeClass('blue').removeClass('red');
|
||||
// $('#playerask').find('.bar').addClass('blue').css('opacity',1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
// 换靴时隐藏自动问路
|
||||
var hiddenForecast = function(){
|
||||
$('#bankerask').find('.circle').css('opacity',0);
|
||||
$('#bankerask').find('.round').css('opacity',0);
|
||||
$('#bankerask').find('.bar').css('opacity',0);
|
||||
$('#playerask').find('.circle').css('opacity',0);
|
||||
$('#playerask').find('.round').css('opacity',0);
|
||||
$('#playerask').find('.bar').css('opacity',0);
|
||||
}
|
||||
|
||||
|
||||
// 问路方法
|
||||
var askInterval;
|
||||
function ask(newdata,olddata){
|
||||
var time=8;
|
||||
askInterval=setInterval(function(){
|
||||
time--;
|
||||
var num=time%2;
|
||||
if(time<0){
|
||||
clearInterval(askInterval);
|
||||
}else{
|
||||
if(num==1){
|
||||
requestData(newdata)
|
||||
}else{
|
||||
requestData(olddata)
|
||||
}
|
||||
}
|
||||
},200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function requestData(data){
|
||||
smallH=$(".canvas-box.small").height();
|
||||
smallW=$(".canvas-box.small").width();
|
||||
|
||||
// 计算单位
|
||||
unitsmall=smallH/18;
|
||||
|
||||
// 计算列个数
|
||||
colsmall=Math.floor(smallW/unitsmall);
|
||||
colbig=Math.floor(bigW/unitbig);
|
||||
|
||||
|
||||
CanvasTable("#canvas1",unitsmall,18,colsmall,data);
|
||||
// $(".canvas-box .active-box").width($(".table-data").width()+16)
|
||||
}
|
||||
|
||||
function CanvasTable(Id,unit,rows,cols,data){
|
||||
var width=unit*cols,
|
||||
height=unit*rows;
|
||||
$(Id).attr("width",width)
|
||||
$(Id).attr("height",height)
|
||||
// $(Id).css("width",width)
|
||||
$(Id).css("height",height)
|
||||
var canvasId=$(Id);
|
||||
var ctb=canvasId[0].getContext('2d');
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#919191";//线条颜色
|
||||
|
||||
ctb.beginPath();
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(width, 0.5);
|
||||
for (var i = 0; i <= rows; i++) {
|
||||
ctb.moveTo(0, unit*i);
|
||||
ctb.lineTo(width, unit*i);
|
||||
}
|
||||
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
|
||||
|
||||
ctb.beginPath();
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, height);
|
||||
for (var j = 1; j <= cols; j++) {
|
||||
ctb.moveTo(unit*j,0);
|
||||
ctb.lineTo(unit*j,height);
|
||||
}
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;//线条宽度
|
||||
ctb.strokeStyle = "#000";//线条颜色
|
||||
ctb.moveTo(0, unit*6);
|
||||
ctb.lineTo(width, unit*6);
|
||||
ctb.moveTo(0, unit*12);
|
||||
ctb.lineTo(width, unit*12);
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
|
||||
if(data){
|
||||
if(data.waybill){
|
||||
if(data.waybill.bigRoad){
|
||||
$.each(data.waybill.bigRoad,function(i,v){
|
||||
if(v.show_x<=cols){
|
||||
BigPath(ctb,unit,v.show_x,v.show_y,v.result)
|
||||
}else if(v.show_x<=2*cols){
|
||||
BigPath(ctb,unit,v.show_x-cols,v.show_y+6,v.result)
|
||||
}else if(v.show_x<=3*cols){
|
||||
BigPath(ctb,unit,v.show_x-2*cols,v.show_y+12,v.result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 大路
|
||||
function BigPath(ctb,unit,x,y,type,slash,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = unit*0.06;
|
||||
var radius=unit/2
|
||||
if(type==2){
|
||||
var color="#0000ff";
|
||||
}else if(type==1){
|
||||
var color="#bc1025"
|
||||
}
|
||||
ctb.strokeStyle = color;
|
||||
ctb.arc(radius+unit*(x-1),radius+unit*(y-1), unit*0.38, 0, Math.PI * 2);
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function countDown(time) {
|
||||
$(".countdown .num").html(time);
|
||||
$(".countdown").fadeIn();
|
||||
if(time<=0){
|
||||
mp3List = ['stop_2.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
$(".countdown").fadeOut();
|
||||
webSocket.send('{"connect":"space","mode":"endBet","number_tab_id":"'+parseInt(number_tab_id)+'"}');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function notice(){
|
||||
if (roll == -LiWidth) {
|
||||
roll = 0;
|
||||
}
|
||||
roll -= 1;
|
||||
$(".notice .scroll").css({
|
||||
left: roll
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function getTime() {
|
||||
var today = new Date();
|
||||
var h = today.getHours();
|
||||
var minute = today.getMinutes()
|
||||
var s = today.getSeconds();
|
||||
if (h < 10) {
|
||||
h = "0" + h;
|
||||
}
|
||||
if (minute < 10) {
|
||||
minute = "0" + minute;
|
||||
}
|
||||
if (s < 10) {
|
||||
s = "0" + s;
|
||||
}
|
||||
var strDate = (" " + today.getFullYear() + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + h + ":" + minute + ":" + s);
|
||||
var n_day = today.getDay();
|
||||
switch (n_day) {
|
||||
case 0:
|
||||
var week = " 星期日 "
|
||||
break;
|
||||
case 1:
|
||||
var week = " 星期一 "
|
||||
break;
|
||||
case 2:
|
||||
var week = " 星期二 "
|
||||
break;
|
||||
case 3:
|
||||
var week = " 星期三 "
|
||||
break;
|
||||
case 4:
|
||||
var week = " 星期四 "
|
||||
break;
|
||||
case 5:
|
||||
var week = " 星期五 "
|
||||
break;
|
||||
case 6:
|
||||
var week = " 星期六 "
|
||||
break;
|
||||
case 7:
|
||||
var week = " 星期日 "
|
||||
break;
|
||||
}
|
||||
$('.date').find('p').html(strDate);
|
||||
$('.date').find('span').html(week);
|
||||
}
|
||||
|
||||
|
||||
function autoBet(data){
|
||||
var number = $('#onlineNumber').text();
|
||||
var bet_type = $('#bet_type').val();
|
||||
// 只有网络投注的桌子才自动开始下注
|
||||
if(bet_type == 1 || bet_type == 3){
|
||||
if(data == true){
|
||||
// 客户刚进来
|
||||
startBet();
|
||||
}else{
|
||||
// 开结果之后 只有在线人数大于0时才自动开始下注
|
||||
if(number > 0){
|
||||
setTimeout(function(){
|
||||
startBet();
|
||||
},5000)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+1330
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Executable
+868
@@ -0,0 +1,868 @@
|
||||
var smallH=0,smallW=0,bigH=0,bigW=0;
|
||||
var unitsmall=0,unitbig=0,colsmall=0,colbig=0;
|
||||
var roll=0;LiWidth=0;
|
||||
var BetStatus;
|
||||
var askData = false;
|
||||
$(function(){
|
||||
$(window).resize(function(){
|
||||
waybillFunc()
|
||||
})
|
||||
// waybillFunc()
|
||||
getTime();
|
||||
// 滚动广告
|
||||
$(".notice ul li").each(function(){
|
||||
LiWidth+=$(this).innerWidth()
|
||||
});
|
||||
$(".notice ul").append($(".notice ul").html())
|
||||
var timer = setInterval(notice, 20);
|
||||
$(".notice").hover(function() {
|
||||
clearInterval(timer);
|
||||
},function() {
|
||||
timer = setInterval(notice, 20);
|
||||
})
|
||||
// 日期
|
||||
setInterval(function(){
|
||||
getTime();
|
||||
}, 1000);
|
||||
// 侧栏控台
|
||||
$(".control-box").hover(function(){
|
||||
$(this).stop().animate({right:"0"})
|
||||
},function(){
|
||||
$(this).stop().animate({right:"-410px"})
|
||||
})
|
||||
/* 键盘操作 */
|
||||
$(document).keydown(function (e){
|
||||
if(e.keyCode == 111){
|
||||
startBet();
|
||||
}
|
||||
if(e.keyCode == 96){
|
||||
endBet();
|
||||
}
|
||||
if(e.keyCode == 13){
|
||||
opening();
|
||||
}
|
||||
})
|
||||
$("#confirm_update_ludan").click(function (){
|
||||
retreated();
|
||||
});
|
||||
$("#cancel_update_ludan").click(function (){
|
||||
$('#update_ludan').hide();
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
function close_print(){
|
||||
$(".iframe-box").hide();
|
||||
}
|
||||
var showPng = function (opening){
|
||||
if(opening == 1) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/banker.png');
|
||||
mp3List = ['banker_win.mp3'];
|
||||
}
|
||||
if(opening == 2) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/player.png');
|
||||
mp3List = ['player_win.mp3'];
|
||||
}
|
||||
if(opening == 3) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/tie.png');
|
||||
mp3List = ['tie.mp3'];
|
||||
}
|
||||
audioMp3(mp3List).Play();
|
||||
$('#openingElement').show().delay(3000).hide(300);
|
||||
}
|
||||
|
||||
var showPng_noVoice = function (opening){
|
||||
var status = $('#number_tab_status').val();
|
||||
if(status == '2'){
|
||||
if(opening == 1) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/banker.png');
|
||||
}
|
||||
if(opening == 2) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/player.png');
|
||||
}
|
||||
if(opening == 3) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/tie.png');
|
||||
}
|
||||
$('#openingElement').show();
|
||||
}else{
|
||||
layer.msg('开结果失败,请确认该铺是处于停止下注的状态');
|
||||
}
|
||||
}
|
||||
function flop_position(data){
|
||||
pokercard=data.round.card;
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$('.begincard .position-card .card').css("opacity",1);
|
||||
$('.begincard .position-card .card').find(".face").css("background-image","url("+pokersrc+")");
|
||||
}
|
||||
function flop_card(data){
|
||||
order_num = data.round.order_num;
|
||||
card_cow = order_num.substring(0,1);
|
||||
card_list = order_num.substring(1,2) - 1;
|
||||
if(card_cow == 1){
|
||||
box_name = 'player-1-card';
|
||||
if(data.round.result){
|
||||
$('.player_1_result').html(data.round.result);
|
||||
}
|
||||
}else if(card_cow == 2){
|
||||
box_name = 'player-2-card';
|
||||
if(data.round.result){
|
||||
$('.player_2_result').html(data.round.result);
|
||||
}
|
||||
}else if(card_cow == 3){
|
||||
box_name = 'player-3-card';
|
||||
if(data.round.result){
|
||||
$('.player_3_result').html(data.round.result);
|
||||
}
|
||||
}else if(card_cow == 4){
|
||||
box_name = 'banker-card';
|
||||
if(data.round.result){
|
||||
$('.banker_result').html(data.round.result);
|
||||
}
|
||||
}
|
||||
if(40<order_num){
|
||||
$('.box1').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
if(10<order_num && order_num<20){
|
||||
$('.box2').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
if(20<order_num && order_num<30){
|
||||
$('.box3').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
if(30<order_num && order_num<40){
|
||||
$('.box4').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
pokercard=data.round.card;
|
||||
$poker=$('.begincard '+'.'+ box_name+' .card');
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$poker.eq(card_list).find(".face").css("background-image","url("+pokersrc+")")
|
||||
$('.begincard '+'.'+ box_name).find(".card").eq(card_list).css('opacity',1);
|
||||
}
|
||||
|
||||
var audio=$("#audio").get(0);
|
||||
var mp3List;
|
||||
var num=0;
|
||||
|
||||
|
||||
function audioMp3(mp3List){
|
||||
var mp3=new Object();
|
||||
mp3.mp3List=mp3List;
|
||||
mp3.url="/static/console/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;
|
||||
}
|
||||
audio.addEventListener("ended", nextAudio);
|
||||
function nextAudio(){
|
||||
num+=1
|
||||
if(num<mp3List.length){
|
||||
audio.src="/static/console/mp3/"+mp3List[num];
|
||||
audio.play();
|
||||
}else{
|
||||
audio.pause();
|
||||
audio.currentTime = 0.0;
|
||||
num=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// WebSocket 数据交互
|
||||
var number_tab_id;
|
||||
if(window.WebSocket){
|
||||
var webSocket = new ReconnectingWebSocket(websocketUrl,null,{debug:true,reconnectInterval:3000});
|
||||
webSocket.onerror = function(event){
|
||||
layer.msg('您已断开链接,请返回重新进入。');
|
||||
}
|
||||
webSocket.onopen = function (event) {
|
||||
var userid = $('#userid').val();
|
||||
var account = $('#account').val();
|
||||
var online_token = $('#online_token').val();
|
||||
var table_id = $('#table_id').val();
|
||||
if(parseInt(userid) > 0 && account != '' && online_token != ''){
|
||||
webSocket.send('{"connect":"space","mode":"onlineLogin","account":"'+account+'","userid":"'+userid+'","table_id":"'+table_id+'","online_token":"'+online_token+'"}');
|
||||
}else{
|
||||
webSocket.close();
|
||||
layer.msg('您已断开链接,请返回重新进入。');
|
||||
}
|
||||
};
|
||||
// 桌子状态
|
||||
var setBetStatus = function (BetStatus){
|
||||
if(BetStatus.type == 1){
|
||||
$('#betstatus').html(BetStatus.msg);
|
||||
}else if(BetStatus.type == 2){
|
||||
$('#number_tab_status').val(BetStatus.betStatus);
|
||||
$('#betstatus').html(BetStatus.betMsg);
|
||||
$('#opening_result').html('');
|
||||
}
|
||||
};
|
||||
// 获取桌子数据
|
||||
var setNumberInfo = function (round){
|
||||
number_tab_id=round.number_tab_id
|
||||
$('#boot_num').val(round.boot_num);//靴数
|
||||
$('#number').val(round.number_tab_number);// 局数
|
||||
$('#number_tab_dt_id').val(round.number_tab_id);
|
||||
$('#boot_id').val(round.boot_id);
|
||||
getResultToatl(round.tid,round.boot_id);
|
||||
};
|
||||
// 获取 庄、闲、和、对 开局次数
|
||||
var getResultToatl = function (TableId,BootId){
|
||||
var query = new Object();
|
||||
query.table_id = TableId;
|
||||
query.boot_id = BootId;
|
||||
$.ajax({
|
||||
url:'/nn/get_result_total',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
var resultToatl = data.data;
|
||||
$('#result_total_player').html(resultToatl.player);
|
||||
$('#result_total_banker').html(resultToatl.banker);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
webSocket.onmessage = function (event) {
|
||||
var data = $.parseJSON(event.data);
|
||||
var table_id = parseInt($('#table_id').val());
|
||||
if(data.table_id == table_id){
|
||||
if(data.sendMode == 'onlineLogin'){
|
||||
if(data.status === true){
|
||||
//登录成功
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
waybillFunc();
|
||||
if(data.round.bet_status == 2){
|
||||
$(".begincard").fadeIn(function(){
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"1"});
|
||||
});
|
||||
card_number_info = data.card_info;
|
||||
if(card_number_info.length > 0){
|
||||
for(var i=0;i<card_number_info.length;i++){
|
||||
if(card_number_info[i]['order_num'] == 0){
|
||||
pokercard=card_number_info[i]['card'];
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$('.begincard .position-card .card').css("opacity",1);
|
||||
$('.begincard .position-card .card').find(".face").css("background-image","url("+pokersrc+")");
|
||||
}else{
|
||||
pokercard=card_number_info[i]['card'];
|
||||
order_num = card_number_info[i]['order_num'];
|
||||
card_cow = card_number_info[i]['order_num'].substring(0,1);
|
||||
card_list = card_number_info[i]['order_num'].substring(1,2) - 1;
|
||||
if(card_cow == 1){
|
||||
box_name = 'player-1-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.player_1_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}else if(card_cow == 2){
|
||||
box_name = 'player-2-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.player_2_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}else if(card_cow == 3){
|
||||
box_name = 'player-3-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.player_3_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}else if(card_cow == 4){
|
||||
box_name = 'banker-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.banker_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}
|
||||
$poker=$('.begincard '+'.'+ box_name+' .card');
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$poker.eq(card_list).find(".face").css("background-image","url("+pokersrc+")")
|
||||
$('.begincard '+'.'+ box_name).find(".card").eq(card_list).css('opacity',1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
webSocket.close();
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'sendScanResult'){
|
||||
if(data.round.position == 0){
|
||||
flop_position(data);
|
||||
}else{
|
||||
flop_card(data);
|
||||
}
|
||||
}else if(data.sendMode == 'resetBoot' || data.sendMode == 'changeBoot'){
|
||||
if(data.status === true){
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
waybillFunc();
|
||||
hiddenForecast(); //隐藏自动问路
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'startBet'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'startBetCountDown'){
|
||||
if(data.status === true && data.countDown >= 0){
|
||||
countDown(data.countDown);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'endBet'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
$(".begincard").fadeIn(function(){
|
||||
$(".list .card").css("opacity","0");
|
||||
$(".banker_result").html('');
|
||||
$(".player_1_result").html('');
|
||||
$(".player_2_result").html('');
|
||||
$(".player_3_result").html('');
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"1"});
|
||||
});
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'toBet'){
|
||||
}else if(data.sendMode == 'inCheckout'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'openingNn'){
|
||||
if(data.status === true){
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
waybillFunc();
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
setTimeout(function(){
|
||||
$(".begincard").fadeOut(function(){
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"0"});
|
||||
});
|
||||
},1000);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'sendScanReset'){
|
||||
if(data.status === true){
|
||||
$(".list .card").css("opacity","0");
|
||||
$(".banker_result").html('');
|
||||
$(".player_1_result").html('');
|
||||
$(".player_2_result").html('');
|
||||
$(".player_3_result").html('');
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
}else if(data.sendMode == 'retreated'){
|
||||
if(data.status === true){
|
||||
$("#update_ludan").hide();
|
||||
waybillFunc();
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
}else if(data.sendMode == 'RepeatedEntry'){
|
||||
webSocket.close();
|
||||
layer.msg(lang[data.msg]);
|
||||
setTimeout(function (){
|
||||
window.location.href='/login/logout';
|
||||
},2000);
|
||||
}else if(data.sendMode == 'resetNumberTab'){
|
||||
if(data.status == true){
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
$(".countdown").fadeOut();
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
setTimeout(function(){
|
||||
$(".begincard").fadeOut(function(){
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"0"});
|
||||
});
|
||||
},200);
|
||||
}else{
|
||||
layer.msg(lang[data.msg] || data.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var inCheckout = function(){
|
||||
layer.confirm('是否需要将桌子的状态设置为"洗牌中"?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"inCheckout","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
var resetBoot = function(){
|
||||
layer.confirm('是否需要进行日结算?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"resetBoot","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var changeBoot = function(){
|
||||
layer.confirm('是否需要进行换靴?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"changeBoot","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var resetNumberTab = function(){
|
||||
layer.confirm(lang.is_reset_number,{btn: [lang.confirm,lang.cancel],title:lang.message}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"resetNumberTab","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var startBet = function(){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"startBet","number_tab_id":"'+parseInt(number_tab_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
var betStatus=$("#number_tab_status").val();
|
||||
if(betStatus==0){
|
||||
mp3List = ['start.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
};
|
||||
var endBet = function (){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"endBet","number_tab_id":"'+parseInt(number_tab_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
var betStatus=$("#number_tab_status").val();
|
||||
if(betStatus==1){
|
||||
$(".countdown .num").html($("#wait_time").val())
|
||||
$(".countdown").fadeOut();
|
||||
mp3List = ['stop_2.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
};
|
||||
var opening = function(){
|
||||
var table_id = $('#table_id').val();
|
||||
$('.control-box .btn-box2 span').removeClass('on');
|
||||
var number_tab_dt_id = $('#number_tab_dt_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"openingNn","number_tab_id":"'+parseInt(number_tab_dt_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
};
|
||||
//回档方法
|
||||
var retreated = function(){
|
||||
var game_id = parseInt($('#game_id').val());
|
||||
var table_id = parseInt($('#table_id').val());
|
||||
var boot_id = parseInt($('#boot_id').val());
|
||||
var number_tab_id = parseInt($('#number_tab_dt_id').val());
|
||||
var update_ludan_result = $('#update_ludan_result').val();
|
||||
if(update_ludan_result == ''){
|
||||
layer.msg('请选择要修改的结果');
|
||||
return false;
|
||||
}
|
||||
webSocket.send('{"connect":"space","mode":"retreated","number_tab_id":"'+number_tab_id+'","boot_id":"'+boot_id+'","table_id":"'+table_id+'","game_id":"'+game_id+'","result":"'+update_ludan_result+'"}');
|
||||
}
|
||||
var confirmResult = function(id,result){
|
||||
$('.control-box .btn-box2 span').eq(0).removeClass('on');
|
||||
$('.control-box .btn-box2 span').eq(1).removeClass('on');
|
||||
$('.control-box .btn-box2 span').eq(2).removeClass('on');
|
||||
var is_on=$("#"+id).hasClass("on");
|
||||
if(is_on){
|
||||
$("#"+id).removeClass("on")
|
||||
}else{
|
||||
$("#"+id).addClass("on")
|
||||
}
|
||||
showPng_noVoice(result);
|
||||
};
|
||||
}else{
|
||||
layer.msg('您的浏览器不支持WebSocket');
|
||||
}
|
||||
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.boot_id = $('#boot_id').val();
|
||||
data.game_id = $('#game_id').val();
|
||||
$.ajax({
|
||||
url:"/nn/waybill",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
requestData(ludan.waybill);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 换靴时隐藏自动问路
|
||||
var hiddenForecast = function(){
|
||||
$('#bankerask').find('.circle').css('opacity',0);
|
||||
$('#bankerask').find('.round').css('opacity',0);
|
||||
$('#bankerask').find('.bar').css('opacity',0);
|
||||
$('#playerask').find('.circle').css('opacity',0);
|
||||
$('#playerask').find('.round').css('opacity',0);
|
||||
$('#playerask').find('.bar').css('opacity',0);
|
||||
}
|
||||
function requestData(data){
|
||||
smallH=$(".canvas-box.small").height();
|
||||
smallW=$(".canvas-box.small").width();
|
||||
// 计算单位
|
||||
unitsmall=smallH/12;
|
||||
// 计算列个数
|
||||
colsmall=Math.floor(smallW/unitsmall);
|
||||
if(colsmall%2!=0){
|
||||
colsmall=colsmall-1
|
||||
}
|
||||
CanvasTable("#canvas1",unitsmall,12,colsmall,data);
|
||||
}
|
||||
|
||||
function CanvasTable(Id,unit,rows,cols,data){
|
||||
var width=unit*cols,
|
||||
height=unit*rows;
|
||||
$(Id).attr("width",width)
|
||||
$(Id).attr("height",height)
|
||||
$(Id).css("height",height)
|
||||
var canvasId=$(Id);
|
||||
var ctb=canvasId[0].getContext('2d');
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#919191";//线条颜色
|
||||
ctb.beginPath();
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(width, 0.5);
|
||||
for (var i = 0; i <= rows; i++) {
|
||||
ctb.moveTo(0, unit*i);
|
||||
ctb.lineTo(width, unit*i);
|
||||
}
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
ctb.beginPath();
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, height);
|
||||
for (var j = 1; j <= cols; j++) {
|
||||
ctb.moveTo(unit*j*2,0);
|
||||
ctb.lineTo(unit*j*2,height);
|
||||
}
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;//线条宽度
|
||||
ctb.strokeStyle = "#000";//线条颜色
|
||||
ctb.moveTo(0, unit*4);
|
||||
ctb.lineTo(width, unit*4);
|
||||
ctb.moveTo(0, unit*8);
|
||||
ctb.lineTo(width, unit*8);
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
title(ctb,unit,1,1,1);
|
||||
title(ctb,unit,1,2,2);
|
||||
title(ctb,unit,1,3,3);
|
||||
title(ctb,unit,1,4,4);
|
||||
title(ctb,unit,1,5,1);
|
||||
title(ctb,unit,1,6,2);
|
||||
title(ctb,unit,1,7,3);
|
||||
title(ctb,unit,1,8,4);
|
||||
title(ctb,unit,1,9,1);
|
||||
title(ctb,unit,1,10,2);
|
||||
title(ctb,unit,1,11,3);
|
||||
title(ctb,unit,1,12,4);
|
||||
cutRoad(ctb,unit,data,cols);
|
||||
}
|
||||
function cutRoad(ctb,unit,data,cols){
|
||||
var L=data.length/4;
|
||||
var new_roadData=[];
|
||||
var Tab=0;
|
||||
|
||||
last_x = (cols/2-1)*3-1;
|
||||
if(L > (cols/2-1)*3-1){
|
||||
var cut = L - last_x;
|
||||
$.each(data,function(i,v){
|
||||
if(v.show_x>cut){
|
||||
new_roadData.push(v)
|
||||
}
|
||||
})
|
||||
$.each(new_roadData,function(i,v){
|
||||
v.show_x = v.show_x - cut;
|
||||
if(v.show_x<=(cols/2-1)){
|
||||
showPath(ctb,unit,v.show_x,v.show_y,v.type,v.result,v.is_win)
|
||||
}else if(v.show_x<=cols-2){
|
||||
showPath(ctb,unit,v.show_x-(cols/2)+1,v.show_y+4,v.type,v.result,v.is_win)
|
||||
}else if(v.show_x<=3*(cols/2)){
|
||||
showPath(ctb,unit,v.show_x-cols+2,v.show_y+8,v.type,v.result,v.is_win)
|
||||
}
|
||||
})
|
||||
}else{
|
||||
if(data){
|
||||
$.each(data,function(i,v){
|
||||
if(v.show_x<=(cols/2-1)){
|
||||
showPath(ctb,unit,v.show_x,v.show_y,v.type,v.result,v.is_win)
|
||||
}else if(v.show_x<=cols-2){
|
||||
showPath(ctb,unit,v.show_x-(cols/2)+1,v.show_y+4,v.type,v.result,v.is_win)
|
||||
}else if(v.show_x<=3*(cols/2)){
|
||||
showPath(ctb,unit,v.show_x-cols+2,v.show_y+8,v.type,v.result,v.is_win)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
function title(ctb,unit,x,y,type){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
if(type==1){
|
||||
fonts= '庄家';
|
||||
var font_color = '#b20a00';
|
||||
}else if(type==2){
|
||||
fonts= '闲一';
|
||||
var font_color = '#0543bc';
|
||||
}else if(type==3){
|
||||
fonts= '闲二';
|
||||
var font_color = '#0543bc';
|
||||
}else if(type==4){
|
||||
fonts= '闲三';
|
||||
var font_color = '#0543bc';
|
||||
}
|
||||
if(type == 1){
|
||||
var color = '#ffad97';
|
||||
}else{
|
||||
var color = '#73d8f7';
|
||||
}
|
||||
//背景色
|
||||
ctb.fillStyle = color ; // 颜色
|
||||
ctb.fillRect(x,(y-1)*unit,unit*2-1,unit-0.5);
|
||||
ctb.fill();
|
||||
//文字
|
||||
ctb.font=unit*0.5+"px Arial";//字的大小
|
||||
ctb.fillStyle = font_color ; // 颜色
|
||||
ctb.textAlign = 'center'; //字的位置
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,radius+unit*(x/2),radius+unit*(y-1));
|
||||
ctb.stroke();
|
||||
}
|
||||
function showPath(ctb,unit,x,y,type,result,is_win){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
if(type==1){
|
||||
var font_color = '#b20a00';
|
||||
}else{
|
||||
var font_color = '#1e14d3';
|
||||
}
|
||||
if(result == 0){
|
||||
var fonts = '无牛';
|
||||
}else if(result == 1){
|
||||
var fonts = '牛1';
|
||||
}else if(result == 2){
|
||||
var fonts = '牛2';
|
||||
}else if(result == 3){
|
||||
var fonts = '牛3';
|
||||
}else if(result == 4){
|
||||
var fonts = '牛4';
|
||||
}else if(result == 5){
|
||||
var fonts = '牛5';
|
||||
}else if(result == 6){
|
||||
var fonts = '牛6';
|
||||
}else if(result == 7){
|
||||
var fonts = '牛7';
|
||||
}else if(result == 8){
|
||||
var fonts = '牛8';
|
||||
}else if(result == 9){
|
||||
var fonts = '牛9';
|
||||
}else if(result == 10){
|
||||
var fonts = '牛牛';
|
||||
}else if(result == 11){
|
||||
var fonts = '五公';
|
||||
}
|
||||
//背景色
|
||||
if(is_win == 1){
|
||||
if(type == 1){
|
||||
ctb.fillStyle = '#b20a00' ; // 颜色
|
||||
}else{
|
||||
ctb.fillStyle = '#1e14d3' ; // 颜色
|
||||
}
|
||||
ctb.fillRect(unit*x*2,unit*(y-0.25),unit*2,unit*0.25);
|
||||
ctb.fill();
|
||||
win(ctb,unit,x,y);
|
||||
}
|
||||
//文字
|
||||
ctb.font=unit*0.45+"px Arial";//字的大小
|
||||
ctb.fillStyle = font_color ; // 颜色
|
||||
ctb.textAlign = 'center'; //字的位置
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,2*x*unit+unit,radius+unit*(y-1));
|
||||
ctb.stroke();
|
||||
}
|
||||
function win(ctb,unit,x,y){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
fonts = 'WIN';
|
||||
ctb.font=unit*0.25+"px Arial";//字的大小
|
||||
ctb.fillStyle = '#fff' ; // 颜色
|
||||
ctb.textAlign = 'center'; //字的位置
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,2*x*unit+unit,unit*(y-0.11));
|
||||
ctb.stroke();
|
||||
}
|
||||
// 大路
|
||||
function BigPath(ctb,unit,x,y,type,slash,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
if(type==1){
|
||||
var color='#b20a00',
|
||||
fonts= lang.banker;
|
||||
ctb.strokeStyle = "#ff4a68";
|
||||
}else if(type==2){
|
||||
var color='#0543bc',
|
||||
fonts= lang.player;
|
||||
ctb.strokeStyle = "#7e7df6";
|
||||
}else if(type==3){
|
||||
var color='#1d8701',
|
||||
fonts= lang.tie;
|
||||
ctb.strokeStyle = "#71df57";
|
||||
}
|
||||
ctb.arc(radius+unit*(x-1), radius+unit*(y-1), unit*0.4, 0, Math.PI * 2);
|
||||
ctb.fillStyle=color;
|
||||
ctb.fill();
|
||||
ctb.font=unit*0.45+"px Arial";
|
||||
ctb.fillStyle ="#fff" ; // 颜色
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,radius+unit*(x-1),radius+unit*(y-1));
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function countDown(time) {
|
||||
var table_id = $('#table_id').val();
|
||||
$(".countdown .num").html(time);
|
||||
$(".countdown").fadeIn();
|
||||
if(time == 10){
|
||||
mp3List = ['time_tip_10.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
if(time < 9 && time > 0){
|
||||
mp3List = ['time.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
if(time<=0){
|
||||
mp3List = ['stop_2.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
$(".countdown").fadeOut();
|
||||
webSocket.send('{"connect":"space","mode":"endBet","number_tab_id":"'+parseInt(number_tab_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function notice(){
|
||||
if (roll == -LiWidth) {
|
||||
roll = 0;
|
||||
}
|
||||
roll -= 1;
|
||||
$(".notice .scroll").css({
|
||||
left: roll
|
||||
})
|
||||
}
|
||||
function getTime() {
|
||||
var today = new Date();
|
||||
var h = today.getHours();
|
||||
var minute = today.getMinutes()
|
||||
var s = today.getSeconds();
|
||||
if (h < 10) {
|
||||
h = "0" + h;
|
||||
}
|
||||
if (minute < 10) {
|
||||
minute = "0" + minute;
|
||||
}
|
||||
if (s < 10) {
|
||||
s = "0" + s;
|
||||
}
|
||||
var strDate = (" " + today.getFullYear() + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + h + ":" + minute + ":" + s);
|
||||
var n_day = today.getDay();
|
||||
switch (n_day) {
|
||||
case 0:
|
||||
var week = " 星期日 "
|
||||
break;
|
||||
case 1:
|
||||
var week = " 星期一 "
|
||||
break;
|
||||
case 2:
|
||||
var week = " 星期二 "
|
||||
break;
|
||||
case 3:
|
||||
var week = " 星期三 "
|
||||
break;
|
||||
case 4:
|
||||
var week = " 星期四 "
|
||||
break;
|
||||
case 5:
|
||||
var week = " 星期五 "
|
||||
break;
|
||||
case 6:
|
||||
var week = " 星期六 "
|
||||
break;
|
||||
case 7:
|
||||
var week = " 星期日 "
|
||||
break;
|
||||
}
|
||||
$('.date').find('p').html(strDate);
|
||||
$('.date').find('span').html(week);
|
||||
}
|
||||
@@ -0,0 +1,796 @@
|
||||
var smallH=0,smallW=0,bigH=0,bigW=0;
|
||||
var unitsmall=0,unitbig=0,colsmall=0,colbig=0;
|
||||
var roll=0;LiWidth=0;
|
||||
var BetStatus;
|
||||
var askData = false;
|
||||
$(function(){
|
||||
$(window).resize(function(){
|
||||
waybillFunc()
|
||||
})
|
||||
waybillFunc()
|
||||
getTime();
|
||||
// 滚动广告
|
||||
$(".notice ul li").each(function(){
|
||||
LiWidth+=$(this).innerWidth()
|
||||
});
|
||||
$(".notice ul").append($(".notice ul").html())
|
||||
var timer = setInterval(notice, 20);
|
||||
$(".notice").hover(function() {
|
||||
clearInterval(timer);
|
||||
},function() {
|
||||
timer = setInterval(notice, 20);
|
||||
})
|
||||
// 日期
|
||||
setInterval(function(){
|
||||
getTime();
|
||||
}, 1000);
|
||||
// 侧栏控台
|
||||
$(".control-box").hover(function(){
|
||||
$(this).stop().animate({right:"0"})
|
||||
},function(){
|
||||
$(this).stop().animate({right:"-410px"})
|
||||
})
|
||||
/* 键盘操作 */
|
||||
$(document).keydown(function (e){
|
||||
if(e.keyCode == 111){
|
||||
startBet();
|
||||
}
|
||||
if(e.keyCode == 96){
|
||||
endBet();
|
||||
}
|
||||
if(e.keyCode == 13){
|
||||
opening();
|
||||
}
|
||||
})
|
||||
$("#confirm_update_ludan").click(function (){
|
||||
retreated();
|
||||
});
|
||||
$("#cancel_update_ludan").click(function (){
|
||||
$('#update_ludan').hide();
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
function close_print(){
|
||||
$(".iframe-box").hide();
|
||||
}
|
||||
var showPng = function (opening){
|
||||
if(opening == 1) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/banker.png');
|
||||
mp3List = ['banker_win.mp3'];
|
||||
}
|
||||
if(opening == 2) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/player.png');
|
||||
mp3List = ['player_win.mp3'];
|
||||
}
|
||||
if(opening == 3) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/tie.png');
|
||||
mp3List = ['tie.mp3'];
|
||||
}
|
||||
audioMp3(mp3List).Play();
|
||||
$('#openingElement').show().delay(3000).hide(300);
|
||||
}
|
||||
|
||||
var showPng_noVoice = function (opening){
|
||||
var status = $('#number_tab_status').val();
|
||||
if(status == '2'){
|
||||
if(opening == 1) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/banker.png');
|
||||
}
|
||||
if(opening == 2) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/player.png');
|
||||
}
|
||||
if(opening == 3) {
|
||||
$('#openingPng').attr('src','/static/console/new_img/tie.png');
|
||||
}
|
||||
$('#openingElement').show();
|
||||
}else{
|
||||
layer.msg('开结果失败,请确认该铺是处于停止下注的状态');
|
||||
}
|
||||
}
|
||||
function flop_position(data){
|
||||
pokercard=data.round.card;
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$('.begincard .position-card .card').css("opacity",1);
|
||||
$('.begincard .position-card .card').find(".face").css("background-image","url("+pokersrc+")");
|
||||
}
|
||||
function flop_card(data){
|
||||
order_num = data.round.order_num;
|
||||
card_cow = order_num.substring(0,1);
|
||||
card_list = order_num.substring(1,2) - 1;
|
||||
if(card_cow == 1){
|
||||
box_name = 'player-1-card';
|
||||
if(data.round.result){
|
||||
$('.player_1_result').html(data.round.result);
|
||||
}
|
||||
}else if(card_cow == 2){
|
||||
box_name = 'player-2-card';
|
||||
if(data.round.result){
|
||||
$('.player_2_result').html(data.round.result);
|
||||
}
|
||||
}else if(card_cow == 3){
|
||||
box_name = 'player-3-card';
|
||||
if(data.round.result){
|
||||
$('.player_3_result').html(data.round.result);
|
||||
}
|
||||
}else if(card_cow == 4){
|
||||
box_name = 'banker-card';
|
||||
if(data.round.result){
|
||||
$('.banker_result').html(data.round.result);
|
||||
}
|
||||
}
|
||||
if(40<order_num){
|
||||
$('.box1').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
if(10<order_num && order_num<20){
|
||||
$('.box2').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
if(20<order_num && order_num<30){
|
||||
$('.box3').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
if(30<order_num && order_num<40){
|
||||
$('.box4').css("background-color","rgba(226, 212, 71, 0.5)");
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
}
|
||||
pokercard=data.round.card;
|
||||
$poker=$('.begincard '+'.'+ box_name+' .card');
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$poker.eq(card_list).find(".face").css("background-image","url("+pokersrc+")")
|
||||
$('.begincard '+'.'+ box_name).find(".card").eq(card_list).css('opacity',1);
|
||||
}
|
||||
|
||||
var audio=$("#audio").get(0);
|
||||
var mp3List;
|
||||
var num=0;
|
||||
|
||||
|
||||
function audioMp3(mp3List){
|
||||
var mp3=new Object();
|
||||
mp3.mp3List=mp3List;
|
||||
mp3.url="/static/console/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;
|
||||
}
|
||||
audio.addEventListener("ended", nextAudio);
|
||||
function nextAudio(){
|
||||
num+=1
|
||||
if(num<mp3List.length){
|
||||
audio.src="/static/console/mp3/"+mp3List[num];
|
||||
audio.play();
|
||||
}else{
|
||||
audio.pause();
|
||||
audio.currentTime = 0.0;
|
||||
num=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// WebSocket 数据交互
|
||||
var number_tab_id;
|
||||
if(window.WebSocket){
|
||||
var webSocket = new WebSocket(websocketUrl);
|
||||
webSocket.onerror = function(event){
|
||||
layer.msg('您已断开链接,请返回重新进入。');
|
||||
}
|
||||
webSocket.onopen = function (event) {
|
||||
var userid = $('#userid').val();
|
||||
var account = $('#account').val();
|
||||
var online_token = $('#online_token').val();
|
||||
var table_id = $('#table_id').val();
|
||||
if(parseInt(userid) > 0 && account != '' && online_token != ''){
|
||||
webSocket.send('{"connect":"space","mode":"onlineLogin","account":"'+account+'","userid":"'+userid+'","table_id":"'+table_id+'","online_token":"'+online_token+'"}');
|
||||
}else{
|
||||
webSocket.close();
|
||||
layer.msg('您已断开链接,请返回重新进入。');
|
||||
}
|
||||
};
|
||||
// 桌子状态
|
||||
var setBetStatus = function (BetStatus){
|
||||
if(BetStatus.type == 1){
|
||||
$('#betstatus').html(BetStatus.msg);
|
||||
}else if(BetStatus.type == 2){
|
||||
$('#number_tab_status').val(BetStatus.betStatus);
|
||||
$('#betstatus').html(BetStatus.betMsg);
|
||||
$('#opening_result').html('');
|
||||
}
|
||||
};
|
||||
// 获取桌子数据
|
||||
var setNumberInfo = function (round){
|
||||
number_tab_id=round.number_tab_id
|
||||
$('#boot_num').val(round.boot_num);//靴数
|
||||
$('#number').val(round.number_tab_number);// 局数
|
||||
$('#number_tab_dt_id').val(round.number_tab_id);
|
||||
$('#boot_id').val(round.boot_id);
|
||||
getResultToatl(round.tid,round.boot_id);
|
||||
};
|
||||
// 获取 庄、闲、和、对 开局次数
|
||||
var getResultToatl = function (TableId,BootId){
|
||||
var query = new Object();
|
||||
query.table_id = TableId;
|
||||
query.boot_id = BootId;
|
||||
$.ajax({
|
||||
url:'/nn/get_result_total',
|
||||
data:query,
|
||||
dataType:"json",
|
||||
type:"POST",
|
||||
async:false,
|
||||
success:function(data){
|
||||
if(data.code == 1){
|
||||
var resultToatl = data.data;
|
||||
$('#result_total_player').html(resultToatl.player);
|
||||
$('#result_total_banker').html(resultToatl.banker);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
webSocket.onmessage = function (event) {
|
||||
var data = $.parseJSON(event.data);
|
||||
var table_id = parseInt($('#table_id').val());
|
||||
if(data.table_id == table_id){
|
||||
if(data.sendMode == 'onlineLogin'){
|
||||
if(data.status === true){
|
||||
//登录成功
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
waybillFunc();
|
||||
console.log(data);
|
||||
if(data.round.bet_status == 2){
|
||||
$(".begincard").fadeIn(function(){
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"1"});
|
||||
});
|
||||
card_number_info = data.card_info;
|
||||
if(card_number_info.length > 0){
|
||||
for(var i=0;i<card_number_info.length;i++){
|
||||
if(card_number_info[i]['order_num'] == 0){
|
||||
pokercard=card_number_info[i]['card'];
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$('.begincard .position-card .card').css("opacity",1);
|
||||
$('.begincard .position-card .card').find(".face").css("background-image","url("+pokersrc+")");
|
||||
}else{
|
||||
pokercard=card_number_info[i]['card'];
|
||||
order_num = card_number_info[i]['order_num'];
|
||||
card_cow = card_number_info[i]['order_num'].substring(0,1);
|
||||
card_list = card_number_info[i]['order_num'].substring(1,2) - 1;
|
||||
if(card_cow == 1){
|
||||
box_name = 'player-1-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.player_1_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}else if(card_cow == 2){
|
||||
box_name = 'player-2-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.player_2_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}else if(card_cow == 3){
|
||||
box_name = 'player-3-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.player_3_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}else if(card_cow == 4){
|
||||
box_name = 'banker-card';
|
||||
if(card_number_info[i]['result']){
|
||||
$('.banker_result').html(card_number_info[i]['result']);
|
||||
}
|
||||
}
|
||||
$poker=$('.begincard '+'.'+ box_name+' .card');
|
||||
pokersrc="/static/poker/"+pokercard+".png";
|
||||
$poker.eq(card_list).find(".face").css("background-image","url("+pokersrc+")")
|
||||
$('.begincard '+'.'+ box_name).find(".card").eq(card_list).css('opacity',1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
webSocket.close();
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'sendScanResult'){
|
||||
if(data.round.position == 0){
|
||||
flop_position(data);
|
||||
}else{
|
||||
flop_card(data);
|
||||
}
|
||||
}else if(data.sendMode == 'resetBoot' || data.sendMode == 'changeBoot'){
|
||||
if(data.status === true){
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
waybillFunc();
|
||||
hiddenForecast(); //隐藏自动问路
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'startBet'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'startBetCountDown'){
|
||||
if(data.status === true && data.countDown >= 0){
|
||||
countDown(data.countDown);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'endBet'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
$(".begincard").fadeIn(function(){
|
||||
$(".list .card").css("opacity","0");
|
||||
$(".banker_result").html('');
|
||||
$(".player_1_result").html('');
|
||||
$(".player_2_result").html('');
|
||||
$(".player_3_result").html('');
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"1"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"1"});
|
||||
});
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'toBet'){
|
||||
}else if(data.sendMode == 'inCheckout'){
|
||||
if(data.status === true){
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'openingTc'){
|
||||
if(data.status === true){
|
||||
setNumberInfo(data.round);
|
||||
setBetStatus(data.round.number_tab_status);
|
||||
waybillFunc();
|
||||
$('.box1').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box2').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box3').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
$('.box4').css("background-color","rgba(0, 0, 0, 0.5)");
|
||||
setTimeout(function(){
|
||||
$(".begincard").fadeOut(function(){
|
||||
$(".begincard .box").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box1").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box2").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box3").animate({"top":"100%","opacity":"0"});
|
||||
$(".begincard .box4").animate({"top":"100%","opacity":"0"});
|
||||
});
|
||||
},1000);
|
||||
}else{
|
||||
layer.msg(lang[data.msg]);
|
||||
}
|
||||
}else if(data.sendMode == 'retreated'){
|
||||
if(data.status === true){
|
||||
$("#update_ludan").hide();
|
||||
waybillFunc();
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
}else if(data.sendMode == 'RepeatedEntry'){
|
||||
webSocket.close();
|
||||
layer.msg(lang[data.msg]);
|
||||
setTimeout(function (){
|
||||
window.location.href='/login/logout';
|
||||
},2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
var inCheckout = function(){
|
||||
layer.confirm('是否需要将桌子的状态设置为"洗牌中"?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"inCheckout","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
var resetBoot = function(){
|
||||
layer.confirm('是否需要进行日结算?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"resetBoot","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var changeBoot = function(){
|
||||
layer.confirm('是否需要进行换靴?',{btn: ['确认','取消']}, function(index){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"changeBoot","table_id":"'+parseInt(table_id)+'"}');
|
||||
layer.close(index);
|
||||
});
|
||||
};
|
||||
var startBet = function(){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"startBet","number_tab_id":"'+parseInt(number_tab_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
var betStatus=$("#number_tab_status").val();
|
||||
if(betStatus==0){
|
||||
mp3List = ['start.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
};
|
||||
var endBet = function (){
|
||||
var table_id = $('#table_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"endBet","number_tab_id":"'+parseInt(number_tab_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
var betStatus=$("#number_tab_status").val();
|
||||
if(betStatus==1){
|
||||
$(".countdown .num").html($("#wait_time").val())
|
||||
$(".countdown").fadeOut();
|
||||
mp3List = ['stop_2.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
}
|
||||
};
|
||||
var opening = function(){
|
||||
var table_id = $('#table_id').val();
|
||||
$('.control-box .btn-box2 span').removeClass('on');
|
||||
var number_tab_dt_id = $('#number_tab_dt_id').val();
|
||||
webSocket.send('{"connect":"space","mode":"openingTc","number_tab_id":"'+parseInt(number_tab_dt_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
};
|
||||
//回档方法
|
||||
var retreated = function(){
|
||||
var game_id = parseInt($('#game_id').val());
|
||||
var table_id = parseInt($('#table_id').val());
|
||||
var boot_id = parseInt($('#boot_id').val());
|
||||
var number_tab_id = parseInt($('#number_tab_dt_id').val());
|
||||
var update_ludan_result = $('#update_ludan_result').val();
|
||||
if(update_ludan_result == ''){
|
||||
layer.msg('请选择要修改的结果');
|
||||
return false;
|
||||
}
|
||||
webSocket.send('{"connect":"space","mode":"retreated","number_tab_id":"'+number_tab_id+'","boot_id":"'+boot_id+'","table_id":"'+table_id+'","game_id":"'+game_id+'","result":"'+update_ludan_result+'"}');
|
||||
}
|
||||
var confirmResult = function(id,result){
|
||||
$('.control-box .btn-box2 span').eq(0).removeClass('on');
|
||||
$('.control-box .btn-box2 span').eq(1).removeClass('on');
|
||||
$('.control-box .btn-box2 span').eq(2).removeClass('on');
|
||||
var is_on=$("#"+id).hasClass("on");
|
||||
if(is_on){
|
||||
$("#"+id).removeClass("on")
|
||||
}else{
|
||||
$("#"+id).addClass("on")
|
||||
}
|
||||
showPng_noVoice(result);
|
||||
};
|
||||
}else{
|
||||
layer.msg('您的浏览器不支持WebSocket');
|
||||
}
|
||||
|
||||
// 请求所有路单数据,执行画布刷新
|
||||
function waybillFunc(){
|
||||
var data = new Object;
|
||||
data.boot_id = $('#boot_id').val();
|
||||
data.game_id = $('#game_id').val();
|
||||
$.ajax({
|
||||
url:"/tc/waybill",
|
||||
type:"POST",
|
||||
dataType:"JSON",
|
||||
data:data,
|
||||
success:function(data){
|
||||
// 将数据结果存session
|
||||
ludan = data;
|
||||
// 执行画布刷新
|
||||
requestData(ludan.waybill);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 换靴时隐藏自动问路
|
||||
var hiddenForecast = function(){
|
||||
$('#bankerask').find('.circle').css('opacity',0);
|
||||
$('#bankerask').find('.round').css('opacity',0);
|
||||
$('#bankerask').find('.bar').css('opacity',0);
|
||||
$('#playerask').find('.circle').css('opacity',0);
|
||||
$('#playerask').find('.round').css('opacity',0);
|
||||
$('#playerask').find('.bar').css('opacity',0);
|
||||
}
|
||||
function requestData(data){
|
||||
smallH=$(".canvas-box.small").height();
|
||||
smallW=$(".canvas-box.small").width();
|
||||
// 计算单位
|
||||
unitsmall=smallH/12;
|
||||
// 计算列个数
|
||||
colsmall=Math.floor(smallW/unitsmall);
|
||||
if(colsmall%2!=0){
|
||||
colsmall=colsmall-1
|
||||
}
|
||||
CanvasTable("#canvas1",unitsmall,12,colsmall,data);
|
||||
}
|
||||
|
||||
function CanvasTable(Id,unit,rows,cols,data){
|
||||
var width=unit*cols,
|
||||
height=unit*rows;
|
||||
$(Id).attr("width",width)
|
||||
$(Id).attr("height",height)
|
||||
$(Id).css("height",height)
|
||||
var canvasId=$(Id);
|
||||
var ctb=canvasId[0].getContext('2d');
|
||||
ctb.lineWidth = 1;//线条宽度
|
||||
ctb.strokeStyle = "#919191";//线条颜色
|
||||
ctb.beginPath();
|
||||
ctb.moveTo(0, 0.5);
|
||||
ctb.lineTo(width, 0.5);
|
||||
for (var i = 0; i <= rows; i++) {
|
||||
ctb.moveTo(0, unit*i);
|
||||
ctb.lineTo(width, unit*i);
|
||||
}
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
ctb.beginPath();
|
||||
ctb.moveTo(0.5, 0);
|
||||
ctb.lineTo(0.5, height);
|
||||
for (var j = 1; j <= cols; j++) {
|
||||
ctb.moveTo(unit*j*2,0);
|
||||
ctb.lineTo(unit*j*2,height);
|
||||
}
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 1.5;//线条宽度
|
||||
ctb.strokeStyle = "#000";//线条颜色
|
||||
ctb.moveTo(0, unit*4);
|
||||
ctb.lineTo(width, unit*4);
|
||||
ctb.moveTo(0, unit*8);
|
||||
ctb.lineTo(width, unit*8);
|
||||
ctb.closePath()
|
||||
ctb.stroke();
|
||||
title(ctb,unit,1,1,1);
|
||||
title(ctb,unit,1,2,2);
|
||||
title(ctb,unit,1,3,3);
|
||||
title(ctb,unit,1,4,4);
|
||||
title(ctb,unit,1,5,1);
|
||||
title(ctb,unit,1,6,2);
|
||||
title(ctb,unit,1,7,3);
|
||||
title(ctb,unit,1,8,4);
|
||||
title(ctb,unit,1,9,1);
|
||||
title(ctb,unit,1,10,2);
|
||||
title(ctb,unit,1,11,3);
|
||||
title(ctb,unit,1,12,4);
|
||||
if(data){
|
||||
$.each(data,function(i,v){
|
||||
if(v.show_x<=(cols/2-1)){
|
||||
showPath(ctb,unit,v.show_x,v.show_y,v.type,v.result,v.is_win)
|
||||
}else if(v.show_x<=cols-1){
|
||||
showPath(ctb,unit,v.show_x-(cols/2)+1,v.show_y+4,v.type,v.result,v.is_win)
|
||||
}else if(v.show_x<=3*(cols/2)){
|
||||
showPath(ctb,unit,v.show_x-cols+1,v.show_y+8,v.type,v.result,v.is_win)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
function title(ctb,unit,x,y,type){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
if(type==1){
|
||||
fonts= '庄家';
|
||||
var font_color = '#b20a00';
|
||||
}else if(type==2){
|
||||
fonts= '闲一';
|
||||
var font_color = '#0543bc';
|
||||
}else if(type==3){
|
||||
fonts= '闲二';
|
||||
var font_color = '#0543bc';
|
||||
}else if(type==4){
|
||||
fonts= '闲三';
|
||||
var font_color = '#0543bc';
|
||||
}
|
||||
if(type == 1){
|
||||
var color = '#ffad97';
|
||||
}else{
|
||||
var color = '#73d8f7';
|
||||
}
|
||||
//背景色
|
||||
ctb.fillStyle = color ; // 颜色
|
||||
ctb.fillRect(x,(y-1)*unit,unit*2-1,unit-0.5);
|
||||
ctb.fill();
|
||||
//文字
|
||||
ctb.font=unit*0.5+"px Arial";//字的大小
|
||||
ctb.fillStyle = font_color ; // 颜色
|
||||
ctb.textAlign = 'center'; //字的位置
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,radius+unit*(x/2),radius+unit*(y-1));
|
||||
ctb.stroke();
|
||||
}
|
||||
function showPath(ctb,unit,x,y,type,result,is_win){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
if(type==1){
|
||||
var font_color = '#b20a00';
|
||||
}else{
|
||||
var font_color = '#1e14d3';
|
||||
}
|
||||
if(result == 1){
|
||||
var fonts = '牛1';
|
||||
}else if(result == 2){
|
||||
var fonts = '牛2';
|
||||
}else if(result == 3){
|
||||
var fonts = '牛3';
|
||||
}else if(result == 4){
|
||||
var fonts = '牛4';
|
||||
}else if(result == 5){
|
||||
var fonts = '牛5';
|
||||
}else if(result == 6){
|
||||
var fonts = '牛6';
|
||||
}else if(result == 7){
|
||||
var fonts = '牛7';
|
||||
}else if(result == 8){
|
||||
var fonts = '牛8';
|
||||
}else if(result == 9){
|
||||
var fonts = '牛9';
|
||||
}else if(result == 10){
|
||||
var fonts = '牛牛';
|
||||
}else if(result == 11){
|
||||
var fonts = '豹子';
|
||||
}else if(result == 12){
|
||||
var fonts = '同花顺';
|
||||
}else if(result == 13){
|
||||
var fonts = '皇家同花顺';
|
||||
}
|
||||
//背景色
|
||||
if(is_win == 1){
|
||||
if(type == 1){
|
||||
ctb.fillStyle = '#b20a00' ; // 颜色
|
||||
}else{
|
||||
ctb.fillStyle = '#1e14d3' ; // 颜色
|
||||
}
|
||||
ctb.fillRect(unit*x*2,unit*(y-0.25),unit*2,unit*0.25);
|
||||
ctb.fill();
|
||||
win(ctb,unit,x,y);
|
||||
}
|
||||
//文字
|
||||
ctb.font=unit*0.4+"px Arial";//字的大小
|
||||
ctb.fillStyle = font_color ; // 颜色
|
||||
ctb.textAlign = 'center'; //字的位置
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,2*x*unit+unit,radius+unit*(y-1));
|
||||
ctb.stroke();
|
||||
}
|
||||
function win(ctb,unit,x,y){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
fonts = 'WIN';
|
||||
ctb.font=unit*0.25+"px Arial";//字的大小
|
||||
ctb.fillStyle = '#fff' ; // 颜色
|
||||
ctb.textAlign = 'center'; //字的位置
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,2*x*unit+unit,unit*(y-0.11));
|
||||
ctb.stroke();
|
||||
}
|
||||
// 大路
|
||||
function BigPath(ctb,unit,x,y,type,slash,corners){
|
||||
ctb.beginPath();
|
||||
ctb.lineWidth = 0.5;
|
||||
ctb.strokeStyle = "#000";
|
||||
var radius=unit/2||0;
|
||||
if(type==1){
|
||||
var color='#b20a00',
|
||||
fonts= lang.banker;
|
||||
ctb.strokeStyle = "#ff4a68";
|
||||
}else if(type==2){
|
||||
var color='#0543bc',
|
||||
fonts= lang.player;
|
||||
ctb.strokeStyle = "#7e7df6";
|
||||
}else if(type==3){
|
||||
var color='#1d8701',
|
||||
fonts= lang.tie;
|
||||
ctb.strokeStyle = "#71df57";
|
||||
}
|
||||
ctb.arc(radius+unit*(x-1), radius+unit*(y-1), unit*0.4, 0, Math.PI * 2);
|
||||
ctb.fillStyle=color;
|
||||
ctb.fill();
|
||||
ctb.font=unit*0.45+"px Arial";
|
||||
ctb.fillStyle ="#fff" ; // 颜色
|
||||
ctb.textAlign = 'center';
|
||||
ctb.textBaseline = 'middle';
|
||||
ctb.fillText(fonts,radius+unit*(x-1),radius+unit*(y-1));
|
||||
ctb.stroke();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function countDown(time) {
|
||||
var table_id = $('#table_id').val();
|
||||
$(".countdown .num").html(time);
|
||||
$(".countdown").fadeIn();
|
||||
if(time<=0){
|
||||
mp3List = ['stop_2.mp3'];
|
||||
audioMp3(mp3List).Play();
|
||||
$(".countdown").fadeOut();
|
||||
webSocket.send('{"connect":"space","mode":"endBet","number_tab_id":"'+parseInt(number_tab_id)+'","table_id":"'+parseInt(table_id)+'"}');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function notice(){
|
||||
if (roll == -LiWidth) {
|
||||
roll = 0;
|
||||
}
|
||||
roll -= 1;
|
||||
$(".notice .scroll").css({
|
||||
left: roll
|
||||
})
|
||||
}
|
||||
function getTime() {
|
||||
var today = new Date();
|
||||
var h = today.getHours();
|
||||
var minute = today.getMinutes()
|
||||
var s = today.getSeconds();
|
||||
if (h < 10) {
|
||||
h = "0" + h;
|
||||
}
|
||||
if (minute < 10) {
|
||||
minute = "0" + minute;
|
||||
}
|
||||
if (s < 10) {
|
||||
s = "0" + s;
|
||||
}
|
||||
var strDate = (" " + today.getFullYear() + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日" + h + ":" + minute + ":" + s);
|
||||
var n_day = today.getDay();
|
||||
switch (n_day) {
|
||||
case 0:
|
||||
var week = " 星期日 "
|
||||
break;
|
||||
case 1:
|
||||
var week = " 星期一 "
|
||||
break;
|
||||
case 2:
|
||||
var week = " 星期二 "
|
||||
break;
|
||||
case 3:
|
||||
var week = " 星期三 "
|
||||
break;
|
||||
case 4:
|
||||
var week = " 星期四 "
|
||||
break;
|
||||
case 5:
|
||||
var week = " 星期五 "
|
||||
break;
|
||||
case 6:
|
||||
var week = " 星期六 "
|
||||
break;
|
||||
case 7:
|
||||
var week = " 星期日 "
|
||||
break;
|
||||
}
|
||||
$('.date').find('p').html(strDate);
|
||||
$('.date').find('span').html(week);
|
||||
}
|
||||
Executable
+1508
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,365 @@
|
||||
// MIT License:
|
||||
//
|
||||
// Copyright (c) 2010-2012, Joe Walnes
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* This behaves like a WebSocket in every way, except if it fails to connect,
|
||||
* or it gets disconnected, it will repeatedly poll until it successfully connects
|
||||
* again.
|
||||
*
|
||||
* It is API compatible, so when you have:
|
||||
* ws = new WebSocket('ws://....');
|
||||
* you can replace with:
|
||||
* ws = new ReconnectingWebSocket('ws://....');
|
||||
*
|
||||
* The event stream will typically look like:
|
||||
* onconnecting
|
||||
* onopen
|
||||
* onmessage
|
||||
* onmessage
|
||||
* onclose // lost connection
|
||||
* onconnecting
|
||||
* onopen // sometime later...
|
||||
* onmessage
|
||||
* onmessage
|
||||
* etc...
|
||||
*
|
||||
* It is API compatible with the standard WebSocket API, apart from the following members:
|
||||
*
|
||||
* - `bufferedAmount`
|
||||
* - `extensions`
|
||||
* - `binaryType`
|
||||
*
|
||||
* Latest version: https://github.com/joewalnes/reconnecting-websocket/
|
||||
* - Joe Walnes
|
||||
*
|
||||
* Syntax
|
||||
* ======
|
||||
* var socket = new ReconnectingWebSocket(url, protocols, options);
|
||||
*
|
||||
* Parameters
|
||||
* ==========
|
||||
* url - The url you are connecting to.
|
||||
* protocols - Optional string or array of protocols.
|
||||
* options - See below
|
||||
*
|
||||
* Options
|
||||
* =======
|
||||
* Options can either be passed upon instantiation or set after instantiation:
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url);
|
||||
* socket.debug = true;
|
||||
* socket.reconnectInterval = 4000;
|
||||
*
|
||||
* debug
|
||||
* - Whether this instance should log debug messages. Accepts true or false. Default: false.
|
||||
*
|
||||
* automaticOpen
|
||||
* - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
|
||||
*
|
||||
* reconnectInterval
|
||||
* - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
|
||||
*
|
||||
* maxReconnectInterval
|
||||
* - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
|
||||
*
|
||||
* reconnectDecay
|
||||
* - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
|
||||
*
|
||||
* timeoutInterval
|
||||
* - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.
|
||||
*
|
||||
*/
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], factory);
|
||||
} else if (typeof module !== 'undefined' && module.exports){
|
||||
module.exports = factory();
|
||||
} else {
|
||||
global.ReconnectingWebSocket = factory();
|
||||
}
|
||||
})(this, function () {
|
||||
|
||||
if (!('WebSocket' in window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
function ReconnectingWebSocket(url, protocols, options) {
|
||||
|
||||
// Default settings
|
||||
var settings = {
|
||||
|
||||
/** Whether this instance should log debug messages. */
|
||||
debug: false,
|
||||
|
||||
/** Whether or not the websocket should attempt to connect immediately upon instantiation. */
|
||||
automaticOpen: true,
|
||||
|
||||
/** The number of milliseconds to delay before attempting to reconnect. */
|
||||
reconnectInterval: 1000,
|
||||
/** The maximum number of milliseconds to delay a reconnection attempt. */
|
||||
maxReconnectInterval: 30000,
|
||||
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
|
||||
reconnectDecay: 1.5,
|
||||
|
||||
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
|
||||
timeoutInterval: 2000,
|
||||
|
||||
/** The maximum number of reconnection attempts to make. Unlimited if null. */
|
||||
maxReconnectAttempts: null,
|
||||
|
||||
/** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
|
||||
binaryType: 'blob'
|
||||
}
|
||||
if (!options) { options = {}; }
|
||||
|
||||
// Overwrite and define settings with options if they exist.
|
||||
for (var key in settings) {
|
||||
if (typeof options[key] !== 'undefined') {
|
||||
this[key] = options[key];
|
||||
} else {
|
||||
this[key] = settings[key];
|
||||
}
|
||||
}
|
||||
|
||||
// These should be treated as read-only properties
|
||||
|
||||
/** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
|
||||
this.url = url;
|
||||
|
||||
/** The number of attempted reconnects since starting, or the last successful connection. Read only. */
|
||||
this.reconnectAttempts = 0;
|
||||
|
||||
/**
|
||||
* The current state of the connection.
|
||||
* Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
|
||||
* Read only.
|
||||
*/
|
||||
this.readyState = WebSocket.CONNECTING;
|
||||
|
||||
/**
|
||||
* A string indicating the name of the sub-protocol the server selected; this will be one of
|
||||
* the strings specified in the protocols parameter when creating the WebSocket object.
|
||||
* Read only.
|
||||
*/
|
||||
this.protocol = null;
|
||||
|
||||
// Private state variables
|
||||
|
||||
var self = this;
|
||||
var ws;
|
||||
var forcedClose = false;
|
||||
var timedOut = false;
|
||||
var eventTarget = document.createElement('div');
|
||||
|
||||
// Wire up "on*" properties as event handlers
|
||||
|
||||
eventTarget.addEventListener('open', function(event) { self.onopen(event); });
|
||||
eventTarget.addEventListener('close', function(event) { self.onclose(event); });
|
||||
eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });
|
||||
eventTarget.addEventListener('message', function(event) { self.onmessage(event); });
|
||||
eventTarget.addEventListener('error', function(event) { self.onerror(event); });
|
||||
|
||||
// Expose the API required by EventTarget
|
||||
|
||||
this.addEventListener = eventTarget.addEventListener.bind(eventTarget);
|
||||
this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);
|
||||
this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);
|
||||
|
||||
/**
|
||||
* This function generates an event that is compatible with standard
|
||||
* compliant browsers and IE9 - IE11
|
||||
*
|
||||
* This will prevent the error:
|
||||
* Object doesn't support this action
|
||||
*
|
||||
* http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
|
||||
* @param s String The name that the event should use
|
||||
* @param args Object an optional object that the event will use
|
||||
*/
|
||||
function generateEvent(s, args) {
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(s, false, false, args);
|
||||
return evt;
|
||||
};
|
||||
|
||||
this.open = function (reconnectAttempt) {
|
||||
ws = new WebSocket(self.url, protocols || []);
|
||||
ws.binaryType = this.binaryType;
|
||||
|
||||
if (reconnectAttempt) {
|
||||
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
eventTarget.dispatchEvent(generateEvent('connecting'));
|
||||
this.reconnectAttempts = 0;
|
||||
}
|
||||
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);
|
||||
}
|
||||
|
||||
var localWs = ws;
|
||||
var timeout = setTimeout(function() {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);
|
||||
}
|
||||
timedOut = true;
|
||||
localWs.close();
|
||||
timedOut = false;
|
||||
}, self.timeoutInterval);
|
||||
|
||||
ws.onopen = function(event) {
|
||||
clearTimeout(timeout);
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onopen', self.url);
|
||||
}
|
||||
self.protocol = ws.protocol;
|
||||
self.readyState = WebSocket.OPEN;
|
||||
self.reconnectAttempts = 0;
|
||||
var e = generateEvent('open');
|
||||
e.isReconnect = reconnectAttempt;
|
||||
reconnectAttempt = false;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
|
||||
ws.onclose = function(event) {
|
||||
clearTimeout(timeout);
|
||||
ws = null;
|
||||
if (forcedClose) {
|
||||
self.readyState = WebSocket.CLOSED;
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
} else {
|
||||
self.readyState = WebSocket.CONNECTING;
|
||||
var e = generateEvent('connecting');
|
||||
e.code = event.code;
|
||||
e.reason = event.reason;
|
||||
e.wasClean = event.wasClean;
|
||||
eventTarget.dispatchEvent(e);
|
||||
if (!reconnectAttempt && !timedOut) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onclose', self.url);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
}
|
||||
|
||||
var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
|
||||
setTimeout(function() {
|
||||
self.reconnectAttempts++;
|
||||
self.open(true);
|
||||
}, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);
|
||||
}
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);
|
||||
}
|
||||
var e = generateEvent('message');
|
||||
e.data = event.data;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
ws.onerror = function(event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onerror', self.url, event);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('error'));
|
||||
};
|
||||
}
|
||||
|
||||
// Whether or not to create a websocket upon instantiation
|
||||
if (this.automaticOpen == true) {
|
||||
this.open(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits data to the server over the WebSocket connection.
|
||||
*
|
||||
* @param data a text string, ArrayBuffer or Blob to send to the server.
|
||||
*/
|
||||
this.send = function(data) {
|
||||
if (ws) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'send', self.url, data);
|
||||
}
|
||||
return ws.send(data);
|
||||
} else {
|
||||
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the WebSocket connection or connection attempt, if any.
|
||||
* If the connection is already CLOSED, this method does nothing.
|
||||
*/
|
||||
this.close = function(code, reason) {
|
||||
// Default CLOSE_NORMAL code
|
||||
if (typeof code == 'undefined') {
|
||||
code = 1000;
|
||||
}
|
||||
forcedClose = true;
|
||||
if (ws) {
|
||||
ws.close(code, reason);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional public API method to refresh the connection if still open (close, re-open).
|
||||
* For example, if the app suspects bad data / missed heart beats, it can try to refresh.
|
||||
*/
|
||||
this.refresh = function() {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
|
||||
* this indicates that the connection is ready to send and receive data.
|
||||
*/
|
||||
ReconnectingWebSocket.prototype.onopen = function(event) {};
|
||||
/** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
|
||||
ReconnectingWebSocket.prototype.onclose = function(event) {};
|
||||
/** An event listener to be called when a connection begins being attempted. */
|
||||
ReconnectingWebSocket.prototype.onconnecting = function(event) {};
|
||||
/** An event listener to be called when a message is received from the server. */
|
||||
ReconnectingWebSocket.prototype.onmessage = function(event) {};
|
||||
/** An event listener to be called when an error occurs. */
|
||||
ReconnectingWebSocket.prototype.onerror = function(event) {};
|
||||
|
||||
/**
|
||||
* Whether all instances of ReconnectingWebSocket should log debug messages.
|
||||
* Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
|
||||
*/
|
||||
ReconnectingWebSocket.debugAll = false;
|
||||
|
||||
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
|
||||
ReconnectingWebSocket.OPEN = WebSocket.OPEN;
|
||||
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
|
||||
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
|
||||
|
||||
return ReconnectingWebSocket;
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
!function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()}(this,function(){function a(b,c,d){function l(a,b){var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!1,!1,b),c}var e={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i=!1,j=!1,k=document.createElement("div");k.addEventListener("open",function(a){g.onopen(a)}),k.addEventListener("close",function(a){g.onclose(a)}),k.addEventListener("connecting",function(a){g.onconnecting(a)}),k.addEventListener("message",function(a){g.onmessage(a)}),k.addEventListener("error",function(a){g.onerror(a)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b){h=new WebSocket(g.url,c||[]),b||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d=h,e=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=!0,d.close(),j=!1},g.timeoutInterval);h.onopen=function(){clearTimeout(e),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d=l("open");d.isReconnect=b,b=!1,k.dispatchEvent(d)},h.onclose=function(c){if(clearTimeout(e),h=null,i)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d=l("connecting");d.code=c.code,d.reason=c.reason,d.wasClean=c.wasClean,k.dispatchEvent(d),b||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(!0)},e>g.maxReconnectInterval?g.maxReconnectInterval:e)}},h.onmessage=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b.data);var c=l("message");c.data=b.data,k.dispatchEvent(c)},h.onerror=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b),k.dispatchEvent(l("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(b){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b),h.send(b);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a,b){"undefined"==typeof a&&(a=1e3),i=!0,h&&h.close(a,b)},this.refresh=function(){h&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=!1,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a});
|
||||
@@ -0,0 +1,197 @@
|
||||
class WebSocketClass {
|
||||
constructor (wsUrl) {
|
||||
this.successFn = {} // 成功的回掉函数
|
||||
this.wsUrl = wsUrl // 请求的url
|
||||
this.errorCallBackFunArr = [] // 当推送异常时执行的数组
|
||||
this.isConnection = false // 判断是否支持weosocket
|
||||
this.isErrorCallBack = false
|
||||
this.lockReconnect = false // 避免重复连接
|
||||
this.ping = null
|
||||
this.sendObj = {}
|
||||
this.heartCheck()
|
||||
this.createWebSocket()
|
||||
}
|
||||
createWebSocket () {
|
||||
try {
|
||||
this.webSocket = new WebSocket(this.wsUrl)
|
||||
this.initEventHandle()
|
||||
} catch (e) {
|
||||
this.errorCallBackData()
|
||||
this.reconnect(this.wsUrl)
|
||||
}
|
||||
}
|
||||
initEventHandle () {
|
||||
this.webSocket.onclose = () => {
|
||||
this.errorCallBackData()
|
||||
this.reconnect(this.wsUrl)
|
||||
}
|
||||
this.webSocket.onerror = () => {
|
||||
this.errorCallBackData()
|
||||
this.reconnect(this.wsUrl)
|
||||
}
|
||||
this.webSocket.onopen = () => {
|
||||
this.isConnection = true
|
||||
this.isErrorCallBack = false
|
||||
clearInterval(this.ping)
|
||||
this.ping = setInterval(() => {
|
||||
this.send('{"event": "ping"}')
|
||||
}, 10000)
|
||||
// 心跳检测重置
|
||||
this.heartCheck.start()
|
||||
}
|
||||
this.webSocket.onmessage = data => {
|
||||
// 如果获取到消息,心跳检测重置
|
||||
// 拿到任何消息都说明当前连接是正常的
|
||||
this.heartCheck.start()
|
||||
this.decodeData(data)
|
||||
}
|
||||
}
|
||||
send(cmd) {
|
||||
// 只有当 webSocket.readyState 为 OPEN才发送订阅
|
||||
// readyState属性返回实例对象的当前状态,共有四种。
|
||||
// CONNECTING:值为0,表示正在连接。
|
||||
// OPEN:值为1,表示连接成功,可以通信了。
|
||||
// CLOSING:值为2,表示连接正在关闭。
|
||||
// CLOSED:值为3,表示连接已经关闭,或者打开连接失败。
|
||||
if (!cmd) {
|
||||
return
|
||||
}
|
||||
// this.sendObj[cmd] && (delete clearTimeout(this.sendObj[cmd]))
|
||||
if (this.webSocket.readyState === 1) { // 只有当链接打开时才进行订阅
|
||||
this.webSocket.send(cmd)
|
||||
}
|
||||
// else if (this.webSocket.readyState === 0) { // 如果链接处于正在链接中,则进行延时订阅
|
||||
// this.sendObj[cmd] = setTimeout(() => {
|
||||
// this.send(cmd)
|
||||
// }, 50)
|
||||
// }
|
||||
}
|
||||
|
||||
reconnect (url) {
|
||||
if (this.lockReconnect) {
|
||||
return
|
||||
}
|
||||
this.lockReconnect = true
|
||||
// 没连接上会一直重连,设置延迟避免请求过多
|
||||
setTimeout(() => {
|
||||
this.createWebSocket(url)
|
||||
this.lockReconnect = false
|
||||
}, 2000)
|
||||
}
|
||||
errorCallBackData () {
|
||||
this.isConnection = false
|
||||
if (!this.isErrorCallBack && this.errorCallBackFunArr.length) {
|
||||
this.isErrorCallBack = true
|
||||
for (let i = 0, len = this.errorCallBackFunArr.length; i < len; i++) {
|
||||
if ((typeof this.errorCallBackFunArr[i]) === 'function') {
|
||||
this.errorCallBackFunArr[i]()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
decodeData (data) {
|
||||
if (data.data instanceof Blob) {
|
||||
let blob = data.data
|
||||
// js中的blob没有没有直接读出其数据的方法,通过FileReader来读取相关数据
|
||||
let reader = new FileReader()
|
||||
reader.readAsArrayBuffer(blob)
|
||||
// 当读取操作成功完成时调用.
|
||||
reader.onload = (evt) => {
|
||||
if (evt.target.readyState === FileReader.DONE) {
|
||||
let result = new Uint8Array(evt.target.result)
|
||||
// 如果后端进行压缩数据处理(zlib),那么要引入解析zlib的js
|
||||
result = (new window.Zlib.RawInflate(result)).decompress()
|
||||
let strResult = ''
|
||||
let length = result.length
|
||||
for (let i = 0; i < length; i++) {
|
||||
strResult += String.fromCharCode(result[i])
|
||||
}
|
||||
this.callBackData(JSON.parse(strResult))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
let d = JSON.parse(data.data)
|
||||
// 如果后端需要等待,则返回code:10010,过一段时间后重新订阅
|
||||
if (d.code === '10010') {
|
||||
let dt = {}
|
||||
Object.assign(dt, d)
|
||||
delete dt.code
|
||||
delete dt.msg
|
||||
setTimeout(() => {
|
||||
this.send(JSON.stringify(dt))
|
||||
}, 2000)
|
||||
return
|
||||
}
|
||||
this.callBackData(JSON.parse(data.data))
|
||||
}
|
||||
callBackData (data) {
|
||||
if (data instanceof Array) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
this.doCallback(data[i])
|
||||
}
|
||||
} else if (data instanceof Object) {
|
||||
if (data.hasOwnProperty('event') && data.event === 'pong') {
|
||||
return
|
||||
}
|
||||
data.payload && (data.payload = JSON.parse(data.payload))
|
||||
this.doCallback(data)
|
||||
}
|
||||
}
|
||||
doCallback (data) {
|
||||
if (data.event) {
|
||||
let fn = this.successFn[data.event]
|
||||
if (typeof fn === 'function') {
|
||||
fn(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 心跳检测
|
||||
heartCheck () {
|
||||
let that = this
|
||||
this.heartCheck = {
|
||||
timeout: 10000, // 10秒
|
||||
timeoutObj: null,
|
||||
serverTimeoutObj: null,
|
||||
reset: function () {
|
||||
clearTimeout(this.timeoutObj)
|
||||
clearTimeout(this.serverTimeoutObj)
|
||||
},
|
||||
start: function () {
|
||||
this.reset()
|
||||
let self = this
|
||||
this.timeoutObj = setTimeout(function () {
|
||||
// 这里发送一个心跳,后端收到后,返回一个心跳消息
|
||||
// onmessage拿到返回的心跳就说明连接正常
|
||||
that.send('{"event": "ping"}')
|
||||
self.serverTimeoutObj = setTimeout(function () { // 如果超过一定时间还没重置,说明后端主动断开了
|
||||
// 如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
|
||||
that.webSocket.close()
|
||||
}, self.timeout)
|
||||
}, this.timeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function webSocketFn (url) {
|
||||
let wb = new WebSocketClass(url)
|
||||
return {
|
||||
webSocketSend: wb.send.bind(wb),
|
||||
errorCallBackFunArr: wb.errorCallBackFunArr,
|
||||
successFn: wb.successFn,
|
||||
isConnection: function () {
|
||||
return wb.isConnection
|
||||
},
|
||||
getSocketFile (webSocketData, ajaxData) {
|
||||
let socketFail = (isFirst) => {
|
||||
if (this.isConnection()) {
|
||||
webSocketData()
|
||||
} else {
|
||||
ajaxData()
|
||||
setTimeout(socketFail, 2000)
|
||||
}
|
||||
}
|
||||
return socketFail
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user