Skip to content

Commit

Permalink
Merge pull request #47 from EmpowrOrg/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dri94 authored Oct 13, 2022
2 parents 961fa50 + 90b268f commit 1fcfcfb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions swiftplugin/swiftplugin/static/js/src/swiftplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ function SwiftPluginXBlock(runtime, element) {
var solutionCodeMirror = null;

const run_btn = document.getElementById('run-btn');
run_btn.onclick = function (eventObject) {

function getCodeAndMode() {
var user_code = myCodeMirror.getValue()
var code_mode = myCodeMirror.getMode()
var code_mode = myCodeMirror.getMode()
var mode = code_mode.helperType ? code_mode.helperType : code_mode.name;
return {user_code, mode};
}

run_btn.onclick = function (eventObject) {
const {user_code, mode} = getCodeAndMode();
$.ajax({
type: "POST",
url: handlerUrl,
Expand All @@ -24,11 +30,11 @@ function SwiftPluginXBlock(runtime, element) {

const submit_btn = document.getElementById('submit-btn');
submit_btn.onclick = function (eventObject) {
var user_code = myCodeMirror.getValue();
const {user_code, mode} = getCodeAndMode();
$.ajax({
type: "POST",
url: handlerUrl,
data: JSON.stringify({type: 'submit', code: user_code}),
data: JSON.stringify({type: 'submit', code: user_code, language: mode}),
success: updateResponse
});
}
Expand Down

0 comments on commit 1fcfcfb

Please sign in to comment.