原生js怎么js调用蓝牙牙发送数据给POS机

原生JS实现网络彩票投注效果
转载 &更新时间:日 12:19:23 & 作者:thomspon
分享一个最近模仿市面彩票系统写个小案例,没有使用任何后台,从投注到开奖再到返奖都是用原生JS实现的。
个人游戏之作,小伙伴们研究下就好
主要功能:
1、可自由选择投注模式、倍数,可点击‘×'删除提交注单。
2、可使用jsonp引用官方彩票开奖数据(实时开奖)。
3、结合后台可实现官彩同样的效果。
实现原理:
单纯使用Js实现,这里主要用数组存放数据,随机生成开奖号码,然后进行判断是否中奖。
下面是完整JS代码:
index.html
&!doctype html&
&html lang="en"&
&meta charset="UTF-8"&
&meta name="Generator" content="EditPlus&"&
&meta name="Author" content=""&
&meta name="Keywords" content=""&
&meta name="Description" content=""&
&title&彩票--德芙&/title&
&link rel="stylesheet" type='text/css' href="css/index.css" /&
&script type="text/javascript" src='js/sports-1.0-js.js'&&/script&
&div id='Game'&
&div class='G_top'&
&div class="G_t_title"&
&h1 class='G_t_t_logo'&TanZhouCaiPiao&/h1&
&p class='text'&付出不亚于任何人的努力!&/p&
&div class='G_t_kaijiang'&
&p class='G_t_k_title'&潭州彩票&span class='G_t_k_t_issue' id='G_t_k_t_issue'&&/span&期&/p&
&div class='G_t_k_num' id='G_t_k_num'&
&span&&/span&
&span&&/span&
&span&&/span&
&span&&/span&
&span&&/span&
&div class="G_t_user"&
&div class='G_t_u_name'&德芙纵享丝滑&/div&
&div class='G_t_u_buy'&
&span class='G_t_u_money' id='G_t_u_money'&1314.51&/span&
&div class='supMoney' id='supMoney'&
&div class='addMoney' id='addMoney'&
&div id="content"&
&div class='c_left'&
&div class='c_l_mode' id='c_l_mode'&
&span class='c_l_m_first'&三星&/span&
&span&定位胆&/span&
&span&大小单双&/span&
&div class="c_l_shuoming"&
&div class="c_l_s_right" id='c_l_s_right'&
&a href="javascript:void(0)"&选号规则
&div class='c_l_s_r_hide'&
&a href="javascript:void(0)"&中奖说明
&div class='c_l_s_r_hide'&
&a href="javascript:void(0)"&投注案例
&div class='c_l_s_r_hide'&
&div class='c_l_number' id='c_l_number'&
&div class='c_l_bottom'&
&div class='c_l_b_function'&
&span class="c_l_b_f_sup"&&/span&
&input type="text" class='c_l_b_f_beishu' id='c_l_b_f_beishu' value='1'/&
&span class="c_l_b_f_add"&&/span&
&select name="sel_mode" id="sel_mode" class="c_l_b_f_sel"&
&option value="1"&元&/option&
&option value="2"&角&/option&
&option value="3"&分&/option&
&p class='c_l_b_f_jiangjin'&奖金:&span id='jiangjin'&1800&/span&&/p&
&p class="c_l_b_f_data"&选择&span class='c_l_b_f_d_num' id='zhushu'&0&/span&注,共 ¥ &span class='c_l_b_f_d_num' id='money'&0&/span&元&/p&
&div class='c_l_b_submit'&
&input type="submit" value='添加号码' id='c_l_b_s_addNum'/&
&input type="button" value='提交注单' id='c_l_b_deledNum' class='c_l_b_deledNum'/&
&textarea id='c_l_data' class='c_l_data' readonly&&/textarea&
&div class='c_right'&
&div class="c_r_rus"&
&div class="c_r_r_qihao"&开奖期号&/div&
&div class="c_r_r_haoma"&开奖号码&/div&
&ul id='c_r_r_box'&
&div class="c_r_list"&
&div class="c_r_l_title"&
&span&玩法&/span&
&span&注数&/span&
&span&倍数&/span&
&span&金额&/span&
&span class='close'&&/span&
&ul id='c_r_l_ul'&
&div class="c_r_touzhu"&
&input type="button" value='立即投注' id='c_r_t_btn' class='c_r_t_btn'/&
&div class='explain'&
&h2&介绍说明&/h2&
&div id='toggleMove' class='arrow'&&/div&
&p&&span&投注方式:&/span&请您选择您的投注号码后‘添加号码'==&‘提交注单'==&‘立即投注'&/p&
&p&&span&三星玩法:&/span&至少需要在‘百位'、‘十位'、‘个位'三个位置中选择一个号码投注,开奖号码后三位与您投注号码一致即中奖&/p&
&p&&span&定位胆玩法:&/span&从任意一个位置选择一个号码即可投注,开奖号码与投注号码的位置、号码相同即中奖&/p&
&p&&span&大小单双玩法:&/span&至少需要在‘百位'、‘十位'中选择一个号码投注,开奖号码与投注号码的位置、形态相同即中奖&/p&
&p&&span&功能:&/span&可自由选择投注模式、倍数,可点击‘&'删除提交注单&/p&
&p&&span&扩展:&/span&可使用jsonp引用官方彩票开奖数据(实时开奖),更多玩法添加请联系我&/p&
&p&&span&Author:&/span&Thompson德芙&/p&
&p&&span&转载:&/span&&/p&
&script type="text/javascript" src='js/index.js'&&/script&
@charset="UTF-8";
html,body,ul,li,a,i,div,img,span,p{margin:0;padding:0;}
ul,li{list-style:}
a{text-decoration:}
i{font-style:}
background:url('../img/bg.jpg');
font-family:'Microsoft yahei';
.clearfix:after {
visibility:
font-size:0;
content:" ";
height:242
right:10%;
background:rgba(0,0,0,0.5);
border-radius:5
font-size:12
padding:10
#toggleMove{
width:100%;
text-align:
transform:scale(1.5);
background: url(../img/arrow.png) no-repeat center 0;
background: url(../img/arrow.png) no-repeat center -40
bottom:-18
.explain h2{
text-align:
.explain p{
.explain p span{
color:#ffff33;
margin-right:10
width:1000
height:500
margin:50px auto 200
#Game .G_top{
width:100%;
height:120
#Game .G_top .G_t_title{
height:120
#Game .G_top .G_t_title .text{
width:100%;
font-size:24
font-weight:
text-shadow: 0 0 1px currentColor,1px 1px 1px rgba(50,93,164,0.8),2px 2px 3px rgba(50,93,164,0.8),3px 3px 4px rgba(50,93,164,0.8),4px 4px 5px rgba(50,93,164,0.8);
#Game .G_top .G_t_title .G_t_t_logo{
width:100%;
height:100
font-size:50
font-weight:
color:rgba(41,76,138,0.8);
letter-spacing:6
text-shadow: 0 0 1px currentColor, 2px 0 1px # 2px 1px rgba(41,76,138,0.8), 2px 1px 1px #px 2px 1px #98c0e8, 2px 2px 1px #px 1px 1px #px 3px 1px rgba(41,76,138,0.8), 3px 2px 1px #px 3px 1px rgba(41,76,138,0.8), 3px 3px 1px #px 2px 1px #px 4px 1px rgba(41,76,138,0.8), 4px 3px 1px #px 4px 1px rgba(41,76,138,0.8), 4px 4px 1px #px 3px 1px #px 5px 1px #98c0e8, 5px 4px 1px #px 5px 1px rgba(41,76,138,0.8), 5px 5px 1px #px 4px 1px #px 6px 1px rgba(41,76,138,0.8), 6px 5px 1px #px 6px 1px rgba(41,76,138,0.8), 6px 6px 1px #px 5px 1px #px 7px 1px #98c0e8, 7px 6px 1px #px 7px 1px #98c0e8, 7px 7px 1px #px 6px 1px #px 8px 1px #98c0e8, 8px 7px 1px #px 8px 1px #98c0e8, 8px 8px 1px #px 7px 1px #px 9px 1px #98c0e8, 9px 8px 1px #px 9px 1px #98c0e8, 9px 9px 1px #px 8px 1px #px 10px 1px #98c0e8, 10px 9px 1px #px 10px 1px #98c0e8, 10px 10px 1px #px 9px 1px #px 11px 1px #98c0e8, 11px 10px 1px #px 11px 1px #98c0e8, 11px 11px 1px #px 11px 1px #666, 11px 12px 1px #666, 10px 12px 1px #666, 9px 12px 1px #666, 8px 11px 1px #666, 7px 10px 1px #666, 6px 9px 1px #666, 5px 8px 1px #666, 4px 7px 1px #666, 3px 6px 1px #666, 2px 5px 1px #666, 1px 4px 1px #666, 0 3px 1px #666, -1px 2px 1px #666, 20px 8px 8px rgba(0,0,0,.7);
h1:before,h1:after{
content: 'TanZhouCaiPiao';
color:rgba(41,76,138,0.8);
text-shadow: 0 0 1px currentColor,-1px -1px 1px #003,0 -1px 1px #003,1px -1px 1px #003,1px 0 1px #003,1px 1px 1px #003,0 1px 1px #003,-1px 1px 1px #003,-1px 0 1px #003;
h1:after {
color: rgba(40,80,120,.1);
text-shadow: 1px -1px 1px rgba(40,80,120,.8),-1px 1px 1px rgba(255,255,255,.8);
#Game .G_top .G_t_kaijiang{
height:110
background:rgba(41,76,138,0.8);
right:0;top:0;
#Game .G_top .G_t_kaijiang .G_t_k_title{
line-height:20
background:rgba(51,51,51,0.8);
font-size:14
text-align:
#Game .G_top .G_t_kaijiang .G_t_k_title .G_t_k_t_issue{
margin:0 5
color:#399;
#Game .G_top .G_t_kaijiang .G_t_k_num{
width:100%;
#Game .G_top .G_t_kaijiang .G_t_k_num span{
margin-left:11
margin-top:16
background:url('../img/num.png') -423px -119
#Game .G_top .G_t_kaijiang .G_t_k_num span.kaijiang{
background:url('../img/mv.gif');
background-position: '0px 0px';
#Game .G_top .G_t_user{
bottom:-20
#Game .G_top .G_t_user .supMoney,#Game .G_top .G_t_user .addMoney{
font-weight:
font-size:24
color:#ff6700;
opacity:1;
#Game .G_top .G_t_user .addMoney{
color:#00ff66;
#Game .G_top .G_t_user & div{
line-height:40
text-align:
#Game .G_top .G_t_user .G_t_u_buy{
color:#ff0;
#Game .G_top .G_t_user .G_t_u_buy .G_t_u_money{
color:#ff6700;
width:100%;
height:350
margin-top:30
#content .c_left{
height:100%;
#content .c_left .c_l_mode{
background:rgba(0,0,0,0.8);
border-radius:5
#content .c_left .c_l_mode & span{
font-family:14
text-align:
line-height:34
margin:2px 10px 2px 0
background:rgb(78,70,63);
border-radius:5
transition:0.3s;
-moz-transition:0.3s;
-webkit-transition:0.3s;
-o-transition:0.3s;
-ms-transition:0.3s;
#content .c_left span.c_l_m_first{
background:rgba(31,58,110,1);
#content .c_left .c_l_mode & span:hover{
background:rgba(31,58,110,1);
#content .c_left .c_l_shuoming{
margin-top:10
width:100%;
background:rgba(0,0,0,0.8);
border-radius:5
#content .c_left .c_l_shuoming .c_l_s_right{
margin:11px 10px 11px 0
#content .c_left .c_l_shuoming .c_l_s_right & a{
line-height:20
font-size:12
text-align:
margin-right:7
background:url('../img/icon.png') no-
#content .c_left .c_l_shuoming .c_l_s_right & a .c_l_s_r_hide{
color:#e8e9e9;
background:rgba(41, 76, 138, 0.8);
border-radius:5
#content .c_left .c_l_number{
height:160
margin-top:20
padding:0 10
#content .c_left .c_l_number ul{
#content .c_left .c_l_number ul:after{
visibility:
font-size:0;
content:" ";
#content .c_left .c_l_number .c_l_n_align{
color:#ffbe13;
line-height:50
#content .c_left .c_l_number ul li{
border-radius:50%;
line-height:43
text-align:
margin:3px 5px 4px 0
background:url('../img/icon.png') no-repeat -46px -57
#content .c_left .c_l_number .c_l_n_btn{
margin-top:5
#content .c_left .c_l_number .c_l_n_btn & span{
font-size:12
line-height:20
text-align:
background:#4a433c;
border-radius:3
transition:0.3s;
-moz-transition:0.3s;
-webkit-transition:0.3s;
-o-transition:0.3s;
-ms-transition:0.3s;
#content .c_left .c_l_number .c_l_n_btn & span:hover{
background:rgb(50,93,164);
#content .c_left .c_l_bottom{
width:100%;
margin-top:20
#content .c_left .c_l_bottom .c_l_b_function{
padding-left:10
background:rgba(0,0,0,0.8);
border-radius:5
line-height:34
font-size:12
#content .c_left .c_l_bottom .c_l_b_function i{
margin:0 5
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_sup{
margin-top:9
background:url('../img/sub.png') no-
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_beishu{
background:#333;
border-radius:5
text-align:
color:#ff6700;
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_add{
margin-top:9
background:url('../img/add.png') no-
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_sel{
background:#333;
border-radius:5
margin:5px 20
text-align:
color:#ff6700;
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_jiangjin{
height:100%;
display:inline-
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_jiangjin span{
color:#ff6700;
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_data{
#content .c_left .c_l_bottom .c_l_b_function .c_l_b_f_data .c_l_b_f_d_num{
margin:0 5
color:#ff6700;
#content .c_left .c_l_bottom .c_l_b_function:after{
visibility:
font-size:0;
content:" ";
#content .c_left .c_l_bottom .c_l_b_submit{
background:rgba(0,0,0,0.8);
border-radius:5
margin-right:10
#content .c_left .c_l_bottom .c_l_b_submit & input{
border-radius:3
font-size:16
font-family:'Microsoft yahei';
background:rgba(50,93,164,0.8);
#content .c_left .c_l_bottom .c_l_b_submit & input:hover{
background:rgba(50,93,164,1);
#content .c_left .c_l_bottom .c_l_b_deledNum{
bottom:-33
border-radius:3
font-size:16
font-family:'Microsoft yahei';
background:rgba(50,93,164,0.8);
#content .c_left .c_l_bottom .c_l_b_deledNum:hover{
background:rgba(50,93,164,1);
#content .c_left .c_l_data{
min-width:660
max-width:660
min-height:115
border-radius:5
background:rgba(0,0,0,0.8);
padding:5px 10
font-size:14
font-family:'merriweather,arial,sans-serif';
letter-spacing:2
#content .c_right{
height:100%;
#content .c_right & div{
border-radius:5
background:rgba(0,0,0,0.8);
#content .c_right .c_r_rus{
width:100%;
height:185
#content .c_right .c_r_rus & div{
color:#ff6700;
line-height:30
text-align:
#content .c_right .c_r_rus .c_r_r_qihao{
left:0;top:0;
#content .c_right .c_r_rus .c_r_r_haoma{
right:0;top:0;
#content .c_right .c_r_rus ul{
width:100%;
top:30left:0;
#content .c_right .c_r_rus ul li{
width:100%;
#content .c_right .c_r_rus ul li span{
display:inline-
line-height:30
text-align:
#content .c_right .c_r_list{
height:150
padding:10
text-align:
font-size:14
#content .c_right .c_r_list .c_r_l_title{
width:100%;
#content .c_right .c_r_list .c_r_l_title span{
display:inline-
text-align:
line-height:20
color:#ff6700;
#content .c_right .c_r_list ul li{
width:100%;
#content .c_right .c_r_list ul li span{
display:inline-
text-align:
line-height:20
margin-right:4
#content .c_right .c_r_list ul li span.list_close{
text-align:
color:#ff6700;
#content .c_right .c_r_l_title span.close{
width:20height:20
background-image: url('../img/icon.png');
background-repeat: no-
background-position: -67px -21
#content .c_right .c_r_touzhu{
margin-top:15
text-align:
#content .c_right .c_r_touzhu span{
color:#ff6700;
#content .c_right .c_r_touzhu .c_r_t_issue{
#content .c_right .c_r_touzhu .c_r_t_queren{
font-size:14
margin:15px 0;
#content .c_right .c_r_touzhu .c_r_t_btn{
width:100%;
background:rgba(50,93,164,0.8);
border-radius:5
font-size:26
font-family:'Microsoft yahei';
font-weight:
transition:0.3s;
-moz-transition:0.3s;
-webkit-transition:0.3s;
-o-transition:0.3s;
-ms-transition:0.3s;
#content .c_right .c_r_touzhu .c_r_t_btn:hover{
background:rgba(50,93,164,1);
window.onload=function(){
var toggleMove=document.getElementById('toggleMove');
var toggleOff=
Game.init();
move(toggleMove.parentNode,{'top':'0px'},'10');
toggleMove.onclick=function(){
if(toggleOff){
move(toggleMove.parentNode,{'top':'-242px'},'10');
this.className='close';
toggleOff = !toggleO
move(toggleMove.parentNode,{'top':'0px'},'10');
this.className='arrow';
toggleOff = !toggleO
var Game={
'numPos':['-63px -61px','-3px -3px','-63px -3px','-123px -3px','-183px -3px','-243px -3px','-303px -3px','-363px -3px','-423px -3px','-3px -61px'],
'oNum':document.getElementById('c_l_number'),
'personMon':document.getElementById('G_t_u_money'),
'alignArr':['百位','十位','个位'],
'btnArr':['全','大','小','奇','偶','清'],
'qishu':0,
'step':'0',
'Data':[],
'targetData':[],
'OrderArr':[],
'num':'1',
'amountX':0,
'wanfa':null,
'init':function(){
var oMode=document.getElementById('c_l_mode').getElementsByTagName('span');
var jiangjin=document.getElementById('jiangjin');
this.addInitCase1();
this.addRegulation('0');
this.control();
this.controlInput(Game.amountX);
this.controlSelect(Game.num);
this.getNumData(Game.step);
this.empty();
for (var i=0;i & oMode.i++)
oMode[i].index=i;
oMode[i].onclick=function(){
Game.step=this.
for (var j=0;j & oMode.j++)
oMode[j].className='';
this.className='c_l_m_first';
switch(this.index){
Game.addInitCase1();
jiangjin.innerHTML='1800';
Game.addInitCase1();
jiangjin.innerHTML='18';
Game.addInitCase2();
jiangjin.innerHTML='7.8';
Game.Data.length=0;
Game.addRegulation(this.index);
Game.getNumData(Game.step);
Game.control();
'addInitCase1':function(){
this.oNum.innerHTML='';
for (var i=0;i & this.alignArr.i++ )
var oNum_ul=document.createElement('ul');
var oNum_ul_div=document.createElement('div');
oNum_ul_div.innerHTML=this.alignArr[i];
oNum_ul_div.className='c_l_n_align';
oNum_ul.appendChild(oNum_ul_div);
for (var j=0; j & 10;j++ )
var oNum_ul_li=document.createElement('li');
oNum_ul_li.off=
oNum_ul_li.className='li'+i;
oNum_ul_li.innerHTML=j;
oNum_ul.appendChild(oNum_ul_li);
var oNum_ul_Rdiv=document.createElement('div');
for (var z=0;z & this.btnArr.z++ )
var oSpan=document.createElement('span');
oSpan.className='span'+i;
oSpan.innerHTML=this.btnArr[z];
oNum_ul_Rdiv.appendChild(oSpan);
oNum_ul_Rdiv.className='c_l_n_btn';
oNum_ul.appendChild(oNum_ul_Rdiv);
this.oNum.appendChild(oNum_ul);
'addInitCase2':function(){
this.oNum.innerHTML='';
var init1Arr=['大','小','单','双'];
for (var i=0;i & this.alignArr.length-1;i++ )
var oNum_ul=document.createElement('ul');
var oNum_ul_div=document.createElement('div');
oNum_ul_div.innerHTML=Game.alignArr[i];
oNum_ul_div.className='c_l_n_align';
oNum_ul.appendChild(oNum_ul_div);
for (var j=0; j & init1Arr.j++ )
var oNum_ul_li=document.createElement('li');
oNum_ul_li.off=
oNum_ul_li.className='li'+i;
oNum_ul_li.innerHTML=init1Arr[j];
oNum_ul.appendChild(oNum_ul_li);
var oNum_ul_Rdiv=document.createElement('div');
var oSpan=document.createElement('span');
oSpan.innerHTML=this.btnArr[5];
oSpan.className='span'+i;
oNum_ul_Rdiv.appendChild(oSpan);
oNum_ul_Rdiv.className='c_l_n_btn';
oNum_ul.appendChild(oNum_ul_Rdiv);
this.oNum.appendChild(oNum_ul);
'addRegulation':function(step){
var oP=document.getElementById('c_l_s_right');
var oHide=this.getClassName(oP,'c_l_s_r_hide');
var data=[
['从百位、十位、个位各选一个号码组成一注。','从百位、十位、个位中选择一个3位数号码组成一注,所选号码与开奖号码后3位相同,且顺序一致,即为中奖。','投注方案:345&/br&开奖号码:345,即中后三直选。'],
['在百位、十位、个位任意位置上任意选择1个或1个以上号码。','从百位、十位、个位任意位置上至少选择1个以上号码,所选号码与相同位置上的开奖号码一致,即为中奖。','投注方案:百位 1&/br&开奖号码:百位 1,即中定位胆百位。'],
['从百位、十位中的“大、小、单、双”中至少各选一个组成一注。','对百位和十位的“大(56789)小(01234)、单(13579)双(02468)”形态进行购买,所选号码的位置、形态与开奖号码的位置、形态相同,即为中奖。','投注方案:小双&/br&开奖号码:百位与十位“小双”,即中前二大小单双。']
for (var i=0;i & oHide.i++ )
oHide[i].index=i;
oHide[i].innerHTML=data[step][i];
oHide[i].parentNode.onmouseover=function(ev){
ev=ev||window.
ev.preventDefault();
for (var j=0;j& oHide.j++)
oHide[j].style.display='none';
this.children[0].style.display='block';
for (var i=0;i & oHide.i++ )
oHide[i].parentNode.onmouseout=function(ev){
ev=ev||window.
ev.preventDefault();
this.children[0].style.display='none';
'getNumData':function(step){
var addBtn=document.getElementById('c_l_b_s_addNum');
var oText=document.getElementById('c_l_data');
var amount=document.getElementById('zhushu');
var money=document.getElementById('money');
var oInput=document.getElementById('c_l_b_f_beishu');
var oUl=this.oNum.
this.Data[step]=[];
for (var i=0;i & oUl.i++ )
this.Data[step][i]=[];
this.select(this.getClassName(oUl[i],'li'+i),this.Data[step][i]);
addBtn.onclick=function(){
oText.innerHTML='';
Game.Data[Game.Data.length]=
Game.targetData=addNum(Game.Data);
/**************************/
if(Game.targetData.length){
switch(parseInt(step)){
Game.amountX=Game.targetData.length
amount.innerHTML=Game.amountX;
oText.innerHTML=Game.targetD
Game.amountX=Game.targetData.
amount.innerHTML=Game.amountX;
for (var i=0;i & Game.targetData.i++ )
oText.innerHTML+=Game.targetData[i]+'n';
Game.amountX=Game.targetData.length
amount.innerHTML=Game.amountX;
oText.innerHTML=Game.targetD
Game.wanfa=
money.innerHTML=Game.count.accMul(Game.num,Game.amountX*2*oInput.value);
money.innerHTML = '0';
amount.innerHTML = '0';
alert('请选择正确的投注方式!');
/**************************/
function addNum(Data){
var n=parseInt(Data[Data.length-1]);
switch(n){
return getResultOne(Data[n]);
return getResultTwo(Data[n]);
return getResultThree(Data[n]);
function getResultOne(Arr){
var newArr=[];
if(Arr[0].length & 0 && Arr[1].length & 0 && Arr[2].length & 0){
for (var i=0;i & Arr[0].i++ )
for (var j=0;j& Arr[1].j++ )
for (var z=0;z& Arr[2].z++ )
newArr.push(Arr[0][i]+''+Arr[1][j]+''+Arr[2][z]);
newArr.sort(function(a,b){
return a-b;
return newA
function getResultTwo(Arr){
var strArr=['百位','十位','个位'];
var newArr=[];
for (var i=0;i & Arr.i++ )
if(Arr[i].length){
for (var j=0;j & Arr[i].j++ )
newArr.push(strArr[i]+' :
'+Arr[i][j])
return newA
function getResultThree(Arr){
var newArr=[];
if(Arr[0].length & 0 && Arr[1].length & 0 ){
for (var i=0;i & Arr[0].i++ )
for (var j=0;j& Arr[1].j++ )
newArr.push(Arr[0][i]+''+Arr[1][j]);
newArr.sort(function(a,b){
return a-b;
return newA
'select':function(obj,arr){
var oText=document.getElementById('c_l_data');
var three=['大','小','单','双'];
for (var i=0;i&obj.i++ )
obj[i].index=i;
obj[i].off=
obj[i].onclick=function(){
var oSpan=this.parentNode.getElementsByTagName('span');
for (var i=0;i & oSpan.i++ )
oSpan[i].style.background='#4a433c';
if(this.off){
this.style.backgroundPosition='-2px -57px';
arr.push(obj[this.index].innerHTML);
this.off = !this.
this.style.backgroundPosition='-46px -57px';
if(arr.length){
for (var j=0;j&arr.j++ )
if(Game.step == 2){
if(arr[j] == three[this.index]){
arr.splice(j,1);
if(arr[j] == this.index){
arr.splice(j,1);
this.off = !this.
'control':function(){
var oSpan,
var controlDiv=this.getClassName(this.oNum,'c_l_n_btn');
for (var i=0;i & controlDiv.i++ )
controlDiv[i].index=i;
oSpan=this.getClassName(controlDiv[i],'span'+i);
for (var j=0;j & oSpan.j++ )
oSpan[j].index=j
oSpan[j].onclick=function(){
num=this.parentNode.
Game.Data[Game.step][num].length=0;
var oParent=this.parentNode.parentN
var oLi=oParent.getElementsByTagName('li');
for (var z=0;z & oLi.z++ )
oLi[z].style.backgroundPosition='-46px -57px';
oLi[z].off =
if(Game.step != 2){
var siblings=this.parentNode.
for (var z=0;z & siblings.z++ )
siblings[z].style.background='#4a433c';
Game.controlFn(oLi,num,this.index);
this.style.background='rgb(50,93,164)';
'controlFn':function(oLi,num,index){
var half=parseInt(oLi.length/2);
for (var i=0;i & oLi.i++ )
switch(index)
oLi[i].style.backgroundPosition='-2px -57px';
oLi[i].off =
Game.Data[Game.step][num].push(i);
if(i & half-1){
oLi[i].style.backgroundPosition='-2px -57px';
oLi[i].off =
Game.Data[Game.step][num].push(i);
if(i & half){
oLi[i].style.backgroundPosition='-2px -57px';
oLi[i].off =
Game.Data[Game.step][num].push(i);
var n=(i*2)-1;
if (n & 0 && n & oLi.length){
oLi[n].style.backgroundPosition='-2px -57px';
oLi[n].off =
Game.Data[Game.step][num].push(n);
if(i*2 & oLi.length-1){
oLi[i*2].style.backgroundPosition='-2px -57px';
oLi[i*2].off =
Game.Data[Game.step][num].push(i*2);
oLi[i].style.backgroundPosition='-46px -57px';
oLi[i].off =
Game.Data[Game.step][num].length=0;
//倍数Input
'controlInput':function(amountX){
var money=document.getElementById('money');
var oInput=document.getElementById('c_l_b_f_beishu');
var oBtn=oInput.parentNode.getElementsByTagName('span');
for (var i=0;i & oBtn.i++ )
oBtn[i].index=i;
oBtn[i].onclick=function(){
if(this.index){
if(oInput.value & 9999){
oInput.value++;
if(oInput.value & 0){
oInput.value--;
money.innerHTML=Game.count.accMul(Game.num,Game.amountX*2*oInput.value);
oInput.addEventListener('input',function(){
if(!this.value){
this.value=0;
if(this.value & 9999){
this.value=9999;
this.value=parseInt(this.value);
money.innerHTML=Game.count.accMul(Game.num,Game.amountX*2*this.value);
'controlSelect':function(){
var oInput=document.getElementById('c_l_b_f_beishu');
var money=document.getElementById('money');
var oMode=document.getElementById('sel_mode');
oMode.addEventListener('input',function(){
switch(this.value){
Game.num=1;
Game.num=0.1;
Game.num=0.01;
money.innerHTML=Game.count.accMul(Game.num,Game.amountX*2*oInput.value);
'empty':function(){
var oDiv=document.getElementById('c_l_number');
var emptyBtn=document.getElementById('c_l_b_deledNum');
var oText=document.getElementById('c_l_data');
var money=document.getElementById('money');
var amount=document.getElementById('zhushu');
var listUl=document.getElementById('c_r_l_ul');
var oInput=document.getElementById('c_l_b_f_beishu');
var oMode=document.getElementById('sel_mode');
var jiangjin=document.getElementById('jiangjin');
var arr=['三星直选','定位胆','大小单双'];
emptyBtn.onclick=function(){
if(parseInt(money.innerHTML*999)){
var json={a:jiangjin.innerHTML,b:amount.innerHTML,c:oInput.value,d:money.innerHTML,e:Game.targetData,f:Game.num};
Game.OrderArr.push(json);
var oLi=document.createElement('li');
oLi.innerHTML='&span data-step="'+Game.wanfa+'"&'+arr[Game.wanfa]+'&/span&&span&'+amount.innerHTML+'&/span&&span&'+oInput.value+'&/span&&span&'+money.innerHTML+'&/span&&span class="list_close"&&&/span&';
listUl.appendChild(oLi);
/************************************************************/
oDiv.innerHTML='';
oText.innerHTML='';
money.innerHTML='0';
amount.innerHTML='0';
switch(parseInt(Game.step)){
Game.addInitCase1();
Game.addInitCase1();
Game.addInitCase2();
Game.getNumData(Game.step);
Game.control();
Game.amountX=0;
if(Game.OrderArr.length){
Game.delOrder();
Game.pushIn();
if(parseInt(amount.innerHTML))
alert('提交注单失败,请您核实投注金额重新提交!');
alert('请您提交号码,再提交订单哟!');
'delOrder':function(){
var oUl=document.getElementById('c_r_l_ul');
var closeBtn=this.getClassName(oUl,'list_close');
for (var i=0;i & closeBtn.i++ )
closeBtn[i].index=i;
closeBtn[i].onclick=function(){
Game.OrderArr.splice(this.index,1);
this.parentNode.parentNode.removeChild(this.parentNode);
'pushIn':function(){
var supMoney=document.getElementById('supMoney');
var oPushBtn=document.getElementById('c_r_t_btn');
oPushBtn.onclick=function(){
var money=0;
var pM=Game.personMon.innerHTML;
if(Game.OrderArr.length){
for (var i=0;i & Game.OrderArr.i++ )
money=Game.count.accAdd(money,Game.OrderArr[i].d)
if(pM & money){
if(confirm('您选择'+Game.OrderArr.length+'个注单,投注总金额'+money+'元'))
Game.personMon.innerHTML=Game.count.accSubtr(pM,money);
supMoney.innerHTML='-'+
move(supMoney,{top:'50px',opacity:'0'},'50',function(){
supMoney.innerHTML='';
this.style.cssText='top:0;opacity:1;';
Game.kaijiang(Game.getAward);
alert('余额不足,请充值后再进行投注!');
alert('请您选择号码,提交注单后投注!');
'kaijiang':function(callback){
var result=[];
var oSpan=document.getElementById('G_t_k_num').
var listUl=document.getElementById('c_r_l_ul');
for (var i= listUl.children.length-1 ;i &= 0; i-- )
listUl.children[i].parentNode.removeChild(listUl.children[i]);
for (var i=0;i & oSpan.i++ )
oSpan[i].className='kaijiang';
oSpan[i].style.transitionDelay='0s';
setTimeout(function(){
for (var i=0;i & oSpan.i++ )
var n=Math.floor(Math.random()*10);
result.push(n);
oSpan[i].className='';
oSpan[i].style.transitionDelay=i*0.3+'s';
oSpan[i].style.backgroundPosition=Game.numPos[n];
return callback(result);
'getAward':function(res){
var issue=document.getElementById('G_t_k_t_issue');
var oBox=document.getElementById('c_r_r_box');
issue.innerHTML=addZero(Game.qishu);
if(oBox.children.length == 5){
var removeObj=oBox.children[4];
removeObj.parentNode.removeChild(removeObj);
var oLi=document.createElement('li');
oLi.innerHTML='&span class="qishu"&'+addZero(Game.qishu)+'&/span&&span class="haoma"&'+res+'&/span&';
if(oBox.children.length){
oBox.insertBefore(oLi , oBox.children[0])
oBox.appendChild(oLi);
function addZero(a){
if(a & 10){
return '00'+a;
}else if(a & 100){
return '0'+a;
return ''+a;
Game.qishu++;
Game.setMoney(res);
Game.targetData.length=0;
'setMoney':function(res){
var addMoney=document.getElementById('addMoney');
var regB=/百位/,regS=/十位/,regG=/个位/;
var bArr=[],sArr=[],gArr=[];
var san=res[2]+""+res[3]+""+res[4];
var arr=[];
arr.push(((res[2]%2?'单':'双') + (res[3]%2?'单':'双')));
arr.push(((res[2]&4?'大':'小') + (res[3]%2?'单':'双')));
arr.push(((res[2]&4?'大':'小') + (res[3]&4?'大':'小')));
var moneyAward=0;
for (var i=0;i & this.OrderArr.i++ )
n=this.OrderArr[i]
switch(n.a){
case '1800':
for (var z=0;z & n.e.z++ )
if(san == n.e[z]){
moneyAward=this.count.accAdd( moneyAward , this.count.accMul( n.a*n.c ,n.f) );
case '18':
for (var z=0;z & n.e.z++ )
if( regB.test(n.e[z]) ){
if( new RegExp(res[2]).test(n.e[z]) )
}else if( regS.test(n.e[z]) ){
if( new RegExp(res[3]).test(n.e[z]) )
}else if( regG.test(n.e[z]) ){
if( new RegExp(res[4]).test(n.e[z]) )
moneyAward=this.count.accAdd( moneyAward , this.count.accMul( n.f, n.a*k*n.c ) );
case '7.8':
//中奖注数初始值
for (var z=0;z & n.e.z++ )
for(var x=0;x & arr.x++){
if(n.e[z] == arr[x] )
moneyAward=this.count.accAdd( moneyAward , this.count.accMul( n.f, n.a*j*n.c ) );
if(moneyAward){
addMoney.innerHTML='+'+moneyA
move(addMoney ,{top:'-50px',opacity:'0'},'50',function(){
addMoney.innerHTML='';
this.style.cssText='top:0;opacity:1;';
this.personMon.innerHTML=this.count.accAdd(this.personMon.innerHTML,moneyAward);
this.OrderArr.length=0;
'getClassName':function(obj,cName){
var obj= obj ||
if(obj.getElementsByClassName)
return obj.getElementsByClassName(cName);
var arr=[];
var allE=obj.getElementsByTagName('*');
for (var i=0;i&allE.i++ )
var allElements=allE[i].className.split(' ');
for (var j=0;j&allElements.j++)
if(allElements[j].className==cName)
arr.push(allE[i]);
'accMul':function(a,b)
var m=0,s1=a.toString(),s2=b.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
'accDiv':function(a,b){
var t1=0,t2=0,r1,r2;
try{t1=a.toString().split(".")[1].length}catch(e){}
try{t2=b.toString().split(".")[1].length}catch(e){}
with(Math){
r1=Number(a.toString().replace(".",""))
r2=Number(b.toString().replace(".",""))
return (r1/r2)*pow(10,t2-t1);
'accAdd':function(a,b){
var r1,r2,m;
try{r1=a.toString().split(".")[1].length}catch(e){r1=0}
try{r2=b.toString().split(".")[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2))
return (a*m+b*m)/m;
'accSubtr':function(a,b){
var r1,r2,m,n;
try{r1=a.toString().split(".")[1].length}catch(e){r1=0}
try{r2=b.toString().split(".")[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2));
n=(r1&=r2)?r1:r2;
return ((a*m-b*m)/m).toFixed(n);
sports-1.0-js.js
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
return getComputedStyle(obj,false)[attr];
function move(obj,json,num,fn){
var timer=null,attr=iCur=null,iTarget=null,iSpeed=
clearInterval(obj.timer);
obj.timer=setInterval(function(){
var onOff=
for(attr in json){
iTarget=json[attr];
iTarget=parseInt(iTarget);
if(attr=="opacity"){
iCur=parseInt(parseFloat(getStyle(obj,attr)*100));
if(isNaN(iCur)){
iCur=parseInt(getStyle(obj,attr));
if(iCur&iTarget){
iSpeed=Math.ceil((iTarget-iCur)/num);
iSpeed=Math.floor((iTarget-iCur)/num);
if(iCur!=iTarget){
if(attr=="opacity"){
obj.style[attr]=(iCur+iSpeed)/100;
obj.style.filter="alpha(opacity=iCur+iSpeed)";
obj.style[attr]=iCur+iSpeed+"px";
if(Math.abs(iSpeed)&Math.abs(iTarget-iCur)){
obj.style[attr]=iTarget+"px";
if(onOff){
clearInterval(obj.timer);
fn&&fn.call(obj);
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 js 调用蓝牙打印机 的文章

 

随机推荐