Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Plugins data format
- {
- info: {
- name = "OnJoin Example",
- version = "0.01",
- minVersion = "2.2"
- },
- <event>: function(<arguments>){
- <event handling code>
- },
- options: {
- <name>:{
- type: <'bool'|'int'|'array'|'string'>,
- default: <default value>
- }
- },
- }
- Option data format
- {
- name: <name of option>,
- type: <'bool'|'int'|'array'|'string'>,
- value: <current value>,
- plugin: <reference to plugin>
- }
- */
- (function( window, undefined ) {
- var Plugins;
- var Options = [
- // default values here
- ];
- Plugins.init = function(){
- for(var i in this.list){
- if(this[i].options!=undefined){
- var options = this[i].options;
- for(var ii in options){
- var o = {
- type: options[ii].type,
- plugin: this[i],
- name: ii,
- value: window.isset(ii,options[ii])
- };
- Options.push(o);
- }
- }
- }
- };
- Plugins.parse = function(event,data){
- // event is a string containing the signal name (ie: 'join')
- // data is an array of all the arguements to pass to the function
- var output = true;
- for(var i in this.list){
- if(this[i][event]!=undefined){
- // call the function with the right scope, and pass on the right arguements
- var r = this[i][event].apply(this[i],data);
- switch(r){
- case PLUGIN_BREAK:
- return output;
- break;
- case PLUGIN_NO_OUTPUT:
- output = false;
- break;
- }
- }
- }
- return output;
- };
- Plugins.add = funciton(plugin){
- return plugins.list.push(plugin);
- };
- Plugins.options = function(){
- // render the options panel based on options
- };
- Plugins.list = [];
- window.Plugins = Plugins;
- window.Options = Options;
- window.isset = function(ref,option){
- if(/* setting exists */){
- return /* setting */;
- }
- return ref.default;
- }
- })(window);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement