Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added cancel support (C-c), tweaked prompt update-to-done to be O(1) …

…instead of O(n)
  • Loading branch information...
commit bcaaeb7abc7598564076ac3f14d06fd0d0e8d738 1 parent 888acfc
@chrisdone authored
Showing with 26 additions and 13 deletions.
  1. +26 −13 js/tryhaskell.js
View
39 js/tryhaskell.js
@@ -869,27 +869,27 @@ function toHex(n){
if (line == "") return false; // Empty line is invalid
else return true;
},
+ cancelHandle:function(){
+ controller.commandRef.ignore = true;
+ controller.finishCommand();
+ controller.report();
+ },
commandHandle:function(line,report){
+ controller.ajaxloader = $('<p class="ajax-loader">Loading...</p>');
+ var commandRef = {};
+ controller.currentLine = line;
+ controller.commandRef = commandRef;
+ controller.report = report;
if (tellAboutRet) tellAboutRet.fadeOut(function(){
$(this).remove();
});
if (libTrigger(line,report)) return;
- var ajaxloader = $('<p class="ajax-loader">Loading...</p>');
- controller.inner.append(ajaxloader);
+ controller.inner.append(controller.ajaxloader);
controller.scrollToBottom();
- // TODO: a proper UrlEncode
jsonp("http://tryhaskell.org/haskell.json?method=eval&pad=handleJSON&expr=" + encodeHex(line),
function(resp){
- ajaxloader.remove();
- $('.jquery-console-prompt').each(function(){
- lastLine = line;
- if (!$(this).hasClass('prompt-done')) {
- $(this).addClass('prompt-done');
- $(this).click(function(){
- controller.promptText(line);
- });
- }
- });
+ if (commandRef.ignore) { return; }
+ controller.finishCommand();
var result = resp;
if (pageTrigger > -1) {
triggerTutorialPage(pageTrigger,result); }
@@ -946,6 +946,19 @@ function toHex(n){
welcomeMessage:'Type Haskell expressions in here.'
});
+ controller.finishCommand = function() {
+ controller.ajaxloader.remove();
+ $('.jquery-console-prompt :last').each(function(){
+ lastLine = controller.currentLine;
+ if (!$(this).hasClass('prompt-done')) {
+ $(this).addClass('prompt-done');
+ $(this).click(function(){
+ controller.promptText(controller.currentLine);
+ });
+ }
+ });
+ }
+
makeGuidSamplesClickable();
var match = window.location.href.match(/#([0-9]+)$/);
Please sign in to comment.
Something went wrong with that request. Please try again.