mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-24 21:13:35 -04:00
Add goal checking on user clicks
This commit is contained in:
parent
2f220eb007
commit
e30c51e145
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…
Add table
Add a link
Reference in a new issue