2025-01-19 23:59:24 +01:00
|
|
|
|
|
|
|
function fillForm(o) {
|
|
|
|
const output = document.querySelector('#LispPlaygroundOutput');
|
|
|
|
const return_ = document.querySelector('#LispPlaygroundReturn');
|
|
|
|
output.value = (o.hasOwnProperty("Output")) ? o.Output : o.Traceback;
|
|
|
|
return_.value = (o.hasOwnProperty("FinalExpression")) ? o.FinalExpression : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiClient.runLispProgram = function (program) {
|
|
|
|
const url = ApiClient.getUrl('LispPlayground');
|
|
|
|
return this.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: url,
|
|
|
|
dataType: 'json',
|
|
|
|
contentType: 'text/plain; charset=UTF-8',
|
|
|
|
data: program,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function initial_load() {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
}
|
|
|
|
|
2025-01-21 22:51:25 +01:00
|
|
|
export default function (view, params) {
|
|
|
|
view.addEventListener('viewshow', function() {
|
|
|
|
initial_load(null);
|
2025-01-19 23:59:24 +01:00
|
|
|
});
|
2025-01-21 22:51:25 +01:00
|
|
|
view.addEventListener('viewhide', function (_e) {});
|
|
|
|
view.addEventListener('viewdestroy', function (_e) {});
|
2025-01-19 23:59:24 +01:00
|
|
|
|
2025-01-21 22:51:25 +01:00
|
|
|
document.querySelector('#LispPlaygroundConfigPage')
|
|
|
|
.addEventListener('pageshow', function() {
|
|
|
|
initial_load();
|
|
|
|
});
|
2025-01-19 23:59:24 +01:00
|
|
|
|
2025-01-21 22:51:25 +01:00
|
|
|
document.querySelector('#LispPlaygroundConfigForm')
|
|
|
|
.addEventListener('submit', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
const editProgram = document.querySelector('#LispPlaygroundEditProgram');
|
|
|
|
ApiClient.runLispProgram(editProgram.value).then(function (r) {
|
|
|
|
fillForm(r);
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
});
|
2025-01-19 23:59:24 +01:00
|
|
|
});
|
2025-01-21 22:51:25 +01:00
|
|
|
}
|