Skip to content

Commit

Permalink
Merge pull request #13 from cdavid14/master
Browse files Browse the repository at this point in the history
FIX onready load js
  • Loading branch information
onrik authored Jul 31, 2024
2 parents 8611ee6 + 1f09347 commit a88bdc6
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 26 deletions.
54 changes: 54 additions & 0 deletions webshell/static/css/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,57 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
visibility: hidden;
}
}

/**
Name: IntelliJ IDEA darcula theme
From IntelliJ IDEA by JetBrains
*/

.cm-s-darcula { font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;}
.cm-s-darcula.CodeMirror { background: #2B2B2B; color: #A9B7C6; }

.cm-s-darcula span.cm-meta { color: #BBB529; }
.cm-s-darcula span.cm-number { color: #6897BB; }
.cm-s-darcula span.cm-keyword { color: #CC7832; line-height: 1em; font-weight: bold; }
.cm-s-darcula span.cm-def { color: #A9B7C6; font-style: italic; }
.cm-s-darcula span.cm-variable { color: #A9B7C6; }
.cm-s-darcula span.cm-variable-2 { color: #A9B7C6; }
.cm-s-darcula span.cm-variable-3 { color: #9876AA; }
.cm-s-darcula span.cm-type { color: #AABBCC; font-weight: bold; }
.cm-s-darcula span.cm-property { color: #FFC66D; }
.cm-s-darcula span.cm-operator { color: #A9B7C6; }
.cm-s-darcula span.cm-string { color: #6A8759; }
.cm-s-darcula span.cm-string-2 { color: #6A8759; }
.cm-s-darcula span.cm-comment { color: #61A151; font-style: italic; }
.cm-s-darcula span.cm-link { color: #CC7832; }
.cm-s-darcula span.cm-atom { color: #CC7832; }
.cm-s-darcula span.cm-error { color: #BC3F3C; }
.cm-s-darcula span.cm-tag { color: #629755; font-weight: bold; font-style: italic; text-decoration: underline; }
.cm-s-darcula span.cm-attribute { color: #6897bb; }
.cm-s-darcula span.cm-qualifier { color: #6A8759; }
.cm-s-darcula span.cm-bracket { color: #A9B7C6; }
.cm-s-darcula span.cm-builtin { color: #FF9E59; }
.cm-s-darcula span.cm-special { color: #FF9E59; }
.cm-s-darcula span.cm-matchhighlight { color: #FFFFFF; background-color: rgba(50, 89, 48, .7); font-weight: normal;}
.cm-s-darcula span.cm-searching { color: #FFFFFF; background-color: rgba(61, 115, 59, .7); font-weight: normal;}

.cm-s-darcula .CodeMirror-cursor { border-left: 1px solid #A9B7C6; }
.cm-s-darcula .CodeMirror-activeline-background { background: #323232; }
.cm-s-darcula .CodeMirror-gutters { background: #313335; border-right: 1px solid #313335; }
.cm-s-darcula .CodeMirror-guttermarker { color: #FFEE80; }
.cm-s-darcula .CodeMirror-guttermarker-subtle { color: #D0D0D0; }
.cm-s-darcula .CodeMirrir-linenumber { color: #606366; }
.cm-s-darcula .CodeMirror-matchingbracket { background-color: #3B514D; color: #FFEF28 !important; font-weight: bold; }

.cm-s-darcula div.CodeMirror-selected { background: #214283; }

.CodeMirror-hints.darcula {
font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
color: #9C9E9E;
background-color: #3B3E3F !important;
}

.CodeMirror-hints.darcula .CodeMirror-hint-active {
background-color: #494D4E !important;
color: #9C9E9E !important;
}
55 changes: 29 additions & 26 deletions webshell/templates/webshell/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,40 @@
</form>
</div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById('id_source'), {
mode: {
name: "python",
version: 2,
singleLineStringErrors: false
},
lineNumbers: true,
indentUnit: 4,
tabMode: "shift",
matchBrackets: true,
extraKeys: {
"Cmd-Enter": function(instance) {
executeSource();
return false;
django.jQuery(document).ready(function(){
var editor = CodeMirror.fromTextArea(document.getElementById('id_source'), {
mode: {
name: "python",
version: 2,
singleLineStringErrors: false
},
"Ctrl-Enter": function(instance) {
executeSource();
return false;
theme: "darcula",
lineNumbers: true,
indentUnit: 4,
tabMode: "shift",
matchBrackets: true,
extraKeys: {
"Cmd-Enter": function(instance) {
executeSource();
return false;
},
"Ctrl-Enter": function(instance) {
executeSource();
return false;
}
}
});

if (navigator.platform.search('MacIntel') >=0) {
django.jQuery('#id_execute').text('{% trans "Execute" %} (Cmd+Enter)');
}
});

if (navigator.platform.search('MacIntel') >=0) {
django.jQuery('#id_execute').text('{% trans "Execute" %} (Cmd+Enter)');
}

var webshellEditor = django.jQuery('#id_output'),
csrf_token = django.jQuery('input[name="csrfmiddlewaretoken"]').val();

var webshellEditor = django.jQuery('#id_output'),
csrf_token = django.jQuery('input[name="csrfmiddlewaretoken"]').val();
})

function executeSource(){
webshellEditor.text('Executing...');
webshellEditor.text('{% trans "Executing..." %}');
django.jQuery.post('{% url "execute-script" %}',
{'source': editor.getValue(), 'csrfmiddlewaretoken': csrf_token},
function(response){
Expand Down

0 comments on commit a88bdc6

Please sign in to comment.