김한준

API 사용 안하도록 기능 수정

Showing 1 changed file with 231 additions and 75 deletions
1 -var data;
2 -
3 -var acum_list = new Array(); // 번호별 누적횟수를 구하기 위한 배열
4 -for (i=0;i<45;i++){
5 - acum_list[i]=0;
6 -}
7 -
8 -
9 -//회차별 당첨번호를 가지고 오기 위하여 테이블을 만들고 data를 가지고 오기 위해 주소를 변경하는 함수
10 -$(document).ready(function () {
11 - var dropdown = $('#selectBox');
12 - var form = $('#form');
13 - var result = $('#result');
14 - var a2=$('#a1');
15 - for (i = 1; i < 862; i++) {
16 - var option = $('<option>');
17 - option.val(i).text(i+'회차');
18 - dropdown.append(option);
19 - }
20 - form.on('submit', function (event) {
21 - event.preventDefault();
22 - if (!dropdown.val()) {
23 - alert('뭔가 선택을 하세요.');
24 - dropdown.focus();
25 - } else {
26 - //회차별로 api에서 당첨번호를 끌어오기 위한 문자열 주소 조합
27 - document.getElementById("lotto_api_src").src="http://lotto.kaisyu.com/api?method=get&gno="+dropdown.val()+";callback=loadlot";
28 - //api에서 data를 끌어올때 최초 1회만 끌어올수 있는 문제를 해결하기 위한 방안
29 - var lotto_parent = document.getElementById("lotto_api_data");
30 - var lotto_child=document.getElementById("lotto_api_src");
31 - lotto_child.remove();
32 - child_node=document.createElement('script');
33 - child_node.id="lotto_api_src";
34 - lotto_parent.append(child_node);
35 -
36 -
37 -
38 - }
39 - });
40 -});
41 -
42 1
43 //로또 번호 생성 2 //로또 번호 생성
44 function dice(n, s, b) { 3 function dice(n, s, b) {
...@@ -52,13 +11,12 @@ function dice(n, s, b) { ...@@ -52,13 +11,12 @@ function dice(n, s, b) {
52 //로또 번호를 생성하고 번호별로 style을 주며 당첨등을 총괄하기 위한 함수 11 //로또 번호를 생성하고 번호별로 style을 주며 당첨등을 총괄하기 위한 함수
53 function count() { 12 function count() {
54 // console.log($('#inputnum').val()); 13 // console.log($('#inputnum').val());
55 -
56 var numberSort = function(a, b) { 14 var numberSort = function(a, b) {
57 return a[0] - b[0]; 15 return a[0] - b[0];
58 }; 16 };
59 - $('#lottotable').html(""); //초기화 17 +
60 - $('#accumulate_table').html(""); //초기화 18 + resets2();
61 - $('#recom_table').html(""); 19 +
62 var win1 = 0; 20 var win1 = 0;
63 var win2 = 0; 21 var win2 = 0;
64 var win3 = 0; 22 var win3 = 0;
...@@ -101,13 +59,13 @@ function count() { ...@@ -101,13 +59,13 @@ function count() {
101 59
102 // console.log("No." + (list_length) + ": " + val); 60 // console.log("No." + (list_length) + ": " + val);
103 for (m = 0; m < 6; m++) { 61 for (m = 0; m < 6; m++) {
104 - if (val[j][0] == data.nums[m]) { 62 + if (val[j][0] == data[m]) {
105 val[j][1] = 1; 63 val[j][1] = 1;
106 match++; 64 match++;
107 } 65 }
108 } 66 }
109 // console.log("No." + (list_length) + ": " + val); 67 // console.log("No." + (list_length) + ": " + val);
110 - if (val[j][0] == data.bnum) { 68 + if (val[j][0] == data[6]) {
111 val[j][1] = 2; 69 val[j][1] = 2;
112 match_b = 1; 70 match_b = 1;
113 } 71 }
...@@ -197,36 +155,33 @@ function count() { ...@@ -197,36 +155,33 @@ function count() {
197 } 155 }
198 156
199 //api로부터 당첨 data를 끌어오기 위한 함수 157 //api로부터 당첨 data를 끌어오기 위한 함수
200 -function loadlot(a) { 158 +function loadlot(num) {
201 - $("#lottok").html('제 ' + a.gno + '회차 당첨 결과(' + a.gdate + ')'); // + '<br/>' + 159 + $("#lottok").html('제 ' + (861-num+1) + '회차 당첨 결과(' + lotto_num[num-1][7] + ')'); // + '<br/>' +
202 //a.nums + a.bnum; 160 //a.nums + a.bnum;
203 - a.nums[6] = a.bnum;
204 for (i = 0; i < 7; i++) { 161 for (i = 0; i < 7; i++) {
205 - $('#output' + i).text(a.nums[i]); 162 + $('#output' + i).text(lotto_num[num-1][i]);
206 } 163 }
207 for (i = 0; i < 7; i++) { 164 for (i = 0; i < 7; i++) {
208 - if (a.nums[i] <= 10) { 165 + if (lotto_num[num-1][i] <= 10) {
209 - $('#output' + i).addClass("c1"); 166 + $('#output' + i).addClass("output c1");
210 - } else if (a.nums[i] <= 20) { 167 + } else if (lotto_num[num-1][i] <= 20) {
211 - $('#output' + i).addClass("c2"); 168 + $('#output' + i).addClass("output c2");
212 - } else if (a.nums[i] <= 30) { 169 + } else if (lotto_num[num-1][i] <= 30) {
213 - $('#output' + i).addClass("c3"); 170 + $('#output' + i).addClass("output c3");
214 - } else if (a.nums[i] <= 40) { 171 + } else if (lotto_num[num-1][i] <= 40) {
215 - $('#output' + i).addClass("c4"); 172 + $('#output' + i).addClass("output c4");
216 } else { 173 } else {
217 - $('#output' + i).addClass("c5"); 174 + $('#output' + i).addClass("output c5");
218 } 175 }
219 } 176 }
220 177
221 - data = a; 178 +
179 + data = lotto_num[num-1];
222 } 180 }
223 181
224 //생성한 번호별 누적횟수와 추천번호를 위한 함수 182 //생성한 번호별 누적횟수와 추천번호를 위한 함수
225 function accumulate_number() { 183 function accumulate_number() {
226 - 184 + resets2();
227 - $('#lottotable').html(""); //초기화
228 - $('#accumulate_table').html(""); //초기화
229 - $('#recom_table').html(""); //초기화
230 185
231 var temp= JSON.parse(JSON.stringify( acum_list )); 186 var temp= JSON.parse(JSON.stringify( acum_list ));
232 var out_temp= JSON.parse(JSON.stringify( acum_list )); 187 var out_temp= JSON.parse(JSON.stringify( acum_list ));
...@@ -264,11 +219,6 @@ function accumulate_number() { ...@@ -264,11 +219,6 @@ function accumulate_number() {
264 219
265 220
266 221
267 - var numberSort = function(a, b) {
268 - return a[0] - b[0];
269 - };
270 -
271 -
272 222
273 223
274 224
...@@ -300,13 +250,219 @@ function accumulate_number() { ...@@ -300,13 +250,219 @@ function accumulate_number() {
300 250
301 //현재 보이는 화면을 초기화함과 동시에 누적번호 또한 초기화 하기 위한 함수 251 //현재 보이는 화면을 초기화함과 동시에 누적번호 또한 초기화 하기 위한 함수
302 function resets() { 252 function resets() {
303 - $('#lottotable').html(""); //초기화 253 + resets2();
304 - $('#accumulate_table').html(""); //초기화
305 - $('#recom_table').html(""); //초기화
306 - $('#stats').html(""); //초기화
307 -
308 for (i=0;i<45;i++){ 254 for (i=0;i<45;i++){
309 acum_list[i]=0; 255 acum_list[i]=0;
310 } 256 }
257 +}
258 +
259 +function resets2() {
260 + $('#lottotable').html("");
261 + $('#accumulate_table').html("");
262 + $('#recom_table').html("");
263 + $('#stats').html("");
264 + $('#patten_table').html("");
265 + $('#patten_recom_table').html("");
266 + $('#chart_div_1').html("");
267 + $('#chart_div_2').html("");
268 + $('#chart_div_3').html("");
269 + $('#chart_div_4').html("");
270 +
271 +}
272 +
273 +
274 +function patten() {
275 + resets2()
276 +
277 + var temp= JSON.parse(JSON.stringify( nujuk ));
278 + var out_temp= JSON.parse(JSON.stringify( nujuk ));
279 +
280 + temp.sort(function(a,b){return a-b});
281 +
282 +
283 +
284 + $('#patten_table').append('<section id="patten_section" class="shadow"></scetion>');
285 + for(i=44;i>=0;i--) {
286 + for(j=0;j<45;j++){
287 + if(temp[i]==out_temp[j]){
288 + if(j<9)
289 + $('#patten_section').append('<div class="output c1">'+(j+1)+'</div>'+'<progress value="' + temp[i] + '" max="' + (temp[44]+20)+ '"></progress>'+' '+temp[i]);
290 + else if(j<19)
291 + $('#patten_section').append('<div class="output c2">'+(j+1)+'</div>'+'<progress value="' + temp[i] + '" max="' + (temp[44]+20)+ '"></progress>'+' '+temp[i]);
292 + else if(j<29)
293 + $('#patten_section').append('<div class="output c3">'+(j+1)+'</div>'+'<progress value="' + temp[i] + '" max="' + (temp[44]+20)+ '"></progress>'+' '+temp[i]);
294 + else if(j<39)
295 + $('#patten_section').append('<div class="output c4">'+(j+1)+'</div>'+'<progress value="' + temp[i] + '" max="' + (temp[44]+20)+ '"></progress>'+' '+temp[i]);
296 + else
297 + $('#patten_section').append('<div class="output c5">'+(j+1)+'</div>'+'<progress value="' + temp[i] + '" max="' + (temp[44]+20)+ '"></progress>'+' '+temp[i]);
298 + out_temp[j]=null;
299 + break;
300 + }
301 + }
302 + }
303 +
304 +
305 +
306 +
307 +
308 +
309 +
310 +}
311 +
312 +function graph_accum() {
313 + resets2();
314 +
315 + var data = google.visualization.arrayToDataTable([
316 + ['패턴요소', '수치'],
317 + ['홀0:짝6', 9],
318 + ['홀1:짝5', 58],
319 + ['홀2:짝4', 192],
320 + ['홀3:짝3', 299],
321 + ['홀4:짝2', 223],
322 + ['홀5:짝1', 65],
323 + ['홀0:짝6', 15]
324 + ]);
325 + var options = {
326 + title : '역대 홀수 짝수 비율',
327 + vAxis: {title: '출현횟수'},
328 + hAxis: {title: '1회~861회'},
329 + seriesType: 'bars',
330 + series: {5: {type: 'line'}},
331 + backgroundColor : 'ivory'
332 + };
333 +
334 + var data2 = google.visualization.arrayToDataTable([
335 + ['패턴요소', '수치'],
336 + ['저0:고6', 9],
337 + ['저1:고5', 79],
338 + ['저2:고4', 216],
339 + ['저3:고3', 287],
340 + ['저4:고2', 193],
341 + ['저5:고1', 64],
342 + ['저0:고6', 13]
343 + ]);
344 + var options2 = {
345 + title : '역대 저&고 비율',
346 + vAxis: {title: '출현횟수'},
347 + hAxis: {title: '1회~861회'},
348 + seriesType: 'bars',
349 + series: {5: {type: 'line'}},
350 + backgroundColor : 'ivory'
351 +
352 + };
353 +
354 + var data3 = google.visualization.arrayToDataTable([
355 + ['패턴요소', '수치'],
356 + ['0개', 63],
357 + ['1개', 234],
358 + ['2개', 289],
359 + ['3개', 212],
360 + ['4개', 53],
361 + ['5개', 8],
362 + ['6개', 2]
363 + ]);
364 + var options3 = {
365 + title : '역대 3의 배수 비율',
366 + vAxis: {title: '출현횟수'},
367 + hAxis: {title: '1회~861회'},
368 + seriesType: 'bars',
369 + series: {5: {type: 'line'}},
370 + backgroundColor : 'ivory'
371 + };
372 +
373 + var data4 = google.visualization.arrayToDataTable([
374 + ['패턴요소', '수치'],
375 + ['0~100', 106],
376 + ['101~120', 140],
377 + ['121~140', 214],
378 + ['141~160', 180],
379 + ['161~180', 151],
380 + ['181~260', 70]
381 + ]);
382 + var options4 = {
383 + title : '역대 번호 총합 비율',
384 + vAxis: {title: '출현횟수'},
385 + hAxis: {title: '1회~861회'},
386 + seriesType: 'bars',
387 + series: {5: {type: 'line'}},
388 + backgroundColor : 'ivory'
389 +
390 + };
391 +
392 +
393 + while(true){
394 +
395 + var val2=[0,0,0,0,0,0];
396 +
397 + for (j = 0; j < 6; j++) {
398 +
399 + function roll(n) {
400 + if (j == 0) {
401 + val2[j] = n;
402 + } else {
403 + for (l = 0; l < j; l++) {
404 + // console.log(n);
405 + if (n == val2[l]) {
406 + roll(dice(1, 45, 0));
407 + } else {
408 + val2[j] = n;
409 + }
410 + }
411 + }
412 + }
413 + roll(dice(1, 45, 0));
414 + }
415 +
416 + val2.sort(function(a,b){return a-b});
417 +
418 + var check_goju=0;
419 + var check_sum=0;
420 + var check_holjjak=0;
421 + var check_three_mul=0;
422 + for(i=0;i<6;i++){
423 + check_sum+=val2[i];
424 + if(val2[i]>22)
425 + check_goju+=1;
426 + if(val2[i]%2==0)
427 + check_holjjak+=1;
428 + if(val2[i]%3==0)
429 + check_three_mul+=1;
430 + }
431 +
432 + if((check_sum<=160 && check_sum>=121) && (check_goju==3 || check_goju==4) && ( check_holjjak ==2 || check_holjjak==3) && ( check_three_mul==1 || check_three_mul==2))
433 + break;
434 + }
435 +
436 + $('#patten_recom_table').append('<section id="patten_recom_section" class="shadow"></scetion>');
437 +
438 + $("#patten_recom_section").append('추천 로또 번호(패턴 분석)'+'</font>'+'<br>'+'<br>');
439 +
440 + for (i = 0; i < 6; i++) {
441 + if (val2[i] <= 10) {
442 + $('#patten_recom_section').append('<div class="output c1">'+val2[i]+'</div>');
443 + } else if (val2[i] <= 20) {
444 + $('#patten_recom_section').append('<div class="output c2">'+val2[i]+'</div>');
445 + } else if (val2[i] <= 30) {
446 + $('#patten_recom_section').append('<div class="output c3">'+val2[i]+'</div>');
447 + } else if (val2[i] <= 40) {
448 + $('#patten_recom_section').append('<div class="output c4">'+val2[i]+'</div>');
449 + } else {
450 + $('#patten_recom_section').append('<div class="output c5">'+val2[i]+'</div>');
451 + }
452 + }
453 +
454 +
455 +
456 + var chart = new google.visualization.ComboChart(document.getElementById('chart_div_1'));
457 + chart.draw(data, options);
458 + var chart = new google.visualization.ComboChart(document.getElementById('chart_div_2'));
459 + chart.draw(data2, options2);
460 + var chart = new google.visualization.ComboChart(document.getElementById('chart_div_3'));
461 + chart.draw(data3, options3);
462 + var chart = new google.visualization.ComboChart(document.getElementById('chart_div_4'));
463 + chart.draw(data4, options4);
464 +
311 465
312 } 466 }
467 +
468 +
......