PageSourceSearch

https://www.stardock.com/js/sd2017.hubs.js

js stardock.com collected 2026-09-24 08:34:19 UTC 6,454 bytes, 200 lines download raw bytes

1$.connection.hub.url = 'https://hubs.stardock.com/sockets';
2
3$(function () {
4    StardockHub.InitWebsockets();
5});
6
7
8var StardockHub = {
9    isRunning: false,
10    isOn: true,
11    isLoggedOn: false,
12    hubConnection: {},
13    InitWebsockets: function () {
14
15        setTimeout(
16         function () {
17
18            $.connection.hub.url = 'https://hubs.stardock.com/sockets';
19            StardockHub.hubConnection = $.connection("https://hubs.stardock.com/sockets");
20            sdHubProxy = $.connection.stardockWebsiteSharedHub;
21    
22            // Register Guest Hub Events
23            sdHubProxy.client.cart_Changed = function (cart) {
24                StardockHub.onCart_Changed(cart, true);
25            };
26    
27            sdHubProxy.client.stopClient = function () {
28                StardockHub.hubConnection.stop();
29            };
30    
31	         if ($('#account-trigger').hasClass('loggedin') // www.stardock.com
32             || $('.account-trigger').hasClass('loggedin') // forums.stardock.com
33             || $('#listatus').hasClass('loggedin')
34			 ) {
35				  StardockHub.isLoggedOn = true;
36			 }
37			 
38            // Register Account Hub Events
39            if (StardockHub.isLoggedOn == true) {
40                
41                StardockHub.isLoggedOn = true;
42
43                sdHubProxy.client.subscriptionUnreadCount_Changed = function (unreadCount) {
44                    StardockHub.onSubscriptionUnreadCount_Changed(unreadCount, true);
45                };
46    
47                sdHubProxy.client.privateMessageUnreadCount_Changed = function (unreadCount) {
48                    StardockHub.onPrivateMessageUnreadCount_Changed(unreadCount, true);
49                };
50        
51            }
52    
53            StardockHub.StartHubConnection(true);
54
55            //$.connection.hub.reconnecting(function() {
56            //    console.log('trying to reconnect');
57            //});
58
59            
60             $.connection.hub.disconnected(function() {
61                StardockHub.isRunning = false;
62                if (StardockHub.isOn) {
63                    setTimeout(function() {
64                        StardockHub.StartHubConnection(false);
65                    }, 60000); // Restart connection after 60 seconds.
66    
67                }
68             });
69    
70         }, 1);
71    },
72    StartHubConnection: function (onFirstConnect, callback) {
73        var callbackArgs;
74        callbackArgs = arguments[2];
75
76        $.connection.hub.start().done(function () {
77            StardockHub.isOn = true;
78            StardockHub.CompleteInitialization(onFirstConnect);
79
80            if (typeof callback == "function")  {
81                callback(callbackArgs); 
82            }(callbackArgs)
83         });
84
85    },
86    StopHubConnection: function () {
87        StardockHub.isOn = false;
88
89        if (!StardockHub.isRunning) { return; }
90
91        $.connection.hub.stop();
92    },
93    ReduceConnections: function() {
94        if (!StardockHub.isLoggedOn) {
95            setTimeout(function() {
96                StardockHub.StopHubConnection();
97            }, 4000); // Wait 5 seconds to allow other operations to complete
98        }
99    },
100
101    CompleteInitialization: function (onFirstConnect) {
102         StardockHub.isRunning = true;
103
104         if (onFirstConnect) {
105            if ($('#account-trigger').hasClass('loggedin') || $('.account-trigger').hasClass('loggedin')) {
106                StardockHub.UpdateSubscriptionCount();
107                StardockHub.UpdateMessageCount();
108            }
109            fsInitializeCarts();
110         }
111    },
112
113    AddToCart: function(item) {
114        if (!StardockHub.isRunning) {
115            StardockHub.StartHubConnection(false, StardockHub.AddToCart, item);
116            return; 
117        }
118
119        sdHubProxy.server.addToCart(item).done(function (result) {
120        });
121    },
122    
123    GetCart: function(callback) {
124        if (!StardockHub.isRunning) {
125            StardockHub.StartHubConnection(false, StardockHub.GetCart, callback);
126            return; 
127        }
128
129        sdHubProxy.server.getCart().done(function (result) {
130            callback(result);
131        });
132    },
133
134    UpdateCart: function(cartItems) {
135        if (!StardockHub.isRunning) {
136            StardockHub.StartHubConnection(false, StardockHub.UpdateCart, cartItems);
137            return; 
138        }
139
140        sdHubProxy.server.updateCart(cartItems).done(function (result) {
141        });
142    },
143  
144    UpdateSubscriptionCount: function() {
145        if (!StardockHub.isRunning) {
146            StardockHub.StartHubConnection(false, StardockHub.UpdateSubscriptionCount);
147            return; 
148        }
149
150        sdHubProxy.server.getSubscriptionCount().done(function (result) {
151            StardockHub.onSubscriptionUnreadCount_Changed(result, false);
152        });
153    },
154    UpdateMessageCount: function() {
155        if (!StardockHub.isRunning) {
156            StardockHub.StartHubConnection(false, StardockHub.UpdateMessageCount);
157            return; 
158        }
159
160        sdHubProxy.server.getPrivateMessageCount().done(function (result) {
161            StardockHub.onPrivateMessageUnreadCount_Changed(result, false);
162        });
163    },
164
165    onCart_Changed: function(cart, wasUpdate) {
166        fsMergeCarts( global_fastSpringData, cart);
167    },
168
169    onSubscriptionUnreadCount_Changed: function(unreadCount, wasUpdate) {
170        var element = $('#subscription_count');
171        if (unreadCount > 0) {
172            element.text(unreadCount);
173            element.addClass("show");
174            if (wasUpdate) {
175                element.addClass('new'); // Shake the icon
176                setTimeout(function () { element.removeClass('new') }, 1500);
177            }
178        } else {
179            element.text('');
180            element.removeClass("show");
181        }
182    },
183
184    onPrivateMessageUnreadCount_Changed: function(unreadCount, wasUpdate) {
185        var element = $('#message_count');
186        if (unreadCount > 0) {
187            element.text(unreadCount);
188            element.addClass("show");
189            if (wasUpdate) {
190                element.addClass('new'); // Shake the icon
191                setTimeout(function () { element.removeClass('new') }, 1500);
192            }
193        } else {
194            element.text('');
195            element.removeClass("show");
196        }
197    }
198    
199}
200

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.