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

Commit ff0d73b

Browse files
committed
When use_services is false do not display elements that would need to use services.
1 parent b55cca4 commit ff0d73b

File tree

4 files changed

+53
-40
lines changed

4 files changed

+53
-40
lines changed

runestone/activecode/js/activecode.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ActiveCode.prototype.init = function(opts) {
2020
var _this = this;
2121
var suffStart = -1;
2222
var orig = opts.orig
23+
this.useRunestoneServices = opts.useRunestoneServices;
2324
this.origElem = orig;
2425
this.divid = orig.id;
2526
this.code = $(orig).text();
@@ -112,26 +113,29 @@ ActiveCode.prototype.createControls = function () {
112113
$(butt).click(this.runProg.bind(this));
113114

114115
// Save
115-
butt = document.createElement("button");
116-
$(butt).addClass("ac_opt btn btn-default");
117-
$(butt).text("Save");
118-
$(butt).css("margin-left","10px");
119-
this.saveButton = butt;
120-
ctrlDiv.appendChild(butt);
121-
if (this.hidecode) {
122-
$(butt).css("display","none")
116+
if (this.useRunestoneServices) {
117+
butt = document.createElement("button");
118+
$(butt).addClass("ac_opt btn btn-default");
119+
$(butt).text("Save");
120+
$(butt).css("margin-left", "10px");
121+
this.saveButton = butt;
122+
ctrlDiv.appendChild(butt);
123+
if (this.hidecode) {
124+
$(butt).css("display", "none")
125+
}
123126
}
124127
// Load
125-
butt = document.createElement("button");
126-
$(butt).addClass("ac_opt btn btn-default");
127-
$(butt).text("Load");
128-
$(butt).css("margin-left","10px");
129-
this.loadButton = butt;
130-
ctrlDiv.appendChild(butt);
131-
if (this.hidecode) {
132-
$(butt).css("display","none")
128+
if (this.useRunestoneServices) {
129+
butt = document.createElement("button");
130+
$(butt).addClass("ac_opt btn btn-default");
131+
$(butt).text("Load");
132+
$(butt).css("margin-left", "10px");
133+
this.loadButton = butt;
134+
ctrlDiv.appendChild(butt);
135+
if (this.hidecode) {
136+
$(butt).css("display", "none")
137+
}
133138
}
134-
135139
if ($(this.origElem).data('gradebutton')) {
136140
butt = document.createElement("button");
137141
$(butt).addClass("ac_opt btn btn-default");
@@ -166,7 +170,7 @@ ActiveCode.prototype.createControls = function () {
166170
$(butt).click(this.showCodelens.bind(this));
167171
}
168172
// CodeCoach
169-
if ($(this.origElem).data("coach")) {
173+
if (this.useRunestoneServices && $(this.origElem).data("coach")) {
170174
butt = document.createElement("button");
171175
$(butt).addClass("ac_opt btn btn-default");
172176
$(butt).text("Code Coach");
@@ -1414,14 +1418,15 @@ LiveCode.prototype.pushDataFile = function (datadiv) {
14141418

14151419
$(document).ready(function() {
14161420
$('[data-component=activecode]').each( function(index ) {
1421+
var opts = {'orig' : this, 'useRunestoneServices': eBookConfig.useRunestoneServices }
14171422
if ($(this).data('lang') === "javascript") {
1418-
edList[this.id] = new JSActiveCode({'orig': this});
1423+
edList[this.id] = new JSActiveCode(opts);
14191424
} else if ($(this).data('lang') === 'htmlmixed') {
1420-
edList[this.id] = new HTMLActiveCode({'orig': this});
1425+
edList[this.id] = new HTMLActiveCode(opts);
14211426
} else if (['java', 'cpp', 'c', 'python3', 'python2'].indexOf($(this).data('lang')) > -1) {
1422-
edList[this.id] = new LiveCode({'orig': this});
1427+
edList[this.id] = new LiveCode(opts);
14231428
} else { // default is python
1424-
edList[this.id] = new ActiveCode({'orig': this});
1429+
edList[this.id] = new ActiveCode(opts);
14251430
}
14261431
});
14271432
if (loggedout) {

runestone/assess/js/mchoice.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ MultipleChoice.prototype.init = function (opts) {
4444
RunestoneBase.apply(this, arguments);
4545
var orig = opts.orig; // entire <ul> element
4646
this.origElem = orig;
47-
47+
this.useRunestoneServices = opts.useRunestoneServices;
4848
this.multipleanswers = false;
4949
this.divid = orig.id;
5050
if ($(this.origElem).data("multipleanswers") === true) {
@@ -243,18 +243,20 @@ MultipleChoice.prototype.renderMCFormButtons = function () {
243243
this.optsForm.appendChild(this.submitButton);
244244

245245
// Create compare button
246-
this.compareButton = document.createElement("button");
247-
$(this.compareButton).attr({
248-
"class": "btn btn-default",
249-
"id": this.divid + "_bcomp",
250-
"disabled": "",
251-
"name": "compare"
252-
});
253-
this.compareButton.textContent = "Compare me";
254-
this.compareButton.addEventListener("click", function () {
255-
this.compareAnswers(this.divid);
256-
}.bind(this), false);
257-
this.optsForm.appendChild(this.compareButton);
246+
if (this.useRunestoneServices) {
247+
this.compareButton = document.createElement("button");
248+
$(this.compareButton).attr({
249+
"class": "btn btn-default",
250+
"id": this.divid + "_bcomp",
251+
"disabled": "",
252+
"name": "compare"
253+
});
254+
this.compareButton.textContent = "Compare me";
255+
this.compareButton.addEventListener("click", function () {
256+
this.compareAnswers(this.divid);
257+
}.bind(this), false);
258+
this.optsForm.appendChild(this.compareButton);
259+
}
258260
};
259261

260262
MultipleChoice.prototype.renderMCfeedbackDiv = function () {
@@ -546,8 +548,9 @@ MultipleChoice.prototype.compareAnswers = function () {
546548
=================================*/
547549
$(document).ready(function () {
548550
$("[data-component=multiplechoice]").each(function (index) { // MC
551+
var opts = {"orig": this, 'useRunestoneServices':eBookConfig.useRunestoneServices};
549552
if ($(this.parentNode).data("component") !== "timedAssessment") { // If this element exists within a timed component, don't render it here
550-
mcList[this.id] = new MultipleChoice({"orig": this});
553+
mcList[this.id] = new MultipleChoice(opts);
551554
}
552555
});
553556

runestone/common/js/bookfuncs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,11 @@ function addDelay(directive, action, delay) {
243243

244244

245245
// initialize stuff
246-
$(document).ready(handleLoginLogout);
247-
$(document).ready(getNumUsers);
248-
$(document).ready(getOnlineUsers);
246+
if (eBookConfig.useRunestoneServices) {
247+
$(document).ready(handleLoginLogout);
248+
$(document).ready(getNumUsers);
249+
$(document).ready(getOnlineUsers);
250+
}
249251

250252
// misc stuff
251253
// todo: This could be further distributed but making a video.js file just for one function seems dumb.

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@
263263
<footer class="footer">
264264
<div class="container">
265265
<p class="pull-right">
266-
<span id='numuserspan'></span> readers online now | <span class='loggedinuser'></span> | <a href="#">Back to top</a>
266+
{% if use_services == 'true' %}
267+
<span id='numuserspan'></span> readers online now | <span class='loggedinuser'></span>
268+
{% endif %}
269+
| <a href="#">Back to top</a>
267270
{% if theme_source_link_position == "footer" %}
268271
<br />
269272
{% include "sourcelink.html" %}

0 commit comments

Comments
 (0)