-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (29 loc) · 852 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Command = function() {
return this;
}
Command.prototype.moveToTrash = function moveToTrash() {
var view = this.GUI.activeView().model;
var selectedItems = view.selected();
if (selectedItems.length === 0){
this.GUI.app.msg("select some items to delete.");
} else {
const {shell} = require('electron');
for (var i = selectedItems.length - 1; i >= 0; i--) {
var item = selectedItems[i];
var path = require("path");
var fn = path.join(view.path, item.name) + item.ext;
if (shell.moveItemToTrash(fn)){
this.GUI.app.msg("deleted \"" + fn + "\"");
} else {
this.GUI.app.msg("failed to delete \"" + fn + "\"");
}
}
view.refresh();
}
return false
};
var Plugin = function (client) {
this.command = new Command();
client.app.registerHotKey("del", this.command.moveToTrash);
};
module.exports = Plugin;