//----------------------------------------------------- //- pingpong.js - Javascript Messaging Library //- Copyright 2012 Ohgyun Ahn (ohgyun@gmail.com) //- MIT Licensed //- //- https://github.com/ohgyun/pingpong //----------------------------------------------------- (function(h){var g={version:"0.1",subscribe:function(a,b,d){var f=new c(a),a=new l(a,b,d);j.register(f,a)},publish:function(a){var b=new c(a),d=Array.prototype.slice.call(arguments,1);d.push(a);j.runHandlers(b,d)},unsubscribe:function(a,b){var d=new c(a);j.remove(d,b)},ping:function(){this.publish.apply(this,arguments)},pong:function(){this.subscribe.apply(this,arguments)},pung:function(){this.unsubscribe.apply(this,arguments)},channel:function(a){return i.getInstance(a)}},i=function(a){this._channel= a},m=i.prototype;i._instances={};i.getInstance=function(a){var b=this._instances;b[a]=b[a]||new i(a);return b[a]};(function(){for(var a in g)g.hasOwnProperty(a)&&"function"===typeof g[a]&&function(a){m[a]=function(){var d=this._channel+c.SEPERATOR+(arguments[0]||""),f=Array.prototype.slice.call(arguments,1);f.unshift(d);return g[a].apply(g,f)}}(a)})();var c=function(a){this._topic=a;this._topicPieces=a.split(c.SEPERATOR);this.validate()},e=c.prototype;c.SEPERATOR=".";c.WILDCARD="*";c.VALIDATOR=/^\w+$/; e.validate=function(){this.eachTopicPiece(function(a,b){!c.VALIDATOR.test(a)&&!(b&&a===c.WILDCARD)&&n.throwError("INVALID_TOPIC")})};e.eachTopicPiece=function(a,b){var d=this._topicPieces.length,f,c;f=!1;for(var e=0;e