PageSourceSearch

https://www.portolahotel.com/js/bundle/hdmbase.js

js portolahotel.com collected 2026-09-26 02:17:46 UTC 5,176 bytes, 157 lines download raw bytes

1var HDM = (function ($) {
2    var _createNs, _getNSString;
3    /**
4    * @method createNs
5    *
6    * @param (String) n  example "HDM.admin.wizard"
7    * @param (Object) o  example { "HDM" : { "admin": {} } } rarely used
8    * I think I got this from tinymce.
9    * Note that each node has a reference to its parent and a name.  This makes 
10    * constructing the namespace tree string more efficient.  Do I care?
11    * Otherwise you have to right some recursive search for the path down the namespace
12    * to the node.  That search could run into infinite loops and is quite the pain.
13    */
14    _createNs = function (n/*namespace*/, o/*starting place*/) {
15        var i, v;
16        o = o || window;
17        n = n.split('.');
18        for (i = 0; i < n.length; i++) {
19            v = n[i];
20            if (!o[v]) {
21                o[v] = {"__name":v, "__parent": o};//we want to be able to go back up this tree as well
22            }
23            o = o[v];
24        }
25        return o; //return last namespace object created
26    };
27
28    /**
29    *  Gets a string representing a namespace
30
31    *  @param ns a namespace leaf object from the namespace.
32    *         The admin part of this { "HDM":{ {"admin": {}} }}
33       @part optional for convience
34    */
35    _getNSString = function (ns, part) {
36        var nsString = "";
37        while (ns) {
38            nsString = ns.__name + (nsString !== ""?".":"") + nsString;
39            ns = ns.__parent;
40        }
41        if (part) {
42            nsString = nsString + "." + part;
43        }
44        return nsString;
45    };
46    return {
47        createNs: _createNs,
48        getNSString: _getNSString,
49        __name: "HDM"
50    };
51}(jQuery));
52
53HDM.createNs("HDM.eventbus");
54/*
55A very simple event bus.
56//a good refernce https://github.com/krasimir/EventBus/blob/master/src/EventBus.js
57*/
58HDM.eventbus.EventBus = (function () {
59
60    var _subscribe, _unsubscribe, _publish;
61
62    _subscribe = function (type, fn) {
63        type = type || "any";
64        if (typeof this.subscribers[type] === "undefined") {
65            this.subscribers[type] = [];
66        }
67        this.subscribers[type].push(fn);
68        return { "type":type, "function":fn };
69    };
70    _unsubscribe = function (type, fn) {
71        type = type || "any";
72        if (typeof this.subscribers[type] === "undefined") {
73            this.subscribers[type] = [];
74        }
75        for (var i = 0; i < this.subscribers[type].length; i++) {
76            if (this.subscribers[type][i] === fn) {
77                this.subscribers[type].splice(i, 1);
78            }
79        }
80    };
81    _publish = function (type, data) {
82        type = type || "any";
83        if (!(type in this.subscribers)) {
84            return; //no one subscribed
85        }
86        var who = this.subscribers[type];
87        for (var i = 0; i < who.length; i++) {
88            who[i](data);
89        }
90    };
91    var Constr = function () {
92        this.subscribers = {};
93        return this;
94    };
95
96    Constr.prototype = {
97        subscribe: _subscribe,
98        unsubscribe: _unsubscribe,
99        publish: _publish
100    };
101    return Constr;
102} ());
103/*
104*  pubsub is a wrapper around the event bus so that 
105   event buses can be created, subscribed to, published to by anyone 
106   regardless of whether the main publisher has set it up yet.
107*/
108HDM.pubsub = (function () {
109    var pubsubs = {}, _subscribe, _unsubscribe, _publish, _getEventBus;
110
111    /*
112      @param namespace is so we can have publishers have their own
113             event bus.  Making it easier to avoid event name collisions
114    */
115    _subscribe = function (topic, fn, namespace) {
116        var pubsub = _getEventBus(namespace);
117        pubsub.subscribe(topic, fn);
118        return { "type":topic, "function":fn, "namespace":namespace };
119    };
120    _unsubscribe = function (topic, fn, namespace) {
121        var pubsub = _getEventBus(namespace);
122        pubsub.unsubscribe(topic, fn);
123    };
124
125    /*
126      @param namespace is so we can have publishers have their own
127             event bus.  Making it easier to avoid event name collisions
128    */
129    _publish = function (topic, data, namespace) {
130        var pubsub = _getEventBus(namespace);
131        pubsub.publish(topic, data);
132    };
133    /*
134      @param namespace is a string.  For those that publish or subscribe to many events
135             it can be easier to just get a handle to the EventBus associated with 
136             that namespace and hold on to it.
137    */
138    _getEventBus = function (namespace) {
139        if (!namespace) {
140            namespace = "_default";
141        }
142        if (pubsubs[namespace]) {
143            return pubsubs[namespace];
144        }
145        var eventBus = new HDM.eventbus.EventBus();
146        pubsubs[namespace] = eventBus;
147        return eventBus;
148    };
149    return {
150        subscribe: _subscribe,
151        publish: _publish,
152        /* this is public so we can not have to specify namespace all over the place
153        like in classes that use the pubsub often */
154        getEventBus: _getEventBus
155
156    };
157} ());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.