mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Add goal checking on user clicks
This commit is contained in:
parent
fb0357e0f9
commit
dc7c220b57
1 changed files with 8 additions and 0 deletions
|
@ -35,6 +35,8 @@ function receiveMessage(event) {
|
|||
case 'create':
|
||||
create(_.pick(data, 'dom', 'styles', 'scripts'));
|
||||
checkGoals(data.goals, source, origin);
|
||||
$('body').first().off('click', checkRememberedGoals);
|
||||
$('body').first().on('click', checkRememberedGoals);
|
||||
break;
|
||||
case 'update':
|
||||
if (virtualDom)
|
||||
|
@ -108,7 +110,13 @@ function update(options) {
|
|||
virtualScripts = scripts;
|
||||
}
|
||||
|
||||
var lastGoalArgs = [];
|
||||
function checkRememberedGoals() {
|
||||
checkGoals.apply(this, lastGoalArgs);
|
||||
}
|
||||
|
||||
function checkGoals(goals, source, origin) {
|
||||
lastGoalArgs = [goals, source, origin]; // Memoize for checkRememberedGoals
|
||||
// Check right now and also in one second, since our 1-second CSS transition might be affecting things until it is done.
|
||||
doCheckGoals(goals, source, origin);
|
||||
_.delay(function() { doCheckGoals(goals, source, origin); }, 1001);
|
||||
|
|
Loading…
Reference in a new issue