mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
almost all js files are loaded using require.js
This commit is contained in:
parent
aed7b95245
commit
2407e33ea2
35 changed files with 570 additions and 717 deletions
|
@ -1,48 +1,49 @@
|
|||
"use strict";
|
||||
define(['app', 'signalR'], function () {
|
||||
|
||||
_.extend(Backbone.Collection.prototype, {BindSignalR: function (options) {
|
||||
_.extend(Backbone.Collection.prototype, {BindSignalR: function (options) {
|
||||
|
||||
if (!options || !options.url) {
|
||||
console.assert(this.url, 'url must be provided or collection must have url');
|
||||
options = {
|
||||
url: this.url.replace('api', 'signalr')
|
||||
};
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
var _getStatus = function (status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return 'connecting';
|
||||
case 1:
|
||||
return 'connected';
|
||||
case 2:
|
||||
return 'reconnecting';
|
||||
case 4:
|
||||
return 'disconnected';
|
||||
default:
|
||||
throw 'invalid status ' + status;
|
||||
if (!options || !options.url) {
|
||||
console.assert(this.url, 'url must be provided or collection must have url');
|
||||
options = {
|
||||
url: this.url.replace('api', 'signalr')
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
var self = this;
|
||||
|
||||
var _getStatus = function (status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return 'connecting';
|
||||
case 1:
|
||||
return 'connected';
|
||||
case 2:
|
||||
return 'reconnecting';
|
||||
case 4:
|
||||
return 'disconnected';
|
||||
default:
|
||||
throw 'invalid status ' + status;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
var connection = $.connection(options.url);
|
||||
var connection = $.connection(options.url);
|
||||
|
||||
connection.stateChanged(function (change) {
|
||||
console.debug('{0} [{1}]'.format(options.url, _getStatus(change.newState)));
|
||||
});
|
||||
connection.stateChanged(function (change) {
|
||||
console.debug('{0} [{1}]'.format(options.url, _getStatus(change.newState)));
|
||||
});
|
||||
|
||||
connection.received(function (model) {
|
||||
console.debug(model);
|
||||
self.fetch();
|
||||
});
|
||||
connection.received(function (model) {
|
||||
console.debug(model);
|
||||
self.fetch();
|
||||
});
|
||||
|
||||
connection.start({ transport: ['longPolling'] });
|
||||
|
||||
return this;
|
||||
}});
|
||||
connection.start({ transport: ['longPolling'] });
|
||||
|
||||
return this;
|
||||
}});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue