PageSourceSearch

https://www.weatherlink.com/js/10.0.7.4-c92a18e7/vendor/davis/modules/shareCalls.js

js weatherlink.com collected 2026-09-24 08:53:39 UTC 7,593 bytes, 310 lines download raw bytes

1/**
2 * Created by anton.milko on 30-May-18.
3 *
4 * contains ajax calls related to ProSharing feature
5 */
6
7wl.app.module("shareCalls", function(oModule, oApp) {
8  
9  if (Utils.isIE()) {
10    //disable ie 11 caching GET requests
11    $.ajaxSetup({ cache: false })
12  }
13
14  this.getFavorites = function() {
15    var d = $.Deferred();
16    $.get('/deviceShare/favorites', function(response) {
17      if (response.data) {
18        d.resolve(response.data);
19      } else {
20        d.resolve({count: 0, devices: []});
21      }
22    });
23    return d.promise();
24  };
25
26  this.markFavorite = function(systemId) {
27    var d = $.Deferred();
28    $.get('/deviceShare/markFavorite/' + systemId, function(response) {
29      if (response.data) {
30        d.resolve(response);
31      }
32    });
33    return d.promise();
34  };
35
36  this.unmarkFavorite = function(systemId) {
37    var d = $.Deferred();
38    $.get('/deviceShare/unmarkFavorite/' + systemId, function(response) {
39      if (response.data) {
40        d.resolve(response);
41      }
42    });
43    return d.promise();
44  };
45
46  this.getDeviceShares = function(systemId) {
47    var d = $.Deferred();
48    $.get('/deviceShare/deviceShares/' + systemId, function(response) {
49      if (response.data) {
50        d.resolve(response.data);
51      } else {
52        d.resolve({count: 0, devices: []});
53      }
54    });
55    return d.promise();
56  };
57
58  this.unshareDevice = function(deviceShareId) {
59    var d = $.Deferred();
60    $.get('/deviceShare/unshareDevice/' + deviceShareId, function(
61      response) {
62      if (response) {
63        d.resolve(response);
64      }
65    });
66    return d.promise();
67  };
68
69  this.unshareDeviceSharedWithUserId = function(systemId, sharedWithUserId) {
70    var d = $.Deferred();
71    $.get('/deviceShare/unshareDevice/' + systemId + '/' +
72      sharedWithUserId,
73      function(response) {
74        if (response) {
75          d.resolve(response);
76        }
77      });
78    return d.promise();
79  };
80
81  this.getDevicesUpgradedCount = function() {
82    var d = $.Deferred();
83    $.get('/deviceShare/devicesUpgradedCount', function(response) {
84      if (response) {
85        d.resolve(response);
86      }
87    });
88    return d.promise();
89  };
90
91  this.getDeviceUpgradesAllowedCount = function() {
92    var d = $.Deferred();
93    $.get('/deviceShare/deviceUpgradesAllowedCount', function(response) {
94      if (response) {
95        d.resolve(response);
96        wl.app.vent.trigger('deviceUpgradesAllowedCount:set', response.data);
97      }
98    });
99    return d.promise();
100  };
101
102  this.upgradeDevice = function(systemId) {
103    var d = $.Deferred();
104    $.post('/deviceShare/upgradeDevice', {
105      systemId: systemId
106    }, function(response) {
107      if (response) {
108        d.resolve(response);
109      }
110    });
111    return d.promise();
112  };
113
114  this.downgradeDevice = function(systemId) {
115    var d = $.Deferred();
116    $.post('/deviceShare/downgradeDevice', {
117      systemId: systemId
118    }, function(response) {
119      if (response) {
120        d.resolve(response);
121      }
122    });
123    return d.promise();
124  };
125
126  this.searchUsers = function(searchInput, systemId) {
127    var d = $.Deferred();
128    $.post('/deviceShare/searchUsers', {
129      searchInput: searchInput,
130      systemId: systemId
131    }, function(response) {
132      if (response.data) {
133        d.resolve(response.data);
134      }
135    });
136    return d.promise();
137  };
138
139  this.shareDevice = function(shareWithUserId, systemId, isBasicShare) {
140    var d = $.Deferred();
141    $.post('/deviceShare/shareDevice', {
142      shareWithUserId: shareWithUserId,
143      systemId: systemId,
144      isBasicShare: isBasicShare
145    }, function(response) {
146      if (response) {
147        d.resolve(response);
148      }
149    });
150    return d.promise();
151  };
152
153  this.sharePublicDevice = function(shareWithUserId, systemId) {
154    var d = $.Deferred();
155    $.post('/deviceShare/publicShare', {
156      shareWithUserId: shareWithUserId,
157      systemId: systemId
158    }, function(response) {
159      if (response) {
160        d.resolve(response);
161      }
162    });
163    return d.promise();
164  };
165
166  this.getDeviceUpgrades = function() {
167    var d = $.Deferred();
168    $.get('/deviceShare/deviceUpgrades', function(response) {
169      if (response.data) {
170        d.resolve(response.data);
171      }
172    });
173    return d.promise();
174  };
175
176  this.getDevicesSharedWithMe = function() {
177    var d = $.Deferred();
178    $.get('/deviceShare/devicesSharedWithMe', function(response) {
179      if (response.data) {
180        d.resolve(response.data);
181      } else {
182        d.resolve({count: 0, devices: []}
182);
183      }
184    });
185    return d.promise();
186  };
187
188  this.getDeviceSharedCount = function(systemId) {
189    var d = $.Deferred();
190    $.get('/deviceShare/deviceSharedCount/' + systemId, function(response) {
191      if (response) {
192        d.resolve(response);
193      }
194    });
195    return d.promise();
196  };
197
198  this.getDeviceSharesAllowedCount = function(systemId) {
199    var d = $.Deferred();
200    $.get('/deviceShare/deviceSharesAllowedCount/' + systemId, function(
201      response) {
202      if (response) {
203        d.resolve(response);
204      }
205    });
206    return d.promise();
207  };
208
209  this.getDeviceUpgradedBy = function(systemId) {
210    var d = $.Deferred();
211    $.get('/deviceShare/deviceUpgradedBy/' + systemId, function(response) {
212      if (response.data) {
213        d.resolve(response.data);
214      }
215    });
216    return d.promise();
217  };
218
219  this.getDeviceSubscriptionTier = function(systemId) {
220    var d = $.Deferred();
221    $.get('/deviceShare/deviceSubscriptionTier/' + systemId, function(
222      response) {
223      if (response.data) {
224        d.resolve(response.data);
225      }
226    });
227    return d.promise();
228  };
229
230  this.getUploads = function(systemId) {
231    var d = $.Deferred();
232    $.get('/deviceShare/uploads/' + systemId, function(response) {
233      if (response.data) {
234        d.resolve(response.data);
235      }
236    });
237    return d.promise();
238  };
239
240  this.upload = function(deviceUpload, isBasic) {
241    var d = $.Deferred();
242    $.ajax({
243      url: '/deviceShare/upload?isBasic=' + isBasic,
244      type: 'POST',
245      contentType: 'application/json',
246      data: JSON.stringify(deviceUpload),
247      success: function(response) {
248        d.resolve(response);
249      }
250    })
251    return d.promise();
252  };
253
254  this.removeUpload = function(systemId, deviceUploadType) {
255    var d = $.Deferred();
256    $.get('/deviceShare/removeUpload/' + systemId + '/' +
257      deviceUploadType,
258      function(response) {
259        if (response) {
260          d.resolve(response);
261        }
262      });
263    return d.promise();
264  };
265
266  this.getDeviceSubscriptionType = function(systemId) {
267    var d = $.Deferred();
268    $.get('/deviceShare/deviceSubscriptionType/' + systemId, function(
269      response) {
270      if (response.data) {
271        d.resolve(response.data);
272      }
273    });
274    return d.promise();
275  };
276
277  this.getUrlToken = function(sDid) {
278    var d = $.Deferred();
279    $.ajax({
280      type: "GET",
281      url: "/device/getUrlToken/" + sDid,
282      success: function(response) {
283        if (response.data) {
284          d.resolve(response.data);
285        } else {
286          d.resolve({urlToken: null});
287        }
288      },
289      error: function(err) {}
290    });
291    return d.promise();
292  };
293  
294  this.generateUrlToken = function(sDid) {
295    var d = $.Deferred();
296    $.ajax({
297      type: "GET",
298      url: "/device/generateUrl/" + sDid,
299      success: function(response) {
300        if (response.data) {
301          console.log("Generated device url " + response.data
302            .urlToken);
303          d.resolve(response.data);
304        }
305      },
306      error: function(err) {}
307    });
308    return d.promise();
309  }
310});

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.