forked from premiere/premiere-deluge-plugin
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
Ext.namespace('Deluge.premiere');
|
|
Deluge.premiere.PremierePlugin = Ext.extend(Deluge.Plugin, {
|
|
name: "Premiere",
|
|
|
|
onDisable: function() {
|
|
deluge.menus.torrent.remove(this.ci);
|
|
},
|
|
|
|
onEnable: function() {
|
|
this.ci = deluge.menus.torrent.add(new Ext.menu.CheckItem({
|
|
text: "Premiere Mode",
|
|
checkHandler: this.onTogglePremiere,
|
|
scope: this
|
|
}));
|
|
deluge.menus.torrent.on('show', this.onMenuShow, this, {stopEvent : true});
|
|
},
|
|
|
|
onMenuShow: function() {
|
|
var tid = deluge.torrents.getSelectedIds()[0];
|
|
deluge.client.premiere.is_premiere_torrent(tid, {
|
|
success: function (is_prem) {
|
|
this.ci.setChecked(is_prem, true);
|
|
},
|
|
scope: this
|
|
})
|
|
},
|
|
|
|
onTogglePremiere: function(item, checked) {
|
|
var ids = deluge.torrents.getSelectedIds();
|
|
if (checked) {
|
|
for (var i = 0; i < ids.length; i++) {
|
|
deluge.client.premiere.add_premiere_torrent(ids[i]);
|
|
}
|
|
} else {
|
|
for (var i = 0; i < ids.length; i++) {
|
|
deluge.client.premiere.del_premiere_torrent(ids[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
});
|
|
Deluge.registerPlugin('Premiere', Deluge.premiere.PremierePlugin);
|