2 * Written by Riccardo Petrocco
3 * see LICENSE.txt for license information
8 function TribeInterface( controller )
10 this.initialize( controller );
14 TribeInterface.prototype =
19 initialize: function(controller) {
20 this._controller = controller;
29 ajaxError: function(request, error_string, exception, ajaxObject) {
33 remote._error = request.responseText
34 ? request.responseText.trim().replace(/(<([^>]+)>)/ig,"")
36 if( !remote._error.length )
37 remote._error = 'Server not responding';
42 this._controller._BPClosed = true;
43 remote._report = false
48 sendRequest: function( data, success, async ) {
51 if( typeof async != 'boolean' )
61 error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings); },
66 $.ajax( ajaxSettings );
70 loadStats: function( callback, async ) {
71 var tr = this._controller;
72 var o = { method: 'stats' };
73 this.sendRequest( o, callback, async );
76 getInitialDataFor: function(dl_ids, callback) {
78 method: "get_all_downloads"
82 o.arguments.ids = dl_ids;
84 //this.sendRequest( o, function(data){ alert( data.downloads )} );
85 this.sendRequest( o, function(data){ callback(data.downloads)} );
88 pauseAll: function() {
96 // Send the request and report a message if some problems occurred
97 this.sendRequest( o, function(data){ if ( !data.success ) alert("Errors occurred while trying to pause the downloads"); } );
101 pauseDownload: function( id ) {
107 arguments: {"id" : id}
110 // Send the request and report a message if some problems occurred
111 this.sendRequest( o, function(data){ if ( !data.success ) alert("Errors occurred while trying to pause the download"); } );
116 resumeAll: function() {
124 // Send the request and report a message if some problems occurred
125 this.sendRequest( o, function(data){ if ( !data.success ) alert("Errors occurred while trying to resume the downloads"); } );
130 resumeDownload: function( id ) {
136 arguments: {"id" : id}
139 // Send the request and report a message if some problems occurred
140 this.sendRequest( o, function(data){ if ( !data.success ) alert("Errors occurred while trying to resume the download"); } );
145 removeAll: function() {
153 // Send the request and report a message if some problems occurred
154 this.sendRequest( o, function(data){ if ( !data.success ) alert("Errors occurred while trying to remove the downloads"); } );
158 removeDownload: function( id ) {
164 arguments: {"id" : id}
167 // Send the request and report a message if some problems occurred
168 this.sendRequest( o, function(data){ if ( !data.success ) alert("Errors occurred while trying to remove the download"); } );