previous

page 16

next
my new move function
function move(card1,card2) {
var c1=card1.style.gridColumnStart;
var c2=card2.style.gridColumnStart;
if (klass(card1)=='temp') {
// temp → main
var id=card1.id; var i=id-100;
var j=g_temp_col[i];
g_main_cols[c2].push(j);
g_temp_col[i]=-1;
} else if (klass(card2)=='temp') {
// main → temp
var id=g_main_cols[c1].pop();
var id2=card2.id; var i=id2-100;
g_temp_col[i]=id;
} else {
// main → main
g_seq.reverse();
var l=g_seq.length;
for (var i=0;i<l;i++) {
g_main_cols[c1].pop();
var id=g_seq.pop();
g_main_cols[c2].push(id);
}
}
}

At last! We are able to move a card from main to temp.

But something is not quite right - what is it?

click me for the answer

Can you explain why?

click me for the answer

previous
next