Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit e56d202

Browse files
committed
fixes to scrubber timestamps
1 parent 6d52d42 commit e56d202

2 files changed

Lines changed: 29 additions & 19 deletions

File tree

runestone/activecode/js/activecode.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,13 @@ ActiveCode.prototype.createEditor = function (index) {
144144
});
145145

146146
// give the user a visual cue that they have changed but not saved
147-
editor.on('change', (function () {
147+
editor.on('change', (function (ev) {
148148
if (editor.acEditEvent == false || editor.acEditEvent === undefined) {
149+
// change events can come before any real changes for various reasons, some unknown
150+
// this avoids unneccsary log events and updates to the activity counter
151+
if (this.origElem.textContent === editor.getValue()) {
152+
return;
153+
}
149154
$(editor.getWrapperElement()).css('border-top', '2px solid #b43232');
150155
$(editor.getWrapperElement()).css('border-bottom', '2px solid #b43232');
151156
this.logBookEvent({'event': 'activecode', 'act': 'edit', 'div_id': this.divid});
@@ -302,19 +307,19 @@ ActiveCode.prototype.createControls = function () {
302307
ctrlDiv.appendChild(butt);
303308
$(butt).click((function() {
304309
let data = {
305-
divid: this.divid,
310+
divid: this.divid,
306311
code: this.editor.getValue(),
307312
lang: this.language,
308313
};
309-
$.getJSON('/runestone/ajax/broadcast_code.json',
310-
data,
314+
$.getJSON('/runestone/ajax/broadcast_code.json',
315+
data,
311316
function (status) {
312317
if (status.mess === 'success') {
313318
alert(`Shared Code with ${status.share_count} students`);
314319
} else {
315320
alert("Sharing Failed");
316321
}
317-
322+
318323
});
319324
}).bind(this));
320325
}
@@ -437,27 +442,27 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) {
437442
$(scrubberDiv).css("display","inline-block");
438443
$(scrubberDiv).css("margin-left","10px");
439444
$(scrubberDiv).css("margin-right","10px");
440-
$(scrubberDiv).width("180px");
445+
$(scrubberDiv).css({"min-width": "200px",
446+
"max-width": "300px"});
441447
var scrubber = document.createElement("div");
448+
this.timestampP = document.createElement("span");
442449
this.slideit = function() {
443450
this.editor.setValue(this.history[$(scrubber).slider("value")]);
444451
var curVal = this.timestamps[$(scrubber).slider("value")];
445-
var tooltip = '<div class="sltooltip"><div class="sltooltip-inner">' +
446-
curVal + '</div><div class="sltooltip-arrow"></div></div>';
447-
$(scrubber).find(".ui-slider-handle").html(tooltip);
452+
let pos = $(scrubber).slider("value");
453+
let outOf = this.history.length;
454+
$(this.timestampP).text(`${curVal} - ${pos+1} of ${outOf}`);
448455
this.logBookEvent({'event': 'activecode', 'act': 'slide:'+curVal, 'div_id': this.divid})
449-
setTimeout(function () {
450-
$(scrubber).find(".sltooltip").fadeOut()
451-
}, 4000);
452456
};
453457
$(scrubber).slider({
454458
max: this.history.length-1,
455459
value: this.history.length-1,
456460
});
461+
$(scrubber).css('margin','10px');
457462
$(scrubber).on("slide",this.slideit.bind(this));
458463
$(scrubber).on("slidechange",this.slideit.bind(this));
459464
scrubberDiv.appendChild(scrubber);
460-
465+
scrubberDiv.appendChild(this.timestampP);
461466
// If there is a deadline set then position the scrubber at the last submission
462467
// prior to the deadline
463468
if (this.deadline) {
@@ -473,14 +478,18 @@ ActiveCode.prototype.addHistoryScrubber = function (pos_last) {
473478
i = i - 1;
474479
scrubber.value = Math.max(i,0);
475480
this.editor.setValue(this.history[scrubber.value]);
481+
$(scrubber).slider('value', scrubber.value);
476482
}
477483
else if (pos_last) {
478484
scrubber.value = this.history.length-1;
479485
this.editor.setValue(this.history[scrubber.value]);
480486
} else {
481487
scrubber.value = 0;
482488
}
483-
489+
let pos = $(scrubber).slider("value");
490+
let outOf = this.history.length;
491+
let ts = this.timestamps[$(scrubber).slider("value")];
492+
$(this.timestampP).text(`${ts} - ${pos+1} of ${outOf}`);
484493
$(this.histButton).remove();
485494
this.histButton = null;
486495
this.historyScrubber = scrubber;
@@ -2127,9 +2136,9 @@ LiveCode.prototype.runProg_callback = function(data) {
21272136
logresult = result.outcome;
21282137
}
21292138
this.logRunEvent({'div_id': this.divid,
2130-
'code': source,
2131-
'errinfo': logresult,
2132-
'to_save':saveCode,
2139+
'code': source,
2140+
'errinfo': logresult,
2141+
'to_save':saveCode,
21332142
'lang': this.language,
21342143
'event':'livecode',
21352144
'partner': this.partner,

runestone/common/js/runestonebase.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ RunestoneBase.prototype.logBookEvent = function (eventInfo) {
3838
null, 'json');
3939
}
4040
console.log("logging event " + JSON.stringify(eventInfo));
41-
if (typeof pageProgressTracker.updateProgress === "function") {
41+
if (typeof pageProgressTracker.updateProgress === "function"
42+
&& eventInfo.act != 'edit') {
4243
pageProgressTracker.updateProgress(eventInfo.div_id);
4344
}
4445
return post_return;
@@ -149,7 +150,7 @@ RunestoneBase.prototype.addCaption = function(elType) {
149150
$(capDiv).html(this.caption + " (" + this.divid + ")");
150151
$(capDiv).addClass(`${elType}_caption`);
151152
$(capDiv).addClass(`${elType}_caption_text`);
152-
153+
this.capDiv = capDiv;
153154
//this.outerDiv.parentNode.insertBefore(capDiv, this.outerDiv.nextSibling);
154155
this.containerDiv.appendChild(capDiv);
155156
};

0 commit comments

Comments
 (0)