mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
41 lines
987 B
JavaScript
41 lines
987 B
JavaScript
var AppDispatcher = require('../dispatcher/AppDispatcher');
|
|
var TorrentConstants = require('../constants/TorrentConstants');
|
|
|
|
var performAction = function(action, hash, success, error) {
|
|
|
|
$.ajax({
|
|
url: '/torrents/' + hash + '/' + action,
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
|
success(data);
|
|
}.bind(this),
|
|
|
|
error: function(xhr, status, err) {
|
|
console.error(torrentsData, status, err.toString());
|
|
}.bind(this)
|
|
});
|
|
};
|
|
|
|
var TorrentActions = {
|
|
|
|
stop: function(hash) {
|
|
performAction('stop', hash, function(data) {
|
|
AppDispatcher.dispatch({
|
|
actionType: TorrentConstants.TORRENT_STOP
|
|
});
|
|
});
|
|
},
|
|
|
|
start: function(hash) {
|
|
performAction('start', hash, function(data) {
|
|
AppDispatcher.dispatch({
|
|
actionType: TorrentConstants.TORRENT_START
|
|
});
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = TorrentActions;
|