previous

page 20

next
click on counter to sea-fill empties

First we need to add an onClick attribute to all the counters.
A change to one line in squares.js will do the trick:

var s4="' onClick='counter_clicked(this);'>0</div>";
counter_clicked in clicks.js
function counter_clicked(el) {
var id=el.id;
var n=id.substring(1);
if (n<10) {
var row=n;
for (var col=0;col<10;col++) {
var id=rc2id(row,col);
var el=document.getElementById(id);
var v=el.getAttribute('v');
if (v==0) {
var a=get_a(row,col);
if (a==7) {
el.src='images/right/7.png';
} else {
el.src='images/wrong/7.png';
}
}
}
} else {
var col=n-10;
for (var row=0;row<10;row++) {
var id=rc2id(row,col);
var el=document.getElementById(id);
var v=el.getAttribute('v');
if (v==0) {
var a=get_a(row,col);
if (a==7) {
el.src='images/right/7.png';
} else {
el.src='images/wrong/7.png';
}
}
}
}
}
previous
next