Advertisement
Eeems

omnomirc.plugins.js

Jul 12th, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Plugins data format
  3.     {
  4.         info: {
  5.             name = "OnJoin Example",
  6.             version = "0.01",
  7.             minVersion = "2.2"
  8.         },
  9.         <event>: function(<arguments>){
  10.             <event handling code>
  11.         },
  12.         options: {
  13.             <name>:{
  14.                 type: <'bool'|'int'|'array'|'string'>,
  15.                 default: <default value>
  16.             }
  17.         },
  18.     }
  19.     Option data format
  20.     {
  21.         name: <name of option>,
  22.         type: <'bool'|'int'|'array'|'string'>,
  23.         value: <current value>,
  24.         plugin: <reference to plugin>
  25.     }
  26. */
  27. (function( window, undefined ) {
  28.     var Plugins;
  29.     var Options = [
  30.         // default values here
  31.     ];
  32.    
  33.     Plugins.init = function(){
  34.         for(var i in this.list){
  35.             if(this[i].options!=undefined){
  36.                 var options = this[i].options;
  37.                 for(var ii in options){
  38.                     var o = {
  39.                         type: options[ii].type,
  40.                         plugin: this[i],
  41.                         name: ii,
  42.                         value: window.isset(ii,options[ii])
  43.                     };
  44.                     Options.push(o);
  45.                 }
  46.             }
  47.         }
  48.     };
  49.     Plugins.parse = function(event,data){
  50.         // event is a string containing the signal name (ie: 'join')
  51.         // data is an array of all the arguements to pass to the function
  52.         var output = true;
  53.         for(var i in this.list){
  54.             if(this[i][event]!=undefined){
  55.                 // call the function with the right scope, and pass on the right arguements
  56.                 var r = this[i][event].apply(this[i],data);
  57.                 switch(r){
  58.                     case PLUGIN_BREAK:
  59.                         return output;
  60.                     break;
  61.                     case PLUGIN_NO_OUTPUT:
  62.                         output = false;
  63.                     break;
  64.                 }
  65.             }
  66.         }
  67.         return output;
  68.     };
  69.     Plugins.add = funciton(plugin){
  70.         return plugins.list.push(plugin);
  71.     };
  72.     Plugins.options = function(){
  73.         // render the options panel based on options
  74.     };
  75.    
  76.     Plugins.list = [];
  77.     window.Plugins = Plugins;
  78.     window.Options = Options;
  79.     window.isset = function(ref,option){
  80.         if(/* setting exists */){
  81.             return /* setting */;
  82.         }
  83.         return ref.default;
  84.     }
  85. })(window);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement