lint sandbox

This commit is contained in:
Berkeley Martinez
2015-08-27 11:40:06 -07:00
parent ce364b472f
commit 45c0c710e0

View File

@ -1,19 +1,20 @@
/* global jailed */
var printCallback;
// sends the input to the plugin for evaluation
var submit = function(code,callback) {
function submit(code, callback) {
printCallback = callback;
// postpone the evaluation until the plugin is initialized
plugin.whenConnected(
function() {
if (requests == 0) {
plugin.whenConnected(function() {
if (requests === 0) {
startLoading();
}
requests++;
plugin.remote.run(code);
});
}
);
};
// puts the message on the terminal
var print = function(cls, msg) {
@ -41,6 +42,7 @@ var api = {
output: function(data) {
endLoading();
// print('input', data.input);
if (data.error) {
print('Error', data);
reset();
@ -60,8 +62,6 @@ var path = scripts[scripts.length-1].src
.slice(0, -1)
.join('/') + '/';
var requests;
// (re)initializes the plugin
@ -72,17 +72,19 @@ var reset = function() {
// give some time to handle the last responce
setTimeout( function() {
endLoading();
console.log("resetting on fatal plugin error");
console.log('resetting on fatal plugin error');
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();
}, 10);
});
};
// initialize everything
var plugin = null;