Add new currying challenge to bonfires and allow inspectlet through protective helmet
This commit is contained in:
4
app.js
4
app.js
@ -158,7 +158,9 @@ var trusted = [
|
||||
'wss://hub.togetherjs.com',
|
||||
'*.ytimg.com',
|
||||
'wss://fcctogether.herokuapp.com',
|
||||
'*.bitly.com'
|
||||
'*.bitly.com',
|
||||
'http://cdn.inspectlet.com/',
|
||||
'http://hn.inspectlet.com/'
|
||||
];
|
||||
|
||||
app.use(helmet.contentSecurityPolicy({
|
||||
|
@ -67,7 +67,7 @@ var requests;
|
||||
// (re)initializes the plugin
|
||||
var reset = function() {
|
||||
requests = 0;
|
||||
plugin = new jailed.Plugin(path+'plugin_v0.1.4.js', api);
|
||||
plugin = new jailed.Plugin(path+'plugin_v0.1.5.js', api);
|
||||
plugin.whenDisconnected( function() {
|
||||
// give some time to handle the last responce
|
||||
setTimeout( function() {
|
||||
|
@ -1,82 +0,0 @@
|
||||
|
||||
// executes the given code and handles the result
|
||||
var run = function(code) {
|
||||
var result = {
|
||||
input: code,
|
||||
output: null,
|
||||
error: null,
|
||||
type: null
|
||||
};
|
||||
|
||||
try {
|
||||
var codeExec = runHidden(code);
|
||||
result.type = typeof codeExec;
|
||||
result.output = stringify(codeExec);
|
||||
} catch(e) {
|
||||
result.error = e.message;
|
||||
}
|
||||
|
||||
application.remote.output(result);
|
||||
self.close();
|
||||
};
|
||||
|
||||
|
||||
// protects even the worker scope from being accessed
|
||||
var runHidden = function(code) {
|
||||
|
||||
var importScript = function(url) {
|
||||
var error = null;
|
||||
try {
|
||||
importScripts(url);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
console.log('Unable to load ramda!');
|
||||
}
|
||||
};
|
||||
var indexedDB = null;
|
||||
var location = null;
|
||||
var navigator = null;
|
||||
var onerror = null;
|
||||
var onmessage = null;
|
||||
var performance = null;
|
||||
var self = null;
|
||||
var webkitIndexedDB = null;
|
||||
var postMessage = null;
|
||||
var close = null;
|
||||
var openDatabase = null;
|
||||
var openDatabaseSync = null;
|
||||
var webkitRequestFileSystem = null;
|
||||
var webkitRequestFileSystemSync = null;
|
||||
var webkitResolveLocalFileSystemSyncURL = null;
|
||||
var webkitResolveLocalFileSystemURL = null;
|
||||
var addEventListener = null;
|
||||
var dispatchEvent = null;
|
||||
var removeEventListener = null;
|
||||
var dump = null;
|
||||
var onoffline = null;
|
||||
var ononline = null;
|
||||
importScript("https://cdn.jsdelivr.net/ramda/0.10.0/ramda.min.js");
|
||||
var _ = R;
|
||||
|
||||
|
||||
return eval(code);
|
||||
}
|
||||
|
||||
|
||||
// converts the output into a string
|
||||
var stringify = function(output) {
|
||||
var result;
|
||||
|
||||
if (typeof output == 'undefined') {
|
||||
result = 'undefined';
|
||||
} else if (output === null) {
|
||||
result = 'null';
|
||||
} else {
|
||||
result = JSON.stringify(output) || output.toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
application.setInterface({run:run});
|
88
public/js/lib/bonfire/plugin_v0.1.5.js
Normal file
88
public/js/lib/bonfire/plugin_v0.1.5.js
Normal file
@ -0,0 +1,88 @@
|
||||
|
||||
// executes the given code and handles the result
|
||||
var run = function(code) {
|
||||
var result = {
|
||||
input: code,
|
||||
output: null,
|
||||
error: null,
|
||||
type: null
|
||||
};
|
||||
|
||||
try {
|
||||
var codeExec = runHidden(code);
|
||||
result.type = typeof codeExec;
|
||||
result.output = stringify(codeExec);
|
||||
} catch(e) {
|
||||
result.error = e.message;
|
||||
}
|
||||
|
||||
application.remote.output(result);
|
||||
self.close();
|
||||
};
|
||||
|
||||
|
||||
// protects even the worker scope from being accessed
|
||||
var runHidden = function(code) {
|
||||
|
||||
var importScript = function(url) {
|
||||
var error = null;
|
||||
try {
|
||||
importScripts(url);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
console.log('Unable to load %s!', url);
|
||||
}
|
||||
};
|
||||
var indexedDB = null;
|
||||
var location = null;
|
||||
var navigator = null;
|
||||
var onerror = null;
|
||||
var onmessage = null;
|
||||
var performance = null;
|
||||
var self = null;
|
||||
var webkitIndexedDB = null;
|
||||
var postMessage = null;
|
||||
var close = null;
|
||||
var openDatabase = null;
|
||||
var openDatabaseSync = null;
|
||||
var webkitRequestFileSystem = null;
|
||||
var webkitRequestFileSystemSync = null;
|
||||
var webkitResolveLocalFileSystemSyncURL = null;
|
||||
var webkitResolveLocalFileSystemURL = null;
|
||||
var addEventListener = null;
|
||||
var dispatchEvent = null;
|
||||
var removeEventListener = null;
|
||||
var dump = null;
|
||||
var onoffline = null;
|
||||
var ononline = null;
|
||||
importScripts(
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/ramda/0.13.0/ramda.min.js");
|
||||
importScripts(
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/chai/2.2.0/chai.min.js"
|
||||
)
|
||||
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
|
||||
|
||||
return eval(code);
|
||||
}
|
||||
|
||||
|
||||
// converts the output into a string
|
||||
var stringify = function(output) {
|
||||
var result;
|
||||
|
||||
if (typeof output == 'undefined') {
|
||||
result = 'undefined';
|
||||
} else if (output === null) {
|
||||
result = 'null';
|
||||
} else {
|
||||
result = JSON.stringify(output) || output.toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
application.setInterface({run:run});
|
@ -1,7 +1,7 @@
|
||||
// MDN Links
|
||||
|
||||
/* These links are for Bonfires. Each key/value pair is used to render a Bonfire with approrpiate links.
|
||||
|
||||
|
||||
|
||||
The text of the key is what the link text will be, e.g. <a href="https://developer ...">Global Array Object</a>
|
||||
General convention is to use the page title of the MDN reference page.
|
||||
@ -14,11 +14,12 @@ var links =
|
||||
"Global String Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
|
||||
"Boolean Objects" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean",
|
||||
"RegExp" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp",
|
||||
"Global Function Object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",
|
||||
"Arguments object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments",
|
||||
|
||||
// ========= PROPERTIES/MISC
|
||||
"String.length" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length",
|
||||
|
||||
|
||||
|
||||
// ========== OBJECT METHODS
|
||||
"Object.getOwnPropertyNames()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
|
||||
@ -68,7 +69,7 @@ var links =
|
||||
"Math.min()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min",
|
||||
"Math.pow()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow",
|
||||
"Remainder" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder_(.25)",
|
||||
|
||||
|
||||
// ======== GENERAL JAVASCRIPT REFERENCES
|
||||
"Arithmetic Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators",
|
||||
"Comparison Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators",
|
||||
|
@ -562,6 +562,23 @@
|
||||
],
|
||||
"MDNlinks" : ["Object.hasOwnProperty()", "Object.getOwnPropertyNames()"]
|
||||
},
|
||||
{
|
||||
"_id": "a97fd23d9b809dac9921074f",
|
||||
"name": "Arguments Optional",
|
||||
"difficulty": "2.22",
|
||||
"description": [
|
||||
"Create a function that sums two arguments together. If only one argument is provided, return a function that expects one additional argument and will return the sum.",
|
||||
"For example, add(2, 3) should return 5, and add(2) should return a function that is waiting for an argument so that <code>var sum2And = add(2); return sum2And(3); // 5</code>",
|
||||
"If either argument isn't a valid numbers, return undefined"
|
||||
],
|
||||
"challengeSeed": "function add() {\n return false;\n}\n\nadd(2,3);",
|
||||
"tests": [
|
||||
"expect(add(2, 3)).to.equal(5);",
|
||||
"expect(add(2)(3)).to.equal(5);",
|
||||
"expect(add('http://bit.ly/IqT6zt')).to.be.undefined;"
|
||||
],
|
||||
"MDNlinks": ["Global Function Object", "Arguments object"]
|
||||
},
|
||||
{
|
||||
"_id": "a2f1d72d9b908d0bd72bb9f6",
|
||||
"name": "Make a Person",
|
||||
|
@ -15,7 +15,7 @@ block content
|
||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||
script(src='/js/lib/jailed/jailed.js')
|
||||
script(src='/js/lib/bonfire/bonfireInit.js')
|
||||
script(src="https://cdn.jsdelivr.net/ramda/0.10.0/ramda.min.js")
|
||||
script(src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.13.0/ramda.min.js")
|
||||
|
||||
|
||||
.row
|
||||
|
Reference in New Issue
Block a user