lint sandbox
This commit is contained in:
@ -1,19 +1,20 @@
|
|||||||
|
/* global jailed */
|
||||||
var printCallback;
|
var printCallback;
|
||||||
|
|
||||||
// sends the input to the plugin for evaluation
|
// sends the input to the plugin for evaluation
|
||||||
var submit = function(code,callback) {
|
function submit(code, callback) {
|
||||||
printCallback = callback;
|
printCallback = callback;
|
||||||
|
|
||||||
// postpone the evaluation until the plugin is initialized
|
// postpone the evaluation until the plugin is initialized
|
||||||
plugin.whenConnected(
|
plugin.whenConnected(function() {
|
||||||
function() {
|
if (requests === 0) {
|
||||||
if (requests == 0) {
|
|
||||||
startLoading();
|
startLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
requests++;
|
requests++;
|
||||||
plugin.remote.run(code);
|
plugin.remote.run(code);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// puts the message on the terminal
|
// puts the message on the terminal
|
||||||
var print = function(cls, msg) {
|
var print = function(cls, msg) {
|
||||||
@ -41,6 +42,7 @@ var api = {
|
|||||||
output: function(data) {
|
output: function(data) {
|
||||||
endLoading();
|
endLoading();
|
||||||
// print('input', data.input);
|
// print('input', data.input);
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
print('Error', data);
|
print('Error', data);
|
||||||
reset();
|
reset();
|
||||||
@ -60,8 +62,6 @@ var path = scripts[scripts.length-1].src
|
|||||||
.slice(0, -1)
|
.slice(0, -1)
|
||||||
.join('/') + '/';
|
.join('/') + '/';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var requests;
|
var requests;
|
||||||
|
|
||||||
// (re)initializes the plugin
|
// (re)initializes the plugin
|
||||||
@ -72,17 +72,19 @@ var reset = function() {
|
|||||||
// give some time to handle the last responce
|
// give some time to handle the last responce
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
endLoading();
|
endLoading();
|
||||||
console.log("resetting on fatal plugin error");
|
console.log('resetting on fatal plugin error');
|
||||||
|
|
||||||
if (challengeType === 0) {
|
if (challengeType === 0) {
|
||||||
codeOutput.setValue("Sorry, your code is either too slow, has a fatal error, or contains an infinite loop.");
|
codeOutput.setValue(
|
||||||
|
'Sorry, your code is either too slow, has a fatal error, ' +
|
||||||
|
'or contains an infinite loop.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
}, 10);
|
}, 10);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// initialize everything
|
// initialize everything
|
||||||
var plugin = null;
|
var plugin = null;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user