previous

page 8

next
checking for acceptable clicks
function check_first(card) {
var ok; g_seq=[];
var c=card.style.gridColumnStart; // column #
var r=card.style.gridRowStart; // row #
if (last(card)) {
g_seq=[parseInt(card.id)]; // used by move()
ok=true; // is last in column
} else { // check for sequence
var arr=[]; var ids=g_main_cols[c];
for (var i=r-1;i<ids.length;i++) {
arr.push(ids[i]);
}
if (check_sequence(arr)) {
g_seq=arr; ok=true;
} else {
ok=false;
}
}
return ok;
}

Note the new global g_seq for storing a single card or a sequence for later use by our move() function.

function check_second(card) {
var ok;
if (last(card)) { // check for sequence
// convert strings to numbers
var n1=parseInt(card.id);
var n2=parseInt(g_click_card.id);
var arr=[n1,n2];
ok=check_sequence(arr);
} else { // is not last in column
ok=false;
}
return ok;
}
previous
next