MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / load

Function load

static/js/learnpython.js:220–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218
219
220function load() {
221 const loading = $("#loading");
222 const codeBlocks = $("code");
223 const outputTheme = "xq-light";
224 let mode;
225
226 if (document.getElementById("code")) {
227 if (window.domainData.language === "python") {
228 mode = {
229 name: "python",
230 version: 2,
231 singleLineStringErrors: false,
232 };
233 } else {
234 mode = window.domainData.codemirror_mode;
235 }
236
237 editor = CodeMirror.fromTextArea(document.getElementById("code"), {
238 lineNumbers: true,
239 indentUnit: 4,
240 tabMode: "shift",
241 mode: mode,
242 theme: "xq-light"
243 });
244
245 codeBlocks.addClass(window.domainData.prism_mode);
246 Prism.highlightAll();
247 } else {
248 editor = {
249 "getValue": function() {},
250 "setValue": function(x) {}
251 };
252 }
253
254 if (document.getElementById("output")) {
255 output = CodeMirror.fromTextArea(document.getElementById("output"), {
256 lineNumbers: false,
257 textWrapping: true,
258 readOnly : true,
259 theme: outputTheme,
260 mode: "text/plain"
261 });
262 }
263
264 originalCode = editor.getValue();
265
266 $("#inner-text pre.exec").after(
267 $("<button>").addClass("btn btn-sm btn-primary execute-code").text("Execute Code").click(function() {
268 maximizeDock();
269 var text = $(this).prev().text();
270 if (window.domainData.container_word && text.indexOf(window.domainData.container_word) === -1) {
271 var lines = text.split("\n");
272 var indentedText = "";
273 for (var i = 0; i < lines.length; i++) {
274 indentedText += window.domainData.container_indent + lines[i] + "\n";
275 }
276 text = window.domainData.container.replace("{code}", indentedText);
277

Callers 1

learnpython.jsFile · 0.85

Calls 5

maximizeDockFunction · 0.85
executeFunction · 0.85
getValueMethod · 0.80
setValueMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected