From d3920882fb089608e979ffc3c81d018f598f981a Mon Sep 17 00:00:00 2001 From: Sam Petulla Date: Sat, 20 Jun 2015 21:10:38 -0400 Subject: [PATCH] add message dialogue when returning to check the bot --- modules/paulbot/paulbot.js | 42 ++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/modules/paulbot/paulbot.js b/modules/paulbot/paulbot.js index 3be401a..19fddc3 100755 --- a/modules/paulbot/paulbot.js +++ b/modules/paulbot/paulbot.js @@ -21,12 +21,21 @@ var paulbot; { "emote": "waving", "speak": message }, { "mode": "off" } ]; + var justStarted, + startingTimeout; if(stats && stats.windows.previous) { dialogue[0].prompts = [ { "prompt": "Continue reading from last spot", - "do": function() { document.getElementsByTagName('body')[0].scrollTop = stats.windows.previous; } + "do": function() { + justStarted = true; + var clearJustStarted = function() { + justStarted = !justStarted; + } + startingTimeout = setTimeout(clearJustStarted, 500); + document.getElementsByTagName('body')[0].scrollTop = stats.windows.previous; + } }, { "prompt": "Go away" @@ -74,6 +83,23 @@ var paulbot; ] paulbot.dialogue(dialogue); } + function alertJustStarting() { + + var message = "Welcome back. Proceed."; + + var dialogue = [ + { + "emote": "explaining", + "speak": message, + "wait": 2000 + }, + { + "mode": "off" + } + ]; + + module.bot.dialogue(dialogue); + } function logScroll() { scrollLog.push({ @@ -86,11 +112,15 @@ var paulbot; var scrollSpeed = (scrollLog[scrollLog.length-1].scrollTop - scrollLog[scrollLog.length-2].scrollTop) / (scrollLog[scrollLog.length-1].timestamp - scrollLog[scrollLog.length-2].timestamp) - - if(pageYOffset + innerHeight > $(document).height() - 400) { - completionThrottled(); - } else if(scrollSpeed > 4 && fastSass.length) { - alertTooFastThrottled(); + if(!justStarted) { + if(pageYOffset + innerHeight > $(document).height() - 400) { + completionThrottled(); + } else if(scrollSpeed > 4 && fastSass.length) { + alertTooFastThrottled(); + } + } + else { + alertJustStarting(); } }