From ac6569994cc54cf28001941187d232ac38507c4b Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Sat, 5 Mar 2016 21:34:01 -0600 Subject: [PATCH 01/13] Remove Save/Load buttons replace with history scrubber. --- runestone/activecode/js/activecode.js | 100 ++++++++++++++++++-------- runestone/common/js/runestonebase.js | 3 + 2 files changed, 75 insertions(+), 28 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 89c199716..89876b841 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -37,6 +37,10 @@ ActiveCode.prototype.init = function(opts) { this.graphics = null; // create div for turtle graphics this.codecoach = null; this.codelens = null; + this.controlDiv = null; + this.historyScrubber = null; + this.history = [this.code] + this.timestamps = ["Original"] if(this.includes !== undefined) { this.includes = this.includes.split(/\s+/); @@ -118,32 +122,14 @@ ActiveCode.prototype.createControls = function () { this.runButton = butt; $(butt).click(this.runProg.bind(this)); - // Save - if (this.useRunestoneServices) { - butt = document.createElement("button"); - $(butt).addClass("ac_opt btn btn-default"); - $(butt).text("Save"); - $(butt).css("margin-left", "10px"); - this.saveButton = butt; - this.saveButton.onclick = this.saveEditor.bind(this); - ctrlDiv.appendChild(butt); - if (this.hidecode) { - $(butt).css("display", "none") - } - } - // Load - if (this.useRunestoneServices) { - butt = document.createElement("button"); - $(butt).addClass("ac_opt btn btn-default"); - $(butt).text("Load"); - $(butt).css("margin-left", "10px"); - this.loadButton = butt; - this.loadButton.onclick = this.loadEditor.bind(this); - ctrlDiv.appendChild(butt); - if (this.hidecode) { - $(butt).css("display", "none") - } - } + var butt = document.createElement("button"); + $(butt).text("Load History"); + $(butt).addClass("btn btn-default"); + ctrlDiv.appendChild(butt); + this.histButton = butt; + $(butt).click(this.addHistoryScrubber.bind(this)); + + if ($(this.origElem).data('gradebutton')) { butt = document.createElement("button"); $(butt).addClass("ac_opt btn btn-default"); @@ -200,9 +186,48 @@ ActiveCode.prototype.createControls = function () { } $(this.outerDiv).prepend(ctrlDiv); + this.controlDiv = ctrlDiv; }; +// Activecode -- If the code has not changed wrt the scrubber position value then don't save the code or reposition the scrubber +// -- still call runlog, but add a parameter to not save the code +// add an initial load history button +// if there is no edit then there is no append to_save (True/False) + +ActiveCode.prototype.addHistoryScrubber = function () { + + var data = {acid: this.divid}; + if (this.sid !== undefined) { + data['sid'] = this.sid; + } + jQuery.get(eBookConfig.ajaxURL + 'getprog', data, function(data, status, whatever) { + this.history = this.history.concat(data.history); + this.timestamps = this.timestamps.concat(data.timestamps); + + scrubber = document.createElement("input"); + scrubber.type = "range"; + scrubber.min = 0; + scrubber.max = this.history.length-1; + scrubber.value = 0 + + $(this.histButton).remove(); + this.histButton = null; + this.historyScrubber = scrubber; + $(scrubber).insertAfter(this.runButton) + + scrubber.onmousemove = function() { + this.editor.setValue(this.history[scrubber.value]); + if (scrubber.value > 0) { + scrubber.title = (new Date(this.timestamps[scrubber.value])).toString(); + } else { + scrubber.title = this.timestamps[scrubber.value]; + } + }.bind(this); + }.bind(this)); +} + + ActiveCode.prototype.createOutput = function () { // Create a parent div with two elements: pre for standard output and a div // to hold turtle graphics output. We use a div in case the turtle changes from @@ -640,6 +665,7 @@ ActiveCode.prototype.buildProg = function() { ActiveCode.prototype.runProg = function() { var prog = this.buildProg(); + var saveCode; $(this.output).text(''); @@ -661,16 +687,34 @@ ActiveCode.prototype.runProg = function() { return Sk.importMainWithBody("", false, prog, true); }); + if (this.historyScrubber === null) { + this.addHistoryScrubber(); + } + + if (this.historyScrubber === null || (this.history[this.historyScrubber.value] == this.editor.getValue())) { + saveCode = "False" + } else { + saveCode = "True" + } + myPromise.then((function(mod) { // success $(this.runButton).removeAttr('disabled'); - this.logRunEvent({'div_id': this.divid, 'code': prog, 'errinfo': 'success'}); // Log the run event + this.logRunEvent({'div_id': this.divid, 'code': prog, 'errinfo': 'success', 'to_save':saveCode}); // Log the run event }).bind(this), (function(err) { // fail $(this.runButton).removeAttr('disabled'); - this.logRunEvent({'div_id': this.divid, 'code': prog, 'errinfo': err.toString()}); // Log the run event + this.logRunEvent({'div_id': this.divid, 'code': prog, 'errinfo': err.toString(), 'to_save':saveCode}); // Log the run event this.addErrorMessage(err) }).bind(this)); + + if (this.historyScrubber && (this.history[this.historyScrubber.value] != this.editor.getValue())) { + this.history.push(this.editor.getValue()); + this.timestamps.push((new Date()).toString()); + this.historyScrubber.max = this.history.length - 1; + this.historyScrubber.value = this.historyScrubber.max; + } + if (typeof(allVisualizers) != "undefined") { $.each(allVisualizers, function (i, e) { e.redrawConnectors(); diff --git a/runestone/common/js/runestonebase.js b/runestone/common/js/runestonebase.js index a5350ed04..0b10e93f8 100644 --- a/runestone/common/js/runestonebase.js +++ b/runestone/common/js/runestonebase.js @@ -12,6 +12,9 @@ RunestoneBase.prototype.logBookEvent = function (eventInfo) { RunestoneBase.prototype.logRunEvent = function (eventInfo) { eventInfo.course = eBookConfig.course; + if (! 'to_save' in eventInfo) { + eventInfo.save_code = "True" + } if (eBookConfig.useRunestoneServices && eBookConfig.logLevel > 0) { jQuery.post(eBookConfig.ajaxURL + 'runlog', eventInfo); // Log the run event } From d9ae7b3f82f8cd619dff76192205c4078d011014 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Sat, 5 Mar 2016 22:23:28 -0600 Subject: [PATCH 02/13] Start to add title and time stamps --- runestone/activecode/js/activecode.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 89876b841..f1508caf7 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -201,20 +201,27 @@ ActiveCode.prototype.addHistoryScrubber = function () { if (this.sid !== undefined) { data['sid'] = this.sid; } - jQuery.get(eBookConfig.ajaxURL + 'getprog', data, function(data, status, whatever) { + jQuery.get(eBookConfig.ajaxURL + 'gethist', data, function(data, status, whatever) { this.history = this.history.concat(data.history); this.timestamps = this.timestamps.concat(data.timestamps); + var scrubberDiv = document.createElement("div"); + $(scrubberDiv).css("display","inline"); + $(scrubberDiv).css("width","140px"); + scrubberTitle = document.createTextNode("Source Timeline"); + //scrubberDiv.appendChild(scrubberTitle); scrubber = document.createElement("input"); scrubber.type = "range"; scrubber.min = 0; scrubber.max = this.history.length-1; - scrubber.value = 0 + scrubber.value = 0; + scrubberDiv.appendChild(scrubber); + this.scrubberTime = document.createElement("p") $(this.histButton).remove(); this.histButton = null; this.historyScrubber = scrubber; - $(scrubber).insertAfter(this.runButton) + $(scrubberDiv).insertAfter(this.runButton) scrubber.onmousemove = function() { this.editor.setValue(this.history[scrubber.value]); From d86c763e6e0eb7474f0995650cfa2d54fd0fae18 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Sat, 5 Mar 2016 22:57:30 -0600 Subject: [PATCH 03/13] Make sure mouse is down before dragging scrubber and changing code. --- runestone/activecode/js/activecode.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index f1508caf7..4ebcb4f23 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -2,6 +2,9 @@ * Created by bmiller on 3/19/15. */ +var isMouseDown = false; +document.onmousedown = function() { isMouseDown = true }; +document.onmouseup = function() { isMouseDown = false }; var edList = {}; @@ -224,11 +227,13 @@ ActiveCode.prototype.addHistoryScrubber = function () { $(scrubberDiv).insertAfter(this.runButton) scrubber.onmousemove = function() { - this.editor.setValue(this.history[scrubber.value]); - if (scrubber.value > 0) { - scrubber.title = (new Date(this.timestamps[scrubber.value])).toString(); - } else { - scrubber.title = this.timestamps[scrubber.value]; + if (isMouseDown) { + this.editor.setValue(this.history[scrubber.value]); + if (scrubber.value > 0) { + scrubber.title = (new Date(this.timestamps[scrubber.value])).toString(); + } else { + scrubber.title = this.timestamps[scrubber.value]; + } } }.bind(this); }.bind(this)); From b85bfd989bf09d955c51202745595345072d62d4 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Sun, 6 Mar 2016 10:43:07 -0600 Subject: [PATCH 04/13] timestamp now displays nicely below the scrubber --- runestone/activecode/js/activecode.js | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 4ebcb4f23..e8d9bea73 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -205,21 +205,26 @@ ActiveCode.prototype.addHistoryScrubber = function () { data['sid'] = this.sid; } jQuery.get(eBookConfig.ajaxURL + 'gethist', data, function(data, status, whatever) { - this.history = this.history.concat(data.history); - this.timestamps = this.timestamps.concat(data.timestamps); + if (data.history !== undefined) { + this.history = this.history.concat(data.history); + for (t in data.timestamps) { + this.timestamps.push( (new Date(data.timestamps[t])).toLocaleString() ) + } + } var scrubberDiv = document.createElement("div"); - $(scrubberDiv).css("display","inline"); - $(scrubberDiv).css("width","140px"); - scrubberTitle = document.createTextNode("Source Timeline"); - //scrubberDiv.appendChild(scrubberTitle); + $(scrubberDiv).css("display","inline-block"); + $(scrubberDiv).width("180px"); scrubber = document.createElement("input"); scrubber.type = "range"; scrubber.min = 0; scrubber.max = this.history.length-1; scrubber.value = 0; scrubberDiv.appendChild(scrubber); - this.scrubberTime = document.createElement("p") + this.scrubberTime = document.createElement("p"); + this.scrubberTime.innerHTML = "Original"; + $(this.scrubberTime).css("font-size","xx-small"); + scrubberDiv.appendChild(this.scrubberTime); $(this.histButton).remove(); this.histButton = null; @@ -229,11 +234,7 @@ ActiveCode.prototype.addHistoryScrubber = function () { scrubber.onmousemove = function() { if (isMouseDown) { this.editor.setValue(this.history[scrubber.value]); - if (scrubber.value > 0) { - scrubber.title = (new Date(this.timestamps[scrubber.value])).toString(); - } else { - scrubber.title = this.timestamps[scrubber.value]; - } + this.scrubberTime.innerHTML = this.timestamps[scrubber.value] } }.bind(this); }.bind(this)); @@ -722,9 +723,10 @@ ActiveCode.prototype.runProg = function() { if (this.historyScrubber && (this.history[this.historyScrubber.value] != this.editor.getValue())) { this.history.push(this.editor.getValue()); - this.timestamps.push((new Date()).toString()); + this.timestamps.push((new Date()).toLocaleString()); this.historyScrubber.max = this.history.length - 1; this.historyScrubber.value = this.historyScrubber.max; + this.scrubberTime.innerHTML = this.timestamps[this.historyScrubber.value] } if (typeof(allVisualizers) != "undefined") { From 925bb20f6d472256fa1637c5d1889457320e9359 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Sun, 6 Mar 2016 11:13:49 -0600 Subject: [PATCH 05/13] History now works with the Show/Hide code button --- runestone/activecode/js/activecode.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index e8d9bea73..9fd588726 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -151,8 +151,11 @@ ActiveCode.prototype.createControls = function () { this.showHideButt = butt; ctrlDiv.appendChild(butt); $(butt).click( (function() { $(this.codeDiv).toggle(); - $(this.loadButton).toggle(); - $(this.saveButton).toggle(); + if (this.historyScrubber == null) { + this.addHistoryScrubber(true); + } else { + $(this.historyScrubber.parentElement).toggle(); + } }).bind(this)); } @@ -198,7 +201,7 @@ ActiveCode.prototype.createControls = function () { // add an initial load history button // if there is no edit then there is no append to_save (True/False) -ActiveCode.prototype.addHistoryScrubber = function () { +ActiveCode.prototype.addHistoryScrubber = function (pos_last) { var data = {acid: this.divid}; if (this.sid !== undefined) { @@ -219,13 +222,20 @@ ActiveCode.prototype.addHistoryScrubber = function () { scrubber.type = "range"; scrubber.min = 0; scrubber.max = this.history.length-1; - scrubber.value = 0; scrubberDiv.appendChild(scrubber); this.scrubberTime = document.createElement("p"); this.scrubberTime.innerHTML = "Original"; $(this.scrubberTime).css("font-size","xx-small"); scrubberDiv.appendChild(this.scrubberTime); + if (pos_last) { + scrubber.value = scrubber.max + this.editor.setValue(this.history[scrubber.value]); + this.scrubberTime.innerHTML = this.timestamps[scrubber.value] + } else { + scrubber.value = 0; + } + $(this.histButton).remove(); this.histButton = null; this.historyScrubber = scrubber; From 7b8a17e74fe3cf299fc10d6eda4b32c8bdbbdf2b Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Tue, 8 Mar 2016 15:26:52 -0600 Subject: [PATCH 06/13] Change get to getJSON -- fixes incompatibility between Safari and Chrome --- runestone/activecode/js/activecode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 9fd588726..2b336b09e 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -207,7 +207,7 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) { if (this.sid !== undefined) { data['sid'] = this.sid; } - jQuery.get(eBookConfig.ajaxURL + 'gethist', data, function(data, status, whatever) { + jQuery.getJSON(eBookConfig.ajaxURL + 'gethist', data, function(data, status, whatever) { if (data.history !== undefined) { this.history = this.history.concat(data.history); for (t in data.timestamps) { From dbd67b67dd58bdcb5847ffd9e5c73cb9b970c36a Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Wed, 9 Mar 2016 14:17:02 -0600 Subject: [PATCH 07/13] handle both onclick and onmousemove events for modifying the scrubber. --- runestone/activecode/js/activecode.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 2b336b09e..803c139e5 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -247,6 +247,12 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) { this.scrubberTime.innerHTML = this.timestamps[scrubber.value] } }.bind(this); + + scrubber.onclick = function() { + this.editor.setValue(this.history[scrubber.value]); + this.scrubberTime.innerHTML = this.timestamps[scrubber.value] + }.bind(this); + }.bind(this)); } From 16dc8c5777745bacc02d8451c5c4b4c049402a8d Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Wed, 16 Mar 2016 11:24:33 -0500 Subject: [PATCH 08/13] add .json suffix to api call --- runestone/activecode/js/activecode.js | 2 +- runestone/datafile/__init__.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 803c139e5..40f8534a5 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -207,7 +207,7 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) { if (this.sid !== undefined) { data['sid'] = this.sid; } - jQuery.getJSON(eBookConfig.ajaxURL + 'gethist', data, function(data, status, whatever) { + jQuery.getJSON(eBookConfig.ajaxURL + 'gethist.json', data, function(data, status, whatever) { if (data.history !== undefined) { this.history = this.history.concat(data.history); for (t in data.timestamps) { diff --git a/runestone/datafile/__init__.py b/runestone/datafile/__init__.py index 413550faf..182339dfc 100644 --- a/runestone/datafile/__init__.py +++ b/runestone/datafile/__init__.py @@ -39,8 +39,7 @@ def setup(app): TEMPLATE = """
-%(filecontent)s
- 
+%(filecontent)s """ class DataFileNode(nodes.General, nodes.Element): From 018bbfc8e0e0c683d01358bd5b96050a85f89ac2 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Sun, 29 May 2016 14:53:52 -0500 Subject: [PATCH 09/13] Add title above. Looks awkward. --- runestone/activecode/js/activecode.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index 40f8534a5..b6a260b1d 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -222,6 +222,10 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) { scrubber.type = "range"; scrubber.min = 0; scrubber.max = this.history.length-1; + stitle = document.createElement('p'); + stitle.innerHTML = "History"; + $(stitle).css("font-size","xx-small"); + scrubberDiv.appendChild(stitle); scrubberDiv.appendChild(scrubber); this.scrubberTime = document.createElement("p"); this.scrubberTime.innerHTML = "Original"; From 2baed404f8f41e9fbffa76e1244adde17f0e60ca Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Mon, 30 May 2016 09:15:35 -0500 Subject: [PATCH 10/13] Clean scrubber with date popup --- runestone/activecode/js/activecode.js | 47 +++++++++---------- .../css/runestone-custom-sphinx-bootstrap.css | 37 +++++++++++++++ 2 files changed, 58 insertions(+), 26 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index b6a260b1d..a74066685 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -217,25 +217,32 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) { var scrubberDiv = document.createElement("div"); $(scrubberDiv).css("display","inline-block"); + $(scrubberDiv).css("margin-left","10px"); + $(scrubberDiv).css("margin-right","10px"); $(scrubberDiv).width("180px"); - scrubber = document.createElement("input"); - scrubber.type = "range"; - scrubber.min = 0; - scrubber.max = this.history.length-1; - stitle = document.createElement('p'); - stitle.innerHTML = "History"; - $(stitle).css("font-size","xx-small"); - scrubberDiv.appendChild(stitle); + scrubber = document.createElement("div"); + var slideit = function() { + this.editor.setValue(this.history[$(scrubber).slider("value")]); + var curVal = this.timestamps[$(scrubber).slider("value")]; + //this.scrubberTime.innerHTML = curVal; + var tooltip = '
' + + curVal + '
'; + $(scrubber).find(".ui-slider-handle").html(tooltip); + setTimeout(function () { + $(scrubber).find(".sltooltip").fadeOut() + }, 4000); + }.bind(this); + $(scrubber).slider({ + max: this.history.length-1, + value: this.history.length-1, + slide: slideit, + change: slideit + }); scrubberDiv.appendChild(scrubber); - this.scrubberTime = document.createElement("p"); - this.scrubberTime.innerHTML = "Original"; - $(this.scrubberTime).css("font-size","xx-small"); - scrubberDiv.appendChild(this.scrubberTime); if (pos_last) { - scrubber.value = scrubber.max + scrubber.value = this.history.length-1 this.editor.setValue(this.history[scrubber.value]); - this.scrubberTime.innerHTML = this.timestamps[scrubber.value] } else { scrubber.value = 0; } @@ -245,18 +252,6 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) { this.historyScrubber = scrubber; $(scrubberDiv).insertAfter(this.runButton) - scrubber.onmousemove = function() { - if (isMouseDown) { - this.editor.setValue(this.history[scrubber.value]); - this.scrubberTime.innerHTML = this.timestamps[scrubber.value] - } - }.bind(this); - - scrubber.onclick = function() { - this.editor.setValue(this.history[scrubber.value]); - this.scrubberTime.innerHTML = this.timestamps[scrubber.value] - }.bind(this); - }.bind(this)); } diff --git a/runestone/common/css/runestone-custom-sphinx-bootstrap.css b/runestone/common/css/runestone-custom-sphinx-bootstrap.css index 5ab489d42..eaba59316 100644 --- a/runestone/common/css/runestone-custom-sphinx-bootstrap.css +++ b/runestone/common/css/runestone-custom-sphinx-bootstrap.css @@ -636,3 +636,40 @@ color: #000000; border-color: #000000; } /* END TIMED ASSESSMENT BUTTON STYLES */ + +.sltooltip { + position: absolute; + z-index: 1020; + display: block; + padding-bottom: 5px; + font-size: 11px; + visibility: visible; + margin-top: -2px; + bottom:120%; + margin-left: -2em; +} + +.sltooltip .sltooltip-arrow { + bottom: 0; + left: 50%; + margin-left: -5px; + border-top: 5px solid #000000; + border-right: 5px solid transparent; + border-left: 5px solid transparent; + position: absolute; + width: 0; + height: 0; +} + +.sltooltip-inner { + max-width: 200px; + padding: 3px 8px; + color: #ffffff; + text-align: center; + text-decoration: none; + background-color: #000000; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + From 789bd361f7b77ece77d85ec18f2d33106fac24bf Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Mon, 30 May 2016 15:46:02 -0500 Subject: [PATCH 11/13] Run/Save --- runestone/activecode/js/activecode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index a74066685..f648bf594 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -119,7 +119,7 @@ ActiveCode.prototype.createControls = function () { // Run var butt = document.createElement("button"); - $(butt).text("Run"); + $(butt).text("Run/Save"); $(butt).addClass("btn btn-success"); ctrlDiv.appendChild(butt); this.runButton = butt; From 9b2cbd6a521591e3dbafe2ae2051063f0b5bddfc Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Thu, 2 Jun 2016 07:41:48 -0500 Subject: [PATCH 12/13] Cleanup references to the scrubber --- runestone/activecode/css/activecode.css | 4 ++++ runestone/activecode/js/activecode.js | 32 +++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/runestone/activecode/css/activecode.css b/runestone/activecode/css/activecode.css index 7fbb6a54e..c1812f642 100644 --- a/runestone/activecode/css/activecode.css +++ b/runestone/activecode/css/activecode.css @@ -92,6 +92,10 @@ border: 2px solid black; } +.ac_section>.col-md-12 { + max-width: 100% !important; +} + .full_width ol { max-width: 100% !important; } \ No newline at end of file diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index f648bf594..ae85fea41 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -44,6 +44,7 @@ ActiveCode.prototype.init = function(opts) { this.historyScrubber = null; this.history = [this.code] this.timestamps = ["Original"] + this.autorun = $(orig).data('autorun'); if(this.includes !== undefined) { this.includes = this.includes.split(/\s+/); @@ -65,7 +66,7 @@ ActiveCode.prototype.init = function(opts) { } this.addCaption(); - if ($(orig).data('autorun')) { + if (this.autorun) { $(document).ready(this.runProg.bind(this)); } }; @@ -116,21 +117,23 @@ ActiveCode.prototype.createEditor = function (index) { ActiveCode.prototype.createControls = function () { var ctrlDiv = document.createElement("div"); $(ctrlDiv).addClass("ac_actions"); - + $(ctrlDiv).addClass("col-md-12"); // Run var butt = document.createElement("button"); - $(butt).text("Run/Save"); + $(butt).text("Save & Run"); $(butt).addClass("btn btn-success"); ctrlDiv.appendChild(butt); this.runButton = butt; $(butt).click(this.runProg.bind(this)); - var butt = document.createElement("button"); - $(butt).text("Load History"); - $(butt).addClass("btn btn-default"); - ctrlDiv.appendChild(butt); - this.histButton = butt; - $(butt).click(this.addHistoryScrubber.bind(this)); + if (! this.hidecode) { + var butt = document.createElement("button"); + $(butt).text("Load History"); + $(butt).addClass("btn btn-default"); + ctrlDiv.appendChild(butt); + this.histButton = butt; + $(butt).click(this.addHistoryScrubber.bind(this)); + } if ($(this.origElem).data('gradebutton')) { @@ -715,11 +718,11 @@ ActiveCode.prototype.runProg = function() { return Sk.importMainWithBody("", false, prog, true); }); - if (this.historyScrubber === null) { + if (this.historyScrubber === null && !this.autorun) { this.addHistoryScrubber(); } - if (this.historyScrubber === null || (this.history[this.historyScrubber.value] == this.editor.getValue())) { + if (this.historyScrubber === null || (this.history[$(this.historyScrubber).slider("value")] == this.editor.getValue())) { saveCode = "False" } else { saveCode = "True" @@ -736,12 +739,11 @@ ActiveCode.prototype.runProg = function() { }).bind(this)); - if (this.historyScrubber && (this.history[this.historyScrubber.value] != this.editor.getValue())) { + if (this.historyScrubber && (this.history[$(this.historyScrubber).slider("value")] != this.editor.getValue())) { this.history.push(this.editor.getValue()); this.timestamps.push((new Date()).toLocaleString()); - this.historyScrubber.max = this.history.length - 1; - this.historyScrubber.value = this.historyScrubber.max; - this.scrubberTime.innerHTML = this.timestamps[this.historyScrubber.value] + $(this.historyScrubber).slider("option", "max", this.history.length - 1) + $(this.historyScrubber).slider("option", "value", this.history.length - 1) } if (typeof(allVisualizers) != "undefined") { From ea736872f1707168fc84ca8484438e37f15b13b2 Mon Sep 17 00:00:00 2001 From: Brad Miller Date: Thu, 2 Jun 2016 09:28:25 -0500 Subject: [PATCH 13/13] Only title Save & Run when logged in --- runestone/activecode/js/activecode.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runestone/activecode/js/activecode.js b/runestone/activecode/js/activecode.js index ae85fea41..13e0a5ad3 100755 --- a/runestone/activecode/js/activecode.js +++ b/runestone/activecode/js/activecode.js @@ -120,8 +120,8 @@ ActiveCode.prototype.createControls = function () { $(ctrlDiv).addClass("col-md-12"); // Run var butt = document.createElement("button"); - $(butt).text("Save & Run"); - $(butt).addClass("btn btn-success"); + $(butt).text("Run"); + $(butt).addClass("btn btn-success run-button"); ctrlDiv.appendChild(butt); this.runButton = butt; $(butt).click(this.runProg.bind(this)); @@ -1675,6 +1675,10 @@ $(document).ready(function() { }); +$(document).bind("runestone:login", function() { + $(".run-button").text("Save & Run"); +}); + // This seems a bit hacky and possibly brittle, but its hard to know how long it will take to // figure out the login/logout status of the user. Sometimes its immediate, and sometimes its // long. So to be safe we'll do it both ways..