|
@@ -169,3 +169,34 @@ function s4() {
|
|
|
function UUID() {
|
|
function UUID() {
|
|
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// Based on original pub/sub implementation from http://davidwalsh.name/pubsub-javascript
|
|
|
|
|
+var huePubSub = (function () {
|
|
|
|
|
+ var topics = {};
|
|
|
|
|
+ var hOP = topics.hasOwnProperty;
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ subscribe: function (topic, listener) {
|
|
|
|
|
+ if(! hOP.call(topics, topic)) {
|
|
|
|
|
+ topics[topic] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var index = topics[topic].push(listener) - 1;
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ remove: function () {
|
|
|
|
|
+ delete topics[topic][index];
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ publish: function (topic, info) {
|
|
|
|
|
+ if (! hOP.call(topics, topic)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ topics[topic].forEach(function (item) {
|
|
|
|
|
+ item(info != undefined ? info : {});
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+})();
|