-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1414 lines (1061 loc) · 38.5 KB
/
index.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<title>shudu</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
tr:{
border: 1px black solid
}
table{
width:520px;
border-collapse:collapse;
}
td{
width: 50px;
height: 50px;
}
table input{
width:50px;
height: 30px;
display: none;
}
.boundary-left {
border-left: 3px #000000 solid;
}
.boundary-bottom {
border-bottom: 3px #000000 solid;
}
.txt{
}
.candidate {
display: inline;
padding: .2em .6em .3em;
font-size: 75%;
font-weight: 700;
line-height: 1;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
background-color: #5bc0de;
}
</style>
<script src="https://code.jquery.com/jquery-2.2.2.min.js" integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" crossorigin="anonymous"></script>
</head>
<body>
<div style="float:left;margin-top:0px;text-align:center">
<h2>Area</h2>
<table border="1px" width="500px" height="500px">
<tr line="0">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr line="1">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr class="boundary-bottom" line="2">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr boundary-top line="3">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr line="4">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr class="boundary-bottom" line="5">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr line="6">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr line="7">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
<tr line="8">
<td num="0" align="center"><span class="txt"></span><input type="text"></td>
<td num="1" align="center"><span class="txt"></span><input type="text"></td>
<td num="2" align="center"><span class="txt"></span><input type="text"></td>
<td num="3" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="4" align="center"><span class="txt"></span><input type="text"></td>
<td num="5" align="center"><span class="txt"></span><input type="text"></td>
<td num="6" class="boundary-left" align="center"><span class="txt"></span><input type="text"></td>
<td num="7" align="center"><span class="txt"></span><input type="text"></td>
<td num="8" align="center"><span class="txt"></span><input type="text"></td>
</tr>
</table>
</div>
<div style="float:left;width:800px;height:600px;margin:3px;">
<h3 style="text-align:center">Assumption image</h3>
<canvas id="canvassample" width="740" height="540"></canvas>
</div>
<div style="clear:both"></div>
<div>
<p>假设级别<span id="level"></span></p>
</div>
<div>
<p>
<button class="level">level1</button>
<button class="level">level2</button>
<button class="level">level3</button>
<button class="level">level4</button>
<button class="breaklevel">break assumption</button>
</p>
</div>
<div>
<p>
<button class="levelStart">show level1 start point</button>
<button class="levelPrev">show level1 prev point</button>
<button class="levelNext">show level1 next point</button>
<button class="levelEnd">show level1 end point</button>
<button class="levelHide">hide level1 point</button>
</p>
<p>
<input type="text">
<button class="addCandidate">add candidate</button>
<button class="showCandidate">show candidate</button>
<button class="hideCandidate">hide candidate</button>
<button class="useCandidate">use current candidate</button>
<button class="deleteCandidate">delete current candidate</button>
</p>
</div>
<div>
<p>
<button class="levelStart">show level2 start point</button>
<button class="levelPrev">show level2 prev point</button>
<button class="levelNext">show level2 next point</button>
<button class="levelEnd">show level2 end point</button>
<button class="levelHide">hide level2 point</button>
</p>
<p>
<input type="text">
<button class="addCandidate">add candidate</button>
<button class="showCandidate">show candidate</button>
<button class="hideCandidate">hide candidate</button>
<button class="useCandidate">use current candidate</button>
<button class="deleteCandidate">delete current candidate</button>
</p>
</div>
<div>
<p>
<button class="levelStart">show level3 start point</button>
<button class="levelPrev">show level3 prev point</button>
<button class="levelNext">show level3 next point</button>
<button class="levelEnd">show level3 end point</button>
<button class="levelHide">hide level3 point</button>
</p>
<p>
<input type="text">
<button class="addCandidate">add candidate</button>
<button class="showCandidate">show candidate</button>
<button class="hideCandidate">hide candidate</button>
<button class="useCandidate">use current candidate</button>
<button class="deleteCandidate">delete current candidate</button>
</p>
</div>
<div>
<p>
<button class="levelStart">show level4 start point</button>
<button class="levelPrev">show level4 prev point</button>
<button class="levelNext">show level4 next point</button>
<button class="levelEnd">show level4 end point</button>
<button class="levelHide">hide level4 point</button>
</p>
<p>
<input type="text">
<button class="addCandidate">add candidate</button>
<button class="showCandidate">show candidate</button>
<button class="hideCandidate">hide candidate</button>
<button class="useCandidate">use current candidate</button>
<button class="deleteCandidate">delete current candidate</button>
</p>
</div>
<div>
<p>
<button class="hidelevelStart">hide all level start point</button>
<button class="hidelevelEnd">hide all level end point</button>
</p>
</div>
</body>
<script type="text/javascript">
const level1CanvasColor = "#4CA9FC"
const level2CanvasColor = "#0047ab"
const level3CanvasColor = "#FF00AB"
const level4CanvasColor = "#000080"
const level1CanvasX = 50
const level1CanvasY = 10
const level1CanvasW = 850
const level1CanvasH = 80
const level2CanvasX = 50
const level2CanvasY = 140
const level2CanvasW = 850
const level2CanvasH = 80
const level3CanvasX = 50
const level3CanvasY = 270
const level3CanvasW = 850
const level3CanvasH = 80
const level4CanvasX = 50
const level4CanvasY = 400
const level4CanvasW = 850
const level4CanvasH = 80
//画出level1的长方形
function drawLevel1CanvasBackGround(){
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
//level1 area
ctx.fillStyle = "#00FA9A";
ctx.fillRect(level1CanvasX, level1CanvasY, level1CanvasW, level1CanvasH);
}
//画出level2的长方形
function drawLevel2CanvasBackGround(){
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
//level1 area
ctx.fillStyle = "#9ACD32";
ctx.fillRect(level2CanvasX, level2CanvasY, level2CanvasW, level2CanvasH);
}
//画出level3的长方形
function drawLevel3CanvasBackGround(){
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
//level1 area
ctx.fillStyle = "#FFA500";
ctx.fillRect(level3CanvasX, level3CanvasY, level3CanvasW, level3CanvasH);
}
//画出level4的长方形
function drawLevel4CanvasBackGround(){
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
//level1 area
ctx.fillStyle = "#9ACD32";
ctx.fillRect(level4CanvasX, level4CanvasY, level4CanvasW, level4CanvasH);
}
function showLevelCandidate(arr,_n){
if(_n==1){
var h = 70;
}else if(_n==2){
var h = 200;
}else if(_n==3){
var h = 330;
}else if(_n==4){
var h = 460;
}else{
return false;
}
for(var i=0;i<arr.length;i++){
addText(arr[i],0,i,h,_n)
}
}
function showLevelUsingCandidate(text,_n){
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
if(_n==1){
var h = 70;
}else if(_n==2){
var h = 200;
}else if(_n==3){
var h = 330;
}else if(_n==4){
var h = 460;
}else{
return false;
}
//清除画布
ctx.clearRect(eval("level"+_n+"CanvasX"),eval("level"+_n+"CanvasY"),eval("level"+_n+"CanvasW"),eval("level"+_n+"CanvasH"))
eval("drawLevel"+_n+"CanvasBackGround()")
addText(text,1,-1,h,_n)
showLevelCandidate(levelCandidateArr[_n-1],_n)
}
function addText(text,fill,i,h,_n){
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
ctx.font="50px Arial";
if(fill){
ctx.fillStyle = eval("level"+_n+"CanvasColor")
ctx.fillText(text,380,h);
}else{
ctx.strokeStyle = eval("level"+_n+"CanvasColor")
if(i%2==0){
ctx.strokeText(text,380+Math.ceil((i+1)/2)*90,h);
}else{
ctx.strokeText(text,380-Math.ceil((i+1)/2)*90,h);
}
}
}
</script>
<script type="text/javascript">
var defaultColor = "blue"
var defaultBackColor = "white"
var orderLevelStartArr = [{},{},{},{}];//In the array there exists every level's first element
var hightLightStatusArr = [-1,-1,-1,-1];//In the array there exists the index of the current highlight cell for each level
var levelCandidateArr = [[],[],[],[]] //In the array there exists the candidate of each level
const LEVEL1COLOR = "#ffffff"
const LEVEL1BACKCOLOR = "#00FA9A"
const LEVEL2COLOR = "#ffffff"
const LEVEL2BACKCOLOR = "#9ACD32"
const LEVEL3COLOR = "#ffffff"
const LEVEL3BACKCOLOR = "#FFA500"
const LEVEL4COLOR = "#ffffff"
const LEVEL4BACKCOLOR = "#000080"
const CANDIDATECOLOR = "#ffffff"
const CANDIDATEBACKCOLOR = "#7f7f7f"
$("td").click(function(){
$(this).find("input").show()
$(this).find(".txt").hide()
var txt = $(this).find(".txt").html()
$(this).find("input").val(dragNumFromtext(txt))
$(this).find("input").focus()
})
$("table input").change(function(){
var txt = $(this).val()
if(/[1-9]/.exec(txt) || !txt){
}else{
return false;
}
addIntoLevelArr($(this).parents("tr").index(),$(this).parents("td").index(),txt)
addIntoLevelOrderArr($(this).parents("tr").index(),$(this).parents("td").index(),txt)
$(this).siblings(".txt").text(textManagerByLevel(txt,window.levelInt))
$(this).siblings(".txt").show()
$(this).hide()
$(this).val("")
showLevelUsingCandidate(eval("level"+(window.levelInt+1)+"OrderArr")[0]["text"],(window.levelInt+1))
})
$("table input").blur(function(){
$(this).hide()
$(this).siblings(".txt").show()
})
$(".level").click(function(){
var levelInt = parseInt($(this).index())
if(!checklevelJump(levelInt)) return false;
window.levelInt = levelInt
showLevel(levelInt)
})
$(".levelStart").click(function(){
var levelInt = parseInt($(".levelStart").index(this))
//var i = orderLevelStartArr[levelInt]["i"]
//var j = orderLevelStartArr[levelInt]["j"]
if(!eval("level"+(levelInt+1)+"OrderArr")[0]){
return false;
}
//var i = eval("level"+(levelInt+1)+"OrderArr")[0]["i"];
//var j = eval("level"+(levelInt+1)+"OrderArr")[0]["j"];
var i = findCurrentFirstOrderCell(levelInt)["i"]
var j = findCurrentFirstOrderCell(levelInt)["j"]
findElementByIJ(i,j).find(".txt").text(textManagerByLevel(eval("level"+(levelInt+1)+"OrderArr")[0]['text'],levelInt))
hightLightStatusArr[levelInt] = 0
if(parseInt(i)>=0 && parseInt(j)>=0 ){
showStartPoint(i,j,levelInt)
}
//去除其他的highLight
for(j=eval("level"+(levelInt+1)+"OrderArr").length - 1;j>0;j--){
var obj = eval("level"+(levelInt+1)+"OrderArr")[j];
hideHightLightByIJ(obj["i"],obj["j"])
}
})
$(".levelEnd").click(function(){
var levelInt = parseInt($(".levelEnd").index(this))
if(!eval("level"+(levelInt+1)+"OrderArr").slice(-1)[0]){
return false;
}
hightLightStatusArr[levelInt] = eval("level"+(levelInt+1)+"OrderArr").length - 1
var i = eval("level"+(levelInt+1)+"OrderArr").slice(-1)[0]["i"];
var j = eval("level"+(levelInt+1)+"OrderArr").slice(-1)[0]["j"];
if(parseInt(i)>=0 && parseInt(j)>=0 ){
showStartPoint(i,j,levelInt)
}
for(var j=0;j<eval("level"+(levelInt+1)+"OrderArr").length - 1;j++){
var obj = eval("level"+(levelInt+1)+"OrderArr")[j];
hideHightLightByIJ(obj["i"],obj["j"])
}
})
$(".levelHide").click(function(){
var levelInt = parseInt($(".levelHide").index(this))
var arr = ["level1OrderArr","level2OrderArr","level3OrderArr","level4OrderArr"]
if(eval(arr[levelInt]).length == 0) return false;
if(hightLightStatusArr[levelInt] == -1) return false;
var _i = eval(arr[levelInt])[hightLightStatusArr[levelInt]]["i"]
var _j = eval(arr[levelInt])[hightLightStatusArr[levelInt]]["j"]
hideHightLightByIJ(_i,_j)
hightLightStatusArr[levelInt] = -1
})
$(".levelNext").click(function(){
var levelNext = parseInt($(".levelNext").index(this))
var _k = hightLightStatusArr[levelNext]
if(eval("level"+(levelNext+1)+"OrderArr").length==0){
return false;
}
//找到最后一个点时就不往后面找了
if(_k == (eval("level"+(levelNext+1)+"OrderArr").length-1)){
return false;
}
//去除前面一格的高亮
if(_k>-1){
var _i = eval("level"+(levelNext+1)+"OrderArr")[_k]["i"];
var _j = eval("level"+(levelNext+1)+"OrderArr")[_k]["j"];
hideHightLightByIJ(_i,_j)
}
//显示后面一格的高亮
var k = hightLightStatusArr[levelNext] + 1
if(!eval("level"+(levelNext+1)+"OrderArr")[k]){
return false;
}
var i = eval("level"+(levelNext+1)+"OrderArr")[k]["i"];
var j = eval("level"+(levelNext+1)+"OrderArr")[k]["j"];
showStartPoint(i,j,levelNext)
hightLightStatusArr[levelNext] += 1
})
$(".levelPrev").click(function(){
var levelPrev = parseInt($(".levelPrev").index(this))
var _k = hightLightStatusArr[levelPrev]
if(eval("level"+(levelPrev+1)+"OrderArr").length==0){
return false;
}
//找到第一个点时就不能往前找了
if(_k == 0){
return false;
}
//去除后面一格的高亮
if(_k>-1){
var _i = eval("level"+(levelPrev+1)+"OrderArr")[_k]["i"];
var _j = eval("level"+(levelPrev+1)+"OrderArr")[_k]["j"];
hideHightLightByIJ(_i,_j)
}
//显示前面一格的高亮
var k = hightLightStatusArr[levelPrev] - 1
if(!eval("level"+(levelPrev+1)+"OrderArr")[k]){
return false;
}
var i = eval("level"+(levelPrev+1)+"OrderArr")[k]["i"];
var j = eval("level"+(levelPrev+1)+"OrderArr")[k]["j"];
showStartPoint(i,j,levelPrev)
hightLightStatusArr[levelPrev] -= 1
})
$(".addCandidate").click(function(){
var arr = ["level1OrderArr","level2OrderArr","level3OrderArr","level4OrderArr"]
var levelCandidate = $(".addCandidate").index(this);
if(eval(arr[levelCandidate]).length<=0){
return false;
}
var val = $(this).prev("input").val()
if(!/[1-9]/.exec(val)){
return false;
}
//如果计划加入的candidate与该level的第一个数相同的话,则什么也不发生
if(firstFirstOrderNum(levelCandidate) == val){
return false;
}
if(!addIntoArrayWithOutDuplicate(val,levelCandidateArr[levelCandidate])) return false;
$(this).siblings(".showCandidate").after("<span class='candidate'>"+val+"</span> ")
$(".levelStart").eq(levelCandidate).click()
//清除表单
$(this).prev("input").val("")
showLevelCandidate(levelCandidateArr[levelCandidate],levelCandidate+1)
})
jQuery(document).on("click",".candidate",function(){
var levelCandidate = $(".addCandidate").index($(this).siblings(".addCandidate"));
var val = $(this).text()
//从某个数组中删除某个固定值
removeParticularElementFromArray(val,levelCandidateArr[levelCandidate])
//如果该级别下第一个单元格显示的是目前即将删除的candidate的话,那么将第一个单元格的内容重新设置为levelnOrderArr[0]['text']
if(/[1-9]/.exec(firstFirstOrderNum(levelCandidate))[0] == val){
recoverFirstCell(levelCandidate)
}
$(this).remove()
reDrawLevelCandidateImage(levelCandidate)
})
function reDrawLevelCandidateImage(n){
var levelCandidate = n
var l1 = document.getElementById('canvassample');
var ctx = l1.getContext('2d');
//清除画布,因为上面的数字有改变了
ctx.clearRect(eval("level"+(levelCandidate+1)+"CanvasX"),eval("level"+(levelCandidate+1)+"CanvasY"),eval("level"+(levelCandidate+1)+"CanvasW"),eval("level"+(levelCandidate+1)+"CanvasH"))
//重新画画布
eval("drawLevel"+(levelCandidate+1)+"CanvasBackGround()")
if(levelCandidateArr[levelCandidate].length<1 || eval("level"+(levelCandidate+1)+"OrderArr").length<1){
return false;
}
showLevelCandidate(levelCandidateArr[levelCandidate],(levelCandidate+1))
showLevelUsingCandidate(eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"],(levelCandidate+1))
}
$(".showCandidate").click(function(){
var levelCandidate = $(".showCandidate").index(this);
if(levelCandidateArr[levelCandidate].length<=0){
return false;
}
for(var i=0;i<levelCandidateArr[levelCandidate].length;i++){
//alert(levelCandidateArr[levelCandidate][i])
}
if(!eval("level"+(levelInt+1)+"OrderArr")[0]){
return false;
}
var i = findCurrentFirstOrderCell(levelCandidate)["i"]
var j = findCurrentFirstOrderCell(levelCandidate)["j"]
console.log(findElementByIJ(i,j))
var element = findElementByIJ(i,j)
element.css("background-color",CANDIDATEBACKCOLOR)
if(!/[1-9]/.exec(element.find(".txt").text())){
return false;
}
if(/[1-9]/.exec(element.find(".txt").text())[0] == eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"]){
//证明此时显示的是正常的第一个数据而不是candidate数据
element.find(".txt").text(levelCandidateArr[levelCandidate][0])
}else{
var index = findIndexFromArray(/[1-9]/.exec(element.find(".txt").text())[0],levelCandidateArr[levelCandidate])
element.find(".txt").text(levelCandidateArr[levelCandidate][(index+1)%levelCandidateArr[levelCandidate].length])
//证明此时显示的不是正常的第一个数据而是candidate数据,根据现有的candidate数据判断下一个candidate数据该怎样显示
}
})
$(".hideCandidate").click(function(){
var levelCandidate = $(".hideCandidate").index(this);
//如果没有设置该级别的假设的话则不触发
if(levelCandidateArr[levelCandidate].length<=0){
return false;
}
//如果该级别下第一个单元格没有数据的话则不触发
if(!eval("level"+(levelCandidate+1)+"OrderArr")[0]){
return false;
}
recoverFirstCell(levelCandidate)
// var i = findCurrentFirstOrderCell(levelCandidate)["i"]
// var j = findCurrentFirstOrderCell(levelCandidate)["j"]
// var element = findElementByIJ(i,j)
// if(!(eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"] == /[1-9]/.exec(element.find(".txt").text())[0])){
// //证明此时显示的不是正常的第一个数据而是candidate数据,根据现有的candidate数据判断下一个candidate数据该怎样显示
// element.find(".txt").text(textManagerByLevel(eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"],levelCandidate))
// element.css("background-color",eval("LEVEL"+(levelCandidate+1)+"BACKCOLOR"))
// element.find(".txt").css("color",eval("LEVEL"+(levelCandidate+1)+"COLOR"))
// }
})
function recoverFirstCell(level){
var i = findCurrentFirstOrderCell(level)["i"]
var j = findCurrentFirstOrderCell(level)["j"]
var element = findElementByIJ(i,j)
if(!(eval("level"+(level+1)+"OrderArr")[0]["text"] == /[1-9]/.exec(element.find(".txt").text())[0])){
//证明此时显示的不是正常的第一个数据而是candidate数据,根据现有的candidate数据判断下一个candidate数据该怎样显示
element.find(".txt").text(textManagerByLevel(eval("level"+(level+1)+"OrderArr")[0]["text"],level))
element.css("background-color",eval("LEVEL"+(level+1)+"BACKCOLOR"))
element.find(".txt").css("color",eval("LEVEL"+(level+1)+"COLOR"))
}
}
$(".deleteCandidate").click(function(){
var levelCandidate = $(".deleteCandidate").index(this);
//如果当前状态第一个单元格显示的不是candidate的话
if(firstFirstOrderNum(levelCandidate) == eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"]){
return false;
}
//删除标签中的candidate
var obj = $($(this).parents("p")[0]).find(".candidate")
for(var i=0;i<obj.length;i++){
if($(obj[i]).text()!=firstFirstOrderNum(levelCandidate)) continue;
$($(this).parents("p")[0]).find(".candidate").eq(i).click()
}
//再让希望删除的candidate从灰色方格中删除掉
for(var i=0;i<levelCandidateArr[levelCandidate].length;i++){
if(levelCandidateArr[levelCandidate][i] == firstFirstOrderNum(levelCandidate)){
levelCandidateArr[levelCandidate].splice(i,1)
}
}
//如果所有的candidate都被删掉了的话,那么就显示原始状态下的第一格
if(levelCandidateArr[levelCandidate].length<1){
$(".levelStart").eq(levelCandidate).click()
}
$(".showCandidate").eq(levelCandidate).click()
reDrawLevelCandidateImage(levelCandidate)
})
$(".useCandidate").click(function(){
var levelCandidate = $(".useCandidate").index(this);
if(levelCandidateArr[levelCandidate].length<=0){
return false;
}
//如果当前状态第一个单元格显示的不是candidate的话
if(firstFirstOrderNum(levelCandidate) == eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"]){
return false;
}
//先清除比当前级别大的级别的假设
if(!checklevelJump(levelCandidate)) return false;
window.levelInt = levelCandidate
//再把当前的candidate加到levelnOrderArr[0]['text']中
eval("level"+(levelCandidate+1)+"OrderArr")[0]["text"] = firstFirstOrderNum(levelCandidate)
//再把candidate[n]中的要用的对应的candidate删掉
var index = findIndexFromArray(firstFirstOrderNum(levelCandidate),levelCandidateArr[levelCandidate])
levelCandidateArr[levelCandidate].splice(index,1)
//点击显示当前级别第一格按钮
$(".levelStart").eq(levelCandidate).click()
//删除标签中的candidate
var obj = $($(this).parents("p")[0]).find(".candidate")
for(var i=0;i<obj.length;i++){
if($(obj[i]).text()!=firstFirstOrderNum(levelCandidate)) continue;
$($(this).parents("p")[0]).find(".candidate").eq(i).click()
}
//删除该级别除了第一个以外的其他假设
deleteCertainLevelExcepTheFirst(levelCandidate)
if(levelCandidate==0){
showLevelUsingCandidate(firstFirstOrderNum(levelCandidate),1)
}
})
function deleteCertainLevelExcepTheFirst(level){
//处理时间序列
//留首元素去掉之后的元素
eval("level"+(level+1)+"OrderArr").splice(1,eval("level"+(level+1)+"OrderArr").length-1)
//处理空间序列
var _i = eval("level"+(level+1)+"OrderArr")[0]["i"]
var _j = eval("level"+(level+1)+"OrderArr")[0]["j"]
var _txt = eval("level"+(level+1)+"OrderArr")[0]['text']
var tmpArr = eval("level"+(level+1)+"Arr")
tmpArr[_i][_j] = 0;
//去除次级别下空间区域中出了第一块方格以外的其他方格
clearCrossNum(tmpArr)
for(var i=0;i<eval("level"+(level+1)+"Arr").length;i++){
eval("level"+(level+1)+"Arr")[i] = new Array(9)
if(i==_i){
eval("level"+(level+1)+"Arr["+_i+"][_j]= "+_txt)
}
}
}
function findCurrentFirstOrderCell(level){
var i = eval("level"+(level+1)+"OrderArr")[0]["i"];
var j = eval("level"+(level+1)+"OrderArr")[0]["j"];
return {"i":i,"j":j}
}
function firstFirstOrderNum(level){
var obj = findCurrentFirstOrderCell(level)
var i = obj['i']
var j = obj['j']
var txt = findElementByIJ(i,j).find(".txt").text()
return /[1-9]/.exec(txt)[0]
}
//add a element into One-dimensional array
function addIntoArrayWithOutDuplicate(j,arr){
for(var i=0;i<arr.length;i++){
if(arr[i] == j) return false;
}
arr.push(j)
return true;
}
//remove a particular element from a array
function removeParticularElementFromArray(j,arr){
var index = findIndexFromArray(j,arr)
if(index<0) return false;
console.log("index is "+index)
arr.splice(index,1)
}
//find the index of a particular element in a array
function findIndexFromArray(j,arr){
for(var i=0;i<arr.length;i++){
if(arr[i] == j) return i;
}
return -1;
}
function hideHightLightByIJ(i,j){
findElementByIJ(i,j).css("background",defaultBackColor)
findElementByIJ(i,j).find(".txt").css("color",defaultColor)
}
$(".hidelevelStart").click(function(){
var arr = ["level1OrderArr","level2OrderArr","level3OrderArr","level4OrderArr"]
for(var i=0;i<arr.length;i++){
if(hightLightStatusArr[i]==0){
var _i = eval(arr[i])[0]["i"]
var _j = eval(arr[i])[0]["j"]
hideHightLightByIJ(_i,_j)
hightLightStatusArr[i] = -1
}
}
})
$(".hidelevelEnd").click(function(){
var arr = ["level1OrderArr","level2OrderArr","level3OrderArr","level4OrderArr"]
for(var i=0;i<arr.length;i++){
if(eval(arr[i]).length==0) continue;
if(hightLightStatusArr[i]==(eval(arr[i]).length-1)){
var _i = eval(arr[i]).slice(-1)[0]["i"]
var _j = eval(arr[i]).slice(-1)[0]["j"]
hideHightLightByIJ(_i,_j)
hightLightStatusArr[i] = -1
}
}
})
$(".breaklevel").click(function(){
cancelLevelTo(-1)
showLevel(-1)
clearAllHightLight()
level1OrderArr = new Array();
level2OrderArr = new Array();
level3OrderArr = new Array();
level4OrderArr = new Array();