Skip to content

Instantly share code, notes, and snippets.

@CreeJee
Last active January 22, 2017 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CreeJee/30ae798f2cd6dd3b318fc66e270822f2 to your computer and use it in GitHub Desktop.
Save CreeJee/30ae798f2cd6dd3b318fc66e270822f2 to your computer and use it in GitHub Desktop.
when I'm not using eval than anything have solution?
var fn = {};
fn.listPlugins = function(cb){
if (!Array.isArray(this.plugins)) {
$.getJSON('/plugins/list.json',(json, textStatus) => {
if (textStatus == "success") {
this.plugins = json;
if (typeof cb == "function") {
cb(json);
}
else{
return json;
}
}
});
}
else{
if (typeof cb == "function") {
cb(this.plugins);
}
else{
return this.plugins;
}
}
}
fn.getPlugins = function(name,filePath){
if(Array.isArray(name) && filePath === undefined){
this.listPlugins((plugins)=>{
for(var k of name){
this.getPlugins(k,plugins[k].path);
console.log(k,plugins[k].path)
}
})
}
else{
$.getScript(filePath, (data, textStatus) => {
if(textStatus == "success")
{
this[name] = eval(data);
}
});
}
}
//list.json
{
"Draw":{
"path" : "/plugins/Draw.js",
"description" : "test"
},
"Math":{
"path" : "/plugins/Math.js",
"description" : "test"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment