Difference between revisions of "Widget:CodeExplorer"

From Coder Merlin
Line 59: Line 59:
                     event.preventDefault();
                     event.preventDefault();


                     // Disable submit button
                     // Disable buttons
                    var executeButton = $("#codeEditorExecuteButton<!--{$uniqueID|validate:int}-->");
                     var submitButton = $("#codeEditorSubmitButton<!--{$uniqueID|validate:int}-->");
                     var submitButton = $("#codeEditorSubmitButton<!--{$uniqueID|validate:int}-->");
                    var executeButtonBackgroundColor = executeButton.css("background-color");
                     var submitButtonBackgroundColor = submitButton.css("background-color");
                     var submitButtonBackgroundColor = submitButton.css("background-color");
                    executeButton.attr("disabled", true);
                    executeButton.css("background-color", "gray");
                     submitButton.attr("disabled", true);
                     submitButton.attr("disabled", true);
                     submitButton.css("background-color", "gray");
                     submitButton.css("background-color", "gray");
Line 107: Line 111:
                         $("#codeEditorCombinedOutput<!--{$uniqueID|validate:int}-->").append(standardOutput);
                         $("#codeEditorCombinedOutput<!--{$uniqueID|validate:int}-->").append(standardOutput);


                         // Re-enable submit button
                         // Re-enable buttons
                        executeButton.attr("disabled", false);
                         submitButton.attr("disabled", false);
                         submitButton.attr("disabled", false);
                        executeButton.css("background-color", executeButtonBackgroundColor);
                         submitButton.css("background-color", submitButtonBackgroundColor);
                         submitButton.css("background-color", submitButtonBackgroundColor);
                       });
                       });

Revision as of 20:51, 15 June 2021

Parameters:

userName
The current user's username
uniqueID
integer: id for editor, must be unique per page
width
integer|string: percentage (as string, e.g. "100%" or integer size in pixels), null for no change (full width)
height
integer|string: percentage (as string, e.g. "100%" or integer size in pixels), null for no change (~10 lines)
lineNumbers
boolean: true to display line numbers
theme
string: name of theme (which must be loaded via css)
readOnly
boolean: true if editing should be disabled
mode
string: language for highlighting (which must be loaded via js)
initialCode
string: initial code to place in editor

Example:

{{#widget:CodeExplorer
|userName=john-williams
|uniqueID=10
|width=null
|height=null
|lineNumbers=true
|theme=vibrant-ink
|readOnly=false
|mode=swift
|initialCode=func sayHello() {
    print("Hello, World!")
}
}}