-
Notifications
You must be signed in to change notification settings - Fork 16
/
test-customize-puzzle.html
170 lines (163 loc) · 3.79 KB
/
test-customize-puzzle.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="exolve-m.css?v1.58"/>
<script src="exolve-m.js?v1.58"></script>
<script>
function customizeExolve(p) {
let c = p.addCellText(0, 1, '@', 12, 10, true, false)
c = p.addCellText(0, 3, '①', 16, 14, true, true)
c.style.stroke = 'blue'
c = p.addCellText(1, 0, '*', 18, 10, false, true)
c = p.addCellText(1, 2, 'α', 12, 8, false, false)
p.activateCell(0,0)
p.background.setAttributeNS(null, 'fill', 'red')
let expectedVars = [
'p.currRow',
'p.currCol',
'p.currClueIndex',
'p.gridInput',
'p.gridWidth',
'p.gridHeight',
'p.numCellsFilled',
'p.numCellsToFill',
'p.offsetLeft',
'p.offsetTop',
'p.svg',
'p.GRIDLINE',
'p.squareDim',
'p.circleR',
'p.questions',
'p.answersList',
'p.id',
'p.clearAllButton',
'p.clearButton',
'p.submitButton',
'p.gridInput',
'p.gridInputWrapper',
'p.allClueIndices',
]
for (let v of expectedVars) {
eval('console.log("' + v + ' = " + ' + v + ')')
if (eval(v) == null) {
console.log('Could not find variable: ' + v)
return
}
}
let expectedFunctions = [
'p.deactivateCurrCell',
'p.activateCell',
'p.advanceCursor',
'p.updateAndSaveState',
'p.updateDisplayAndGetState',
'p.showNinas',
'p.hideNinas',
'p.checkCurr',
'p.checkAll',
'p.revealCurr',
'p.revealAll',
'p.clearCurr',
'p.clearAll',
'p.parseState',
'p.updateClueState',
'p.deactivateCurrCell',
'p.activateCell',
'p.gnavToInner',
'p.cnavTo',
'p.cnavToInner',
'p.punctuateEntry',
'p.getCellsEntry',
]
for (let f of expectedFunctions) {
eval('console.log("func ' + f + ' = " + (' + f + '!= null))')
if (eval(f) == null) {
console.log('Could not find function: ' + f)
return
}
}
let expectedIds = [
'xlv1-clear',
'xlv1-clear-all',
'xlv1-check',
'xlv1-check-all',
'xlv1-reveal',
'xlv1-reveal-all',
'xlv1-setter-by',
'xlv1-squares-filled',
'xlv1-ninas',
'xlv1-submit',
'xlv1-across-label',
'xlv1-down-label',
'xlv1-saving',
'xlv1-controls-etc',
'xlv1-button-row-1',
'xlv1-button-row-2',
'xlv1-saving',
'xlv1-small-print',
'xlv1-grid-parent',
]
for (let id of expectedIds) {
let elt = document.getElementById(id)
if (!elt) {
console.log('Could not find element for id: ' + id)
return
}
}
p.background.setAttributeNS(null, 'fill', 'green');
p.background.style.fill = 'green';
/**
* Override cnavtoInner(), which is a method with parameters.
* We call the original method, and log some details, for
* illustration.
*/
p.cnavToInner = (function() {
var origFn = p.cnavToInner;
return function() {
origFn.apply(this, arguments);
const ci = arguments[0];
console.log('cnavToInner() called on clue index: ' + ci +
'. The clue object is:');
console.log(this.clues[ci]);
};
})();
}
</script>
<title>Test-Customize-Puzzle</title>
</head>
<body>
<script>
createExolve(`
======REPLACE WITH YOUR PUZZLE BELOW======
exolve-begin
exolve-id: test-customize-puzzle
exolve-title: Test-Customize-Puzzle
exolve-setter: Viresh Ratnakar
exolve-copyright: 2020 Viresh Ratnakar
exolve-width: 5
exolve-height: 5
exolve-grid:
00000
0.0.0
00000
0.0.0
00000
exolve-prelude:
<center>
If grid does not turn green, examine js console for errors.
</center>
exolve-across:
1 TODO (5)
4 TODO (5)
5 TODO (5)
exolve-down:
1 TODO (5)
2 TODO (5)
3 TODO (5)
exolve-end
======REPLACE WITH YOUR PUZZLE ABOVE======
`);
</script>
</body>
</html>