ssqdb.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. var DRTcompare = new Object();
  2. DRTcompare.Config = {
  3. Redmin: 1,
  4. Redmax: 33,
  5. Redlen: 11,
  6. Bluemin: 1,
  7. Bluemax: 16,
  8. Bluelen: 8,
  9. msieEnter: unescape("\r\n"),
  10. geckoEnter: unescape("\r\n"),
  11. List: "6+1,6+0,5+1,5+0,4+1,4+0,3+1,3+0,2+1,2+0,1+1,1+0,0+1,0+0".split(","),
  12. exArea: 0,
  13. batchMax: 30
  14. };
  15. DRTcompare.Window_onLoad = function ()
  16. {
  17. DRTcompare.Result_onLoad();
  18. };
  19. DRTcompare.r_onclick = function (object)
  20. {
  21. var in1 = document.getElementById("in1");
  22. var in2 = document.getElementById("in2");
  23. var data = $(object).val();
  24. if (data == "0")
  25. {
  26. $("#leftul").attr("class","list array bot-line");
  27. $("#rightul").attr("class","list array selected");
  28. } else if (data == "1")
  29. {
  30. $("#leftul").attr("class","list array bot-line selected");
  31. $("#rightul").attr("class","list array");
  32. }
  33. };
  34. DRTcompare.cRedBlue_onLoad = function (type)
  35. {
  36. var mins = DRTcompare.Config[type + "min"];
  37. var maxs = DRTcompare.Config[type + "max"];
  38. var lens = DRTcompare.Config[type + "len"];
  39. var o = "";
  40. for (var i = mins; i <= maxs; i++)
  41. {
  42. //o += "<input type='checkbox' name='c" + type + "' value='" + i + "' id='c" + type + " " + i.addzero(2) + "'><label for='c" + type + " " + i.addzero(2) + "'>" + i.addzero(2) + "</label>";
  43. o += "<span class='bigball grey-28' id='c" + type + " " + i.addzero(2) + "' name='c" + type + "'>" + i.addzero(2) + "</span>";
  44. //if (i % lens == 0) o += "<br>";
  45. };
  46. document.getElementById("c" + type + "s").innerHTML = o;
  47. //var obj = document.forms["frm"].elements["c" + type];
  48. var obj = $("span[name=c" + type + "]");
  49. for (var i = 0; i < obj.length; i++)
  50. {
  51. obj[i].onclick = function () { DRTcompare.cRedBlue_onClick(this); };
  52. };
  53. };
  54. DRTcompare.cRedBlue_onClick = function (object)
  55. {
  56. // var type = (object.name == "cRed") ? "Red" : "Blue";
  57. // object.nextSibling.className = (object.checked == true) ? "t" + type : "";
  58. var type = ($(object).attr("name") == "cRed") ? "Red" : "Blue";
  59. if ($(object).attr("class") == "bigball ball-red-28")
  60. { $(object).attr("class","bigball bgrey-28"); }
  61. else { $(object).attr("class","bigball ball-red-28"); }
  62. DRTcompare.hRedBlue_onLoad("c",type,object);
  63. };
  64. DRTcompare.cRedBlue_Reform = function (type)
  65. {
  66. var tRedBlue = document.forms["frm"].elements["tRedBlue"].value.split("+");
  67. tRedBlue = (type == "Red") ? tRedBlue[0] : tRedBlue[1];
  68. var object = $("span[name=[c" + type + "]");
  69. //var object = document.forms["frm"].elements["c" + type];
  70. for (var i = 0; i < object.length; i++)
  71. {
  72. // object[i].checked = (tRedBlue.indexOf(Math.round(object[i].value).addzero(2)) != -1) ? true : false;
  73. // object[i].nextSibling.className = (object[i].checked == true) ? "t" + type : "";
  74. };
  75. };
  76. DRTcompare.tRedBlue_onLoad = function (type,value)
  77. {
  78. var o = "<input name='t" + type + "' value='" + value + "' size='1' maxlength='2' class='" + (type == "Red" ? "text red" : "text wblue") + "'> ";
  79. document.getElementById("t" + type + "s").innerHTML += o;
  80. var object = document.forms["frm"].elements["t" + type];
  81. object = object[object.length - 1];
  82. object.onpaste = function () { return false; };
  83. object.onclick = function () { this.select(); };
  84. object.onkeyup = function () { DRTcompare.tRedBlue_onKeyup(this); };
  85. object.onblur = function () { DRTcompare.tRedBlue_onBlur(this); };
  86. };
  87. DRTcompare.tRedBlue_onKeyup = function (object)
  88. {
  89. object.value = object.value.replace(/\D/gi,"");
  90. if (object.value.length == 2) DRTcompare.tRedBlue_Check(object);
  91. };
  92. DRTcompare.tRedBlue_onBlur = function (object)
  93. {
  94. if (object.value.length == 1)
  95. {
  96. object.value = Math.round(object.value).addzero(2);
  97. DRTcompare.tRedBlue_Check(object);
  98. };
  99. };
  100. DRTcompare.tRedBlue_Check = function (object)
  101. {
  102. var type = (object.name == "tRed") ? "Red" : "Blue"
  103. var mins = DRTcompare.Config[type + "min"];
  104. var maxs = DRTcompare.Config[type + "max"];
  105. if (Math.round(object.value) > maxs || Math.round(object.value) < mins) object.value = "";
  106. if (object.value != "") DRTcompare.hRedBlue_onLoad("t",type,object);
  107. };
  108. DRTcompare.tRedBlue_Reform = function (type)
  109. {
  110. document.getElementById("t" + type + "s").innerHTML = "";
  111. var tRedBlue = document.forms["frm"].elements["tRedBlue"].value.split("+");
  112. tRedBlue = (type == "Red") ? tRedBlue[0] : tRedBlue[1];
  113. tRedBlue = (tRedBlue + " ").split(" ");
  114. var object = document.forms["frm"].elements["t" + type];
  115. for (var i = 0; i < (tRedBlue.length - 1); i++) { DRTcompare.tRedBlue_onLoad(type,tRedBlue[i]); };
  116. };
  117. DRTcompare.tRedBlue_focus = function (type)
  118. {
  119. var object = document.forms["frm"].elements["t" + type];
  120. if (DRTcompare.BrowInfo == "msie") object[object.length - 1].focus();
  121. };
  122. DRTcompare.hRedBlue_onLoad = function (source,type)
  123. {
  124. var tRedBlue = document.forms["frm"].elements["tRedBlue"].value.split("+");
  125. switch (type)
  126. {
  127. case "Red": tRedBlue[0] = DRTcompare.hRedBlue_Gather(source,type); break;
  128. case "Blue": tRedBlue[1] = DRTcompare.hRedBlue_Gather(source,type); break;
  129. };
  130. document.forms["frm"].elements["tRedBlue"].value = tRedBlue.join("+");
  131. DRTcompare.hRedBlue_Reform(source,type);
  132. if (tRedBlue[0] != "") document.forms["frm"].elements["red_n"].value = (tRedBlue[0] + " ").split(" ").length - 1
  133. if (tRedBlue[1] != "") document.forms["frm"].elements["blue_n"].value = (tRedBlue[1] + " ").split(" ").length - 1;
  134. };
  135. DRTcompare.hRedBlue_Gather = function (source,type)
  136. {
  137. //var object = document.forms["frm"].elements[source + type];
  138. var object = $("span[name=" + source + type + "]");
  139. var mins = DRTcompare.Config[type + "min"];
  140. var maxs = DRTcompare.Config[type + "max"];
  141. var tmpStr = "";
  142. for (var i = 0; i < object.length; i++)
  143. {
  144. var objValue = $(object[i]).text();
  145. if ((tmpStr.indexOf(Math.round(objValue).addzero(2)) == -1) && (objValue != ""))
  146. {
  147. if (Math.round(objValue) >= mins && Math.round(objValue) <= maxs)
  148. {
  149. switch (source)
  150. {
  151. case "c":
  152. if ($(object[i]).attr("class") == "bigball ball-red-28")
  153. tmpStr += " " + Math.round(objValue).addzero(2);
  154. break;
  155. case "t":
  156. tmpStr += " " + Math.round(objValue).addzero(2);
  157. break;
  158. };
  159. };
  160. };
  161. };
  162. return tmpStr.trim();
  163. };
  164. DRTcompare.hRedBlue_Reform = function (source,type)
  165. {
  166. DRTcompare.tRedBlue_Reform(type);
  167. DRTcompare.cRedBlue_Reform(type);
  168. DRTcompare.tRedBlue_onLoad(type,"");
  169. switch (type)
  170. {
  171. case "Red": setTimeout("DRTcompare.tRedBlue_focus('Red')",0); break;
  172. case "Blue": setTimeout("DRTcompare.tRedBlue_focus('Blue')",0); break;
  173. };
  174. };
  175. DRTcompare.Calculate_onClick = function ()
  176. {
  177. var r1 = ($("ul[name='r1']").attr("class") != "hide") ? 1 : 2;
  178. DRTcompare.hRedBlue_Value = "";
  179. if (r1 == 1) {
  180. var reditems = $("input[name='db']");
  181. for (var i = 0; i < reditems.length; i++) {
  182. if ($(reditems[i]).prop("checked"))
  183. DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value + $(reditems[i]).val().replace("\n", "").trim() + " ";
  184. }
  185. DRTcompare.hRedBlue_Value += "+";
  186. var blueitems = $("input[name='hdb']");
  187. for (var i = 0; i < blueitems.length; i++) {
  188. if ($(blueitems[i]).prop("checked"))
  189. DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value + $(blueitems[i]).val().replace("\n", "").trim() + " ";
  190. }
  191. } else {
  192. DRTcompare.hRedBlue_Value = $("textarea[class='textarea']").val();
  193. }
  194. if ((DRTcompare.hRedBlue_Value == "") || (DRTcompare.hRedBlue_Value == "+")) { alert(DRTcompare.AlertMsg["0001"]); return false; };
  195. if (DRTcompare.hRedBlue_Value.search(/[^0-9\+\r\n\ ]/g,"") >= 0) { alert(DRTcompare.AlertMsg["0002"]); return false; }
  196. DRTcompare.hRedBlue_Value += DRTcompare.Config[DRTcompare.BrowInfo + "Enter"];
  197. DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value.split(DRTcompare.Config[DRTcompare.BrowInfo + "Enter"]);
  198. for (var i = DRTcompare.hRedBlue_Value.length - 1; i >= 0; i--)
  199. {
  200. DRTcompare.hRedBlue_Value[i] = DRTcompare.hRedBlue_Value[i].trim();
  201. if (DRTcompare.hRedBlue_Value[i] != "")
  202. {
  203. DRTcompare.hRedBlue_Value[i] = DRTcompare.hRedBlue_Value[i].replace(/\ {2,}/gi," ");
  204. if (DRTcompare.hRedBlue_Value[i].indexOf("+") == -1) DRTcompare.hRedBlue_Value[i] += "+";
  205. DRTcompare.hRedBlue_Value[i] = DRTcompare.hRedBlue_Value[i].split("+");
  206. DRTcompare.hRedBlue_Value[i][0] += " ";
  207. DRTcompare.hRedBlue_Value[i][1] += " ";
  208. DRTcompare.hRedBlue_Value[i][0] = DRTcompare.hRedBlue_Value[i][0].split(" ");
  209. DRTcompare.hRedBlue_Value[i][1] = DRTcompare.hRedBlue_Value[i][1].split(" ");
  210. if (DRTcompare.hRedBlue_Value[i][0].length <= 6) { alert(DRTcompare.AlertMsg["0003"]); return false; }
  211. } else { DRTcompare.hRedBlue_Value = DRTcompare.hRedBlue_Value.slice(0,DRTcompare.hRedBlue_Value.length - 1); };
  212. };
  213. if (DRTcompare.hRedBlue_Value.length > DRTcompare.Config["batchMax"]) { alert(DRTcompare.AlertMsg["0021"]); return false; };
  214. for (var i = 0; i < DRTcompare.ResultList.length; i++) { DRTcompare.ResultList[i] = ""; };
  215. DRTcompare.Calculate_Start();
  216. };
  217. DRTcompare.Calculate_Start = function ()
  218. {
  219. var CountA,CountB;
  220. var historyA,historyB;
  221. var Zero,tmpArray;
  222. for (var i = 0; i < h2b.length; i++)
  223. {
  224. for (var j = 0; j < DRTcompare.hRedBlue_Value.length; j++)
  225. {
  226. historyA = "," + h2b[i][0] + ",";
  227. historyB = "," + h2b[i][1] + ",";
  228. tmpArray = "";
  229. CountA = DRTcompare.Calculate_Count(historyA,DRTcompare.hRedBlue_Value[j][0]);
  230. CountB = DRTcompare.Calculate_Count(historyB,DRTcompare.hRedBlue_Value[j][1]);
  231. if (CountA > 0) historyA = DRTcompare.Calculate_AddHTML(historyA,DRTcompare.hRedBlue_Value[j][0],"red");
  232. if (CountB > 0) historyB = DRTcompare.Calculate_AddHTML(historyB,DRTcompare.hRedBlue_Value[j][1],"blue");
  233. numZero = DRTcompare.Calculate_Zero(CountA,CountB);
  234. historyA = historyA.substring(1,historyA.length - 1).split(",");
  235. historyB = historyB.substring(1,historyB.length - 1).split(",");
  236. tmpArray = historyA + "+" + historyB + "+" + h2b[i][2] + "+" + i + "+" + j;
  237. DRTcompare.ResultList[numZero] += tmpArray + "||";
  238. };
  239. };
  240. var obj;
  241. for (var i = 0; i < DRTcompare.ResultList.length; i++)
  242. {
  243. DRTcompare.ResultList[i] = DRTcompare.ResultList[i].split("||");
  244. document.getElementById("resultx_" + i).innerHTML = DRTcompare.ResultList[i].length - 1;
  245. var info = DRTcompare.Result_Start(i);
  246. document.getElementById("show_" + i).innerHTML = info;
  247. };
  248. $('.hidden').hide();
  249. $(".list").click(function () {
  250. $(this).next().siblings(".list").find("a").attr('class', '');
  251. $(this).next().slideDown();
  252. $(this).find("a").attr('class', 'blue');
  253. $(this).next().siblings(".hidden").slideUp();
  254. });
  255. document.getElementById("result1").style.display = "";
  256. };
  257. DRTcompare.Calculate_Count = function (history,Array)
  258. {
  259. var tmpCount = 0;
  260. for (var i = 0; i < Array.length - 1; i++)
  261. {
  262. if (history.indexOf("," + Array[i] + ",") != -1) tmpCount++;
  263. };
  264. return tmpCount;
  265. };
  266. DRTcompare.Calculate_AddHTML = function (history,Array,type)
  267. {
  268. var tmpHistory = history;
  269. for (var i = 0; i < Array.length - 1; i++)
  270. {
  271. tmpHistory = tmpHistory.replace("," + Array[i] + ",",",<span class=" + ((type == "blue") ? "wblue" : "wred") + ">" + Array[i] + "</span>,");
  272. };
  273. return tmpHistory;
  274. };
  275. DRTcompare.Calculate_Zero = function (CountA,CountB)
  276. {
  277. var tmpZ;
  278. for (var i = 0; i < DRTcompare.Config["List"].length; i++)
  279. {
  280. if ((DRTcompare.Config["List"][i][0] == CountA) && (DRTcompare.Config["List"][i][2] == CountB))
  281. {
  282. tmpZ = i;
  283. break;
  284. };
  285. };
  286. return tmpZ;
  287. };
  288. DRTcompare.Result_onLoad = function ()
  289. {
  290. DRTcompare.ResultList = new Array();
  291. var o = "";
  292. o += DRTcompare.Result_onLoad2(0,13,"result11");
  293. document.getElementById("result1").innerHTML = o;
  294. };
  295. DRTcompare.Result_onLoad2 = function (start,end,idname)
  296. {
  297. var o = "";
  298. o += "<div id='" + idname + "' class='gs-follow'>";
  299. for (var i = start; i <= end; i++)
  300. {
  301. DRTcompare.ResultList[i] = "";
  302. o += "<div class='list'><span>" + DRTcompare.AlertMsg["0004"] + " ";
  303. o += DRTcompare.Config["List"][i][0] + " " + DRTcompare.AlertMsg["0005"] + " ";
  304. if (DRTcompare.Config["List"][i][2] == "1") o += DRTcompare.AlertMsg["0016"] + " 1" + " " + DRTcompare.AlertMsg["0006"] + " ";
  305. o += "<span id='resultx_" + i + "' class='Tresult2'></span>" + "&nbsp;" + DRTcompare.AlertMsg["0007"];
  306. o += "<a class=''>" + DRTcompare.AlertMsg["0008"] + "</a></span></div>";
  307. o += "<div class='hidden' id='show_" + i + "'></div>";
  308. };
  309. o += "</div>";
  310. return o;
  311. }
  312. DRTcompare.Result_ExArea = function ()
  313. {
  314. var exArea = window.prompt(DRTcompare.AlertMsg["0009"],DRTcompare.Config["exArea"]);
  315. if (Math.round(exArea) == NaN) exArea = 0;
  316. if (Math.round(exArea) >= 10) { alert(DRTcompare.AlertMsg["0011"]); return false; };
  317. DRTcompare.Config["exArea"] = Math.round(exArea);
  318. DRTcompare.Result_Show();
  319. };
  320. DRTcompare.Result_Start = function (numZero) { DRTcompare.CurrNumZero = numZero; var info = DRTcompare.Result_Show(); return info; };
  321. DRTcompare.Result_Show = function () {
  322. var o = "<ul class='hidden1 dlt'>";
  323. var numZero = DRTcompare.CurrNumZero;
  324. if (DRTcompare.ResultList[numZero] != "") {
  325. var r1 = ($("ul[name='r1']").attr("class") != "hide") ? 1 : 2;
  326. for (var i = 0; i < DRTcompare.ResultList[numZero].length - 1; i++) {
  327. DRTcompare.ResultList[numZero][i] = DRTcompare.ResultList[numZero][i].split("+");
  328. o += DRTcompare.ResultexList(DRTcompare.ResultList[numZero][i][3], "-");
  329. o += "<li class='list'>" + DRTcompare.AlertMsg["0017"] + DRTcompare.ResultList[numZero][i][2];
  330. o += DRTcompare.AlertMsg["0018"] + " " + DRTcompare.ResultList[numZero][i][0].split(",").join(" ");
  331. o += " + " + DRTcompare.ResultList[numZero][i][1].split(",").join(" ");
  332. o += "</li>";
  333. o += DRTcompare.ResultexList(DRTcompare.ResultList[numZero][i][3], "+");
  334. DRTcompare.ResultList[numZero][i] = DRTcompare.ResultList[numZero][i].join("+");
  335. };
  336. } else {
  337. o += DRTcompare.AlertMsg["0015"];
  338. };
  339. o += "</ul>";
  340. return o;
  341. };
  342. DRTcompare.ResultexList = function (historyID,type)
  343. {
  344. var startID,endID;
  345. historyID = Math.round(historyID);
  346. switch (type)
  347. {
  348. case "-": startID = historyID - DRTcompare.Config["exArea"]; endID = historyID - 1; break;
  349. case "+": startID = historyID + 1; endID = historyID + DRTcompare.Config["exArea"]; break;
  350. };
  351. if (startID < 0) startID = 0;
  352. if (endID >= h2b.length) endID = h2b.length - 1;
  353. var o = "";
  354. if (DRTcompare.Config["exArea"] > 0)
  355. {
  356. if (type == "-") o += "<div>";
  357. for (var i = startID; i <= endID; i++) {
  358. o += "<div class='list'>" + DRTcompare.AlertMsg["0017"] + "" + h2b[i][2];
  359. o += DRTcompare.AlertMsg["0018"] + " " + h2b[i][0].split(",").join(" ");
  360. o += " + " + h2b[i][1] + "</div>";
  361. };
  362. if (type == "+") o += "<div></div>";
  363. };
  364. return o;
  365. };
  366. DRTcompare.AlertMsg = {
  367. "0001": ("您选择或者输入的号码为空!"),
  368. "0002": ("批量对比数据列表中,出现非法的字符。"),
  369. "0003": ("选择的红球少于6个,查询过程不成立。"),
  370. "0004": ("开出过"),
  371. "0005": ("个红球"),
  372. "0006": ("个蓝球"),
  373. "0007": ("次"),
  374. "0008": ("显示历史开奖"),
  375. "0009": ("请输入您要扩展查询对比结果上下多少期的数值。例如:要扩展查询3期就输入数字“3”。如您输入数字“0”,就表示不扩展查询。"),
  376. "0010": ("扩展对比结果上下n期"),
  377. "0011": ("您选择的扩展查询范围大于10期"),
  378. "0012": ("开出过"),
  379. "0013": ("个红球与"),
  380. "0014": ("个蓝球"),
  381. "0015": ("暂时没有对比成功的数据"),
  382. "0016": ("与"),
  383. "0017": ("第"),
  384. "0018": ("期"),
  385. "0019": ("注"),
  386. "0020": ("显示≤3个红球的结果"),
  387. "0021": ("您输入的批量数据超出最大限度!!")
  388. };
  389. Number.prototype.addzero = function (length) { var tmpStr = ""; var tmpNum = this.toString(); for (var i = 0; i < length - tmpNum.length; i++) { tmpStr += "0"; }; return tmpStr + tmpNum; };
  390. String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g,""); }
  391. window.onload = DRTcompare.Window_onLoad;
  392. document.forms["frm"].elements["r1"][0].onclick = function () { DRTcompare.r_onclick(this); };
  393. document.forms["frm"].elements["r1"][1].onclick = function () { DRTcompare.r_onclick(this); };
  394. //document.getElementById("version").innerHTML = unescape("%u5DE5%u5177%u7248%u672C%3A%203.0");