Skip to content

Instantly share code, notes, and snippets.

@jackaperkins
Last active February 15, 2016 20:08
Show Gist options
  • Save jackaperkins/e019227cbc49b3386b1e to your computer and use it in GitHub Desktop.
Save jackaperkins/e019227cbc49b3386b1e to your computer and use it in GitHub Desktop.
plugin format
// our plugin data that comes back from the plugin API
var plugin = {
name: "jacks cool script",
body: "var p ={actionName: \"orderPizza\", action: function () { var x = 1;}}"
}
// body is a string of raw javascript code, not JSON encoded;
// when we call eval on it, it'll create a local variable which we can then use:
var p = {
actionName: "orderPizza",
action: function () {
var $pizza = new PizzaAPI();
$Pizza.order(); // ... custom code
},
command: "order (me a) pizza"
}
// inside aubrey's plugin loading:
eval(plugin.body);
addPlugin(p);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment