mirror of
https://github.com/Oreolek/undum.git
synced 2024-05-17 00:18:17 +03:00
Link catcher
This commit is contained in:
parent
1e16ea7be7
commit
38b4ae5bd1
File diff suppressed because one or more lines are too long
|
@ -290,8 +290,8 @@ var startOutputTransaction = function() {
|
||||||
}
|
}
|
||||||
// The default is "all the way down".
|
// The default is "all the way down".
|
||||||
scrollStack.push(
|
scrollStack.push(
|
||||||
$("#content").height() + $("#title").height() + 60
|
document.getElementById("content").offsetHeight + document.getElementById("title").offsetHeight + 60
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
var continueOutputTransaction = function() {
|
var continueOutputTransaction = function() {
|
||||||
if (pendingFirstWrite) {
|
if (pendingFirstWrite) {
|
||||||
|
@ -342,7 +342,7 @@ var processLink = function(code) {
|
||||||
endOutputTransaction();
|
endOutputTransaction();
|
||||||
|
|
||||||
// We're able to save, if we weren't already.
|
// We're able to save, if we weren't already.
|
||||||
$("#save").attr('disabled', false);
|
document.getElementById("save").setAttribute('disabled', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This gets called to actually do the work of processing a code.
|
/* This gets called to actually do the work of processing a code.
|
||||||
|
@ -392,13 +392,21 @@ var processOneLink = function(code) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* This function listens on content block to filter out link clicks. */
|
||||||
|
var linkClickHandler = function(event) {
|
||||||
|
if (event.target.tagName.toLowerCase() === 'a') {
|
||||||
|
event.preventDefault();
|
||||||
|
processClick(event.target.href);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This gets called when the user clicks a link to carry out an
|
/* This gets called when the user clicks a link to carry out an
|
||||||
* action. */
|
* action. */
|
||||||
var processClick = function(code) {
|
var processClick = function(code) {
|
||||||
var now = (new Date()).getTime() * 0.001;
|
var now = (new Date()).getTime() * 0.001;
|
||||||
system.time = now - startTime;
|
system.time = now - startTime;
|
||||||
progress.sequence.push({link:code, when:system.time});
|
progress.sequence.push({link:code, when:system.time});
|
||||||
processLink(code);
|
return processLink(code);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Transitions between situations. */
|
/* Transitions between situations. */
|
||||||
|
|
|
@ -99,6 +99,9 @@ ready(function() {
|
||||||
startGame();
|
startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle the link clicks
|
||||||
|
document.getElementById("content").addEventListener("click", linkClickHandler, false);
|
||||||
|
|
||||||
// Display the "click to begin" message. (We do this in code
|
// Display the "click to begin" message. (We do this in code
|
||||||
// so that, if Javascript is off, it doesn't happen.)
|
// so that, if Javascript is off, it doesn't happen.)
|
||||||
showBlock("click_message");
|
showBlock("click_message");
|
||||||
|
|
Loading…
Reference in a new issue