JQUERY对象的声明与应用

1 function Config(lang) { 2 3 //当前语言类型 4 var type = lang; 5 6 //国际化 7 this.dictionary = function (enums, arr) { 8 //第一步 9 var index = [ 10 'all', 'magnum', 'toto', 'pmp', 'singapore', 'sabah', 'sandakan', 'sarawak', 'mark6', 'hi', 'lo', 'pre', 'next', 'last', 'first', 'page', '' 11 ]; 12 13 14 //第三步 15 var key = { 16 0: all, 17 1: magnum, 18 2: toto, 19 3: pmp, 20 4: singapore, 21 5: sabah, 22 6: sandakan, 23 7: sarawak, 24 8: mark6, 25 9: hi, 26 10: lo, 27 11: pre, 28 12: next, 29 13: last, 30 14: first, 31 15: page, 32 33 }; 34 //使用 alert(new Config().dictionary('all')); 35 var k = 0; 36 for (var i = 0; i < index.length - 1; i++) { 37 if (index[i] == enums) { 38 k = i; 39 } 40 } 41 //语言类型 42 var language = ['en-us', 'zh-tw', 'zh-cn']; 43 44 var word = ''; 45 for (var i = 0; i < language.length; i++) { 46 if (language[i] == type) { 47 if (k) { 48 word = key[k][i]; 49 break; 50 } 51 52 } 53 } 54 if (arr) { 55 for (var i = 0; i < arr.length; i++) { 56 word = word.replace("{" + i + "}", arr[i]); 57 } 58 } 59 return word == "" ? '' : word; 60 } 61 62 }

1 声明 2 function Quick() { 3 this.hide = function () { 4 $("#f_tab").animate({ right: "-180px" }); 5 } 6 this.show = function () { 7 $("#f_tab").animate({ right: "0px" }); 8 } 9 //右边历史记录tab 切换 10 this.history_tab = function () { 11 var $mainbody = $(window.parent.document.body); 12 var index = $(this).index(); 13 if (!$(this).hasClass("bg-quickmenu-history-ov")) { 14 $(this).addClass("bg-quickmenu-history-ov").siblings().removeClass("bg-quickmenu-history-ov"); 15 } 16 if (index == 0) { 17 $mainbody.undefined(".bs_ball_td").show().siblings().hide(); 18 } 19 if (index == 2) { 20 $mainbody.find(".oe_ball_td").show().siblings().hide(); 21 } 22 if (index == 4) { 23 $mainbody.find(".rgb_ball_td").show().siblings().hide(); 24 } 25 } 26 //hotNumber 选取 27 this.hotNum = function () { 28 global.iszodiac = false; 29 var num = parseInt($(this).text()); 30 global.arrNum = [num]; 31 global.ball = num; 32 global.isbet = $(".numstatus").eq(0).attr("numstatus") == "bet" ? true : false; 33 if (global.isbet) { 34 global.isred == false; 35 } else { 36 global.isred == true; 37 } 38 buyAll(); 39 } 40 //买什么 (大 小 单 双 红 蓝 绿) 41 //规则 0:All 1:大 2:小 3:双 4:单 5:红 42 this.witch_buy = function (index) { 43 //买生肖还是 number 44 global.iszodiac = false; 45 global.isbet = $(".numstatus").eq(0).attr("numstatus") == "bet" ? true : false; 46 if (index == 0) { 47 global.arrNum = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49); 48 buyAll(); 49 } 50 if (global.isbet) { 51 global.isred = false; 52 } 53 var $tr = $().iframeDom("#content_number>table>tbody>tr"); 54 if (index == 0) { 55 $tr.each(function () { 56 global.index = $(this).attr("data-num"); 57 global.status = $(this).attr("data-status"); 58 global.market = $(this).attr("data-market"); 59 global.ball = $(this).attr("data-num"); 60 if (global.isred) { 61 global.key = 4; 62 } else { 63 global.key = 3; 64 } 65 if (typeof global.index == 'string' && global.status != 'closed') { 66 if (global.isbet) { 67 global.odds = $(this).find(".mark6_item_blue span>strong").text(); 68 } else { 69 global.odds = $(this).find(".mark6_item_red span>strong").text(); 70 } 71 global.isIndividual = "false"; 72 appendToleft(global.market); 73 } 74 }); 75 global.isIndividual = "true"; 76 } 77 if (index == 1) { 78 $tr.each(function () { 79 global.index = $(this).attr("data-num"); 80 global.status = $(this).attr("data-status"); 81 global.market = $(this).attr("data-market"); 82 global.ball = $(this).attr("data-num"); 83 if (global.isred) { 84 global.key = 4; 85 } else { 86 global.key = 3; 87 } 88 if (typeof global.index == 'string' && global.index >= 25 && global.status != 'closed') { 89 if (global.isbet) { 90 global.odds = $(this).find(".mark6_item_blue span>strong").text(); 91 } else { 92 global.odds = $(this).find(".mark6_item_red span>strong").text(); 93 } 94 global.isIndividual = "false"; 95 appendToleft(global.market); 96 } 97 }); 98 global.isIndividual = "true"; 99 } 100 if (index == 2) { 101 $tr.each(function () { 102 global.index = $(this).attr("data-num"); 103 global.status = $(this).attr("data-status"); 104 global.market = $(this).attr("data-market"); 105 global.ball = $(this).attr("data-num"); 106 if (global.isred) { 107 global.key = 4; 108 } else { 109 global.key = 3; 110 } 111 if (typeof global.index == 'string' && global.index < 25 && global.status != 'closed') { 112 if (global.isbet) { 113 global.odds = $(this).find(".mark6_item_blue span>strong").text(); 114 } else { 115 global.odds = $(this).find(".mark6_item_red span>strong").text(); 116 } 117 global.isIndividual = "false"; 118 appendToleft(global.market); 119 } 120 }); 121 global.isIndividual = "true"; 122 } 123 if (index == 3) { 124 $tr.each(function () { 125 global.index = $(this).attr("data-num"); 126 global.status = $(this).attr("data-status"); 127 global.market = $(this).attr("data-market"); 128 global.ball = $(this).attr("data-num"); 129 if (global.isred) { 130 global.key = 4; 131 } else { 132 global.key = 3; 133 } 134 if (typeof global.index == 'string' && global.index % 2 == 0 && global.status != 'closed') { 135 if (global.isbet) { 136 global.odds = $(this).find(".mark6_item_blue span>strong").text(); 137 } else { 138 global.odds = $(this).find(".mark6_item_red span>strong").text(); 139 } 140 global.isIndividual = "false"; 141 appendToleft(global.market); 142 } 143 }); 144 global.isIndividual = "true"; 145 } 146 if (index == 4) { 147 $tr.each(function () { 148 global.index = $(this).attr("data-num"); 149 global.status = $(this).attr("data-status"); 150 global.market = $(this).attr("data-market"); 151 global.ball = $(this).attr("data-num"); 152 if (global.isred) { 153 global.key = 4; 154 } else { 155 global.key = 3; 156 } 157 if (typeof global.index == 'string' && global.index % 2 != 0 && global.status != 'closed') { 158 if (global.isbet) { 159 global.odds = $(this).find(".mark6_item_blue span>strong").text(); 160 } else { 161 global.odds = $(this).find(".mark6_item_red span>strong").text(); 162 } 163 global.isIndividual = "false"; 164 appendToleft(global.market); 165 } 166 }); 167 global.isIndividual = "true"; 168 } 169 if (index == 5) { 170 global.arrNum = new Array(1, 2, 7, 8, 12, 13, 18, 19, 23, 24, 29, 30, 34, 35, 40, 45, 46); 171 buyAll(); 172 173 } 174 if (index == 6) { 175 global.arrNum = new Array(3, 4, 9, 10, 14, 15, 20, 25, 26, 31, 36, 37, 41, 42, 47, 48); 176 buyAll(); 177 } 178 if (index == 7) { 179 global.arrNum = new Array(5, 6, 11, 16, 17, 21, 22, 27, 28, 32, 33, 38, 39, 43, 44, 49); 180 buyAll(); 181 } 182 } 183 184 //计算生肖的方法 185 this.buy_zodiac = function (index) { 186 //标明是买生肖 187 global.iszodiac = true; 188 var key = [7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6]; 189 var first = key[index - 1]; 190 var p; 191 if (key) { 192 for (var i = 0; i < key.length; i++) { 193 if (key[index - 1] == key[i]) { 194 p = i; 195 } 196 } 197 } 198 199 if (key[p] - key[0] < 0) { 200 first = key[0] - (key[p] + 12 - key[0]); 201 } else { 202 first = key[0] - (key[p] - key[0]); 203 } 204 global.arrNum.length = 0; 205 global.arrNum.push(first); 206 for (var i = 0; i < 4; i++) { 207 first += 12; 208 if (first <= 49) { 209 global.arrNum.push(first); 210 } 211 } 212 global.isred = $(".numstatus").eq(1).attr("numstatus") == "eat" ? true : false; 213 if (global.isred) { 214 global.isbet = false; 215 } else { 216 global.isbet = true; 217 } 218 buyAll(); 219 } 220 //单双切换 bet or eat 状态 221 this.changNumStatus = function () { 222 if (!$(this).hasClass("bg-sd-current-ov")) { 223 $(this).addClass("bg-sd-current-ov").siblings().removeClass("bg-sd-current-ov"); 224 var index = $(this).index(); 225 if (index == 0) { 226 $(this).parents(".numstatus").attr("numstatus", "bet"); 227 global.isred = false; 228 $(this).parents(".numstatus").next().find(".quick_btn").text("BET ALL"); 229 if ($(this).hasClass("zodiac")) { 230 var $img = $(".amt_animal").find("img"); 231 $img.each(function (index, item) { 232 $(item).attr("src", $(item).attr("src").replace(/red/, "blue")); 233 }); 234 } 235 var betMin = $("#hiloMin").val(); 236 $("#textfield5,#textfield6").val(betMin); 237 } 238 else { 239 $(this).parents(".numstatus").attr("numstatus", "eat"); 240 global.isred = true; 241 $(this).parents(".numstatus").next().find(".quick_btn").text("EAT ALL"); 242 if ($(this).hasClass("zodiac")) { 243 var $img = $(".amt_animal").find("img"); 244 $img.each(function (index, item) { 245 $(item).attr("src", $(item).attr("src").replace(/blue/, "red")); 246 }); 247 } 248 var eatMin = $("#extraMin").val(); 249 $("#textfield5,#textfield6").val(eatMin); 250 } 251 } 252 } 253 254 //show quick menu or zodiac 255 this.showtab = function () { 256 if ($(this).index() == 0) { 257 $(".quickmenu").find(".quick").show(); 258 $(".quickmenu").find(".zodiac").hide(); 259 } else { 260 $(".quickmenu").find(".zodiac").show(); 261 $(".quickmenu").find(".quick").hide(); 262 } 263 } 264 265 } 266 267 应用 268 <div class="quick_amt_big btn-bet-white-55" onclick="new Quick().witch_buy(1)"> 269 BIG 270 </div>
$("#betNum").bind("click", new OperaBet().betNum);//new OperaBet().betNum对象的方法
$().iframeDom(".mark6_item,.mark6_item_red,.mark6_item_blue").bind("click", operaNum);//operaNum方法的名称