You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: runestone/activecode/js/activecode.js
+49-53Lines changed: 49 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -36,19 +36,19 @@ import embed from "vega-embed";
36
36
window.vegaEmbed=embed;
37
37
38
38
varisMouseDown=false;
39
-
document.onmousedown=function(){
39
+
document.onmousedown=function(){
40
40
isMouseDown=true;
41
41
};
42
42
43
-
document.onmouseup=function(){
43
+
document.onmouseup=function(){
44
44
isMouseDown=false;
45
45
};
46
46
window.edList={};
47
47
48
48
varsocket,connection,doc;
49
49
varchatcodesServer="chat.codes";
50
50
51
-
CodeMirror.commands.autocomplete=function(cm){
51
+
CodeMirror.commands.autocomplete=function(cm){
52
52
cm.showHint({hint: CodeMirror.hint.anyword});
53
53
};
54
54
@@ -135,7 +135,7 @@ export class ActiveCode extends RunestoneBase {
135
135
}
136
136
this.addCaption("runestone");
137
137
setTimeout(
138
-
function(){
138
+
function(){
139
139
this.editor.refresh();
140
140
}.bind(this),
141
141
1000
@@ -190,15 +190,15 @@ export class ActiveCode extends RunestoneBase {
190
190
});
191
191
// Make the editor resizable
192
192
$(editor.getWrapperElement()).resizable({
193
-
resize: function(){
193
+
resize: function(){
194
194
editor.setSize($(this).width(),$(this).height());
195
195
editor.refresh();
196
196
},
197
197
});
198
198
// give the user a visual cue that they have changed but not saved
199
199
editor.on(
200
200
"change",
201
-
function(ev){
201
+
function(ev){
202
202
if(
203
203
editor.acEditEvent==false||
204
204
editor.acEditEvent===undefined
@@ -208,7 +208,7 @@ export class ActiveCode extends RunestoneBase {
208
208
// offsetParent === null means that the element is not on the screen and so can't change
209
209
// this.controlDiv.offsetParent
210
210
if(this.origText===editor.getValue()||
211
-
this.addingScrubber){
211
+
this.addingScrubber){
212
212
console.log("Fake change event, skipping the log");
213
213
return;
214
214
}
@@ -232,16 +232,16 @@ export class ActiveCode extends RunestoneBase {
232
232
}.bind(this)
233
233
);// use bind to preserve *this* inside the on handler.
234
234
//Solving Keyboard Trap of ActiveCode: If user use tab for navigation outside of ActiveCode, then change tab behavior in ActiveCode to enable tab user to tab out of the textarea
235
-
$(window).keydown(function(e){
235
+
$(window).keydown(function(e){
236
236
varcode=e.keyCode ? e.keyCode : e.which;
237
237
if(code==9&&$("textarea:focus").length===0){
238
238
editor.setOption("extraKeys",{
239
-
Tab: function(cm){
239
+
Tab: function(cm){
240
240
$(document.activeElement)
241
241
.closest(".tab-content")
242
242
.nextSibling.focus();
243
243
},
244
-
"Shift-Tab": function(cm){
244
+
"Shift-Tab": function(cm){
245
245
$(document.activeElement)
246
246
.closest(".tab-content")
247
247
.previousSibling.focus();
@@ -361,7 +361,7 @@ export class ActiveCode extends RunestoneBase {
361
361
this.showHideButt=butt;
362
362
ctrlDiv.appendChild(butt);
363
363
$(butt).click(
364
-
function(){
364
+
function(){
365
365
$(this.codeDiv).toggle();
366
366
if(this.historyScrubber==null){
367
367
this.addHistoryScrubber(true);
@@ -407,7 +407,7 @@ export class ActiveCode extends RunestoneBase {
407
407
this.atButton=butt;
408
408
ctrlDiv.appendChild(butt);
409
409
$(butt).click(
410
-
function(){
410
+
function(){
411
411
newAudioTour(
412
412
this.divid,
413
413
this.code,
@@ -426,7 +426,7 @@ export class ActiveCode extends RunestoneBase {
426
426
this.shareButt=butt;
427
427
ctrlDiv.appendChild(butt);
428
428
$(butt).click(
429
-
asyncfunction(){
429
+
asyncfunction(){
430
430
if(
431
431
!confirm(
432
432
"You are about to share this code with ALL of your students. Are you sure you want to continue?"
@@ -440,8 +440,7 @@ export class ActiveCode extends RunestoneBase {
440
440
lang: this.language,
441
441
};
442
442
letrequest=newRequest(
443
-
eBookConfig.ajaxURL+"broadcast_code.json",
444
-
{
443
+
eBookConfig.ajaxURL+"broadcast_code.json",{
445
444
method: "POST",
446
445
headers: this.jsonHeaders,
447
446
body: JSON.stringify(data),
@@ -468,7 +467,7 @@ export class ActiveCode extends RunestoneBase {
468
467
$(plabel).text("Pair?");
469
468
ctrlDiv.appendChild(plabel);
470
469
$(checkPartner).click(
471
-
function(){
470
+
function(){
472
471
if(this.partner){
473
472
this.partner=false;
474
473
$(partnerTextBox).hide();
@@ -480,8 +479,8 @@ export class ActiveCode extends RunestoneBase {
480
479
if(!didAgree){
481
480
didAgree=confirm(
482
481
"Pair Programming should only be used with the consent of your instructor."+
483
-
"Your partner must be a registered member of the class and have agreed to pair with you."+
484
-
"By clicking OK you certify that both of these conditions have been met."
482
+
"Your partner must be a registered member of the class and have agreed to pair with you."+
483
+
"By clicking OK you certify that both of these conditions have been met."
485
484
);
486
485
if(didAgree){
487
486
localStorage.setItem("partnerAgree","true");
@@ -500,7 +499,7 @@ export class ActiveCode extends RunestoneBase {
500
499
ctrlDiv.appendChild(partnerTextBox);
501
500
$(partnerTextBox).hide();
502
501
$(partnerTextBox).change(
503
-
function(){
502
+
function(){
504
503
this.partner=partnerTextBox.value;
505
504
}.bind(this)
506
505
);
@@ -524,21 +523,21 @@ export class ActiveCode extends RunestoneBase {
524
523
$(butt).attr(
525
524
"href",
526
525
"http://"+
527
-
chatcodesServer+
528
-
"/new?"+
529
-
$.param({
530
-
topic: window.location.host+"-"+this.divid,
531
-
code: this.editor.getValue(),
532
-
lang: "Python",
533
-
})
526
+
chatcodesServer+
527
+
"/new?"+
528
+
$.param({
529
+
topic: window.location.host+"-"+this.divid,
530
+
code: this.editor.getValue(),
531
+
lang: "Python",
532
+
})
534
533
);
535
534
this.chatButton=butt;
536
535
chatBar.appendChild(butt);
537
-
varupdateChatCodesChannels=function(){
536
+
varupdateChatCodesChannels=function(){
538
537
vardata=doc.data;
539
538
vari=1;
540
539
$(channels).html("");
541
-
data["channels"].forEach(function(channel){
540
+
data["channels"].forEach(function(channel){
542
541
if(!channel.archived&&topic===channel.topic){
543
542
varlink=$("<a />");
544
543
varhref=
@@ -581,16 +580,14 @@ export class ActiveCode extends RunestoneBase {
0 commit comments