
previous

page 12
next
the temp panel & the main panel
You should be able to get these two panels side-by-side.
I used a div called game.
Now for the tricky stuff - a card may be clicked in either panel. We can tell which by looking at its class so let's start by writing a helper function to return the class of a card: klass(card). The misspelling is because class is a reserved word in JavaScript.
function klass(card) {
var arr=['main','temp'];
var k='';
for (var i=0;i<arr.length;i++) {
if (card.classList.contains(arr[i])) {
k=arr[i];
}
}
return k;
}
var arr=['main','temp'];
var k='';
for (var i=0;i<arr.length;i++) {
if (card.classList.contains(arr[i])) {
k=arr[i];
}
}
return k;
}
If you've already tried clicking in the temp panel, you would have found nothing happened. Actually something did happen. check_first() fell over because it was expecting a card from the main panel.
So we need to work on check_first().
But first we need to ask: "Is first clicking in temp always ok?"
click me for the answer
How can we tell?
click me for the answer
previous
next