This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
48 lines (39 loc) · 1.82 KB
/
renderer.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const {shell} = require('electron')
var recursive = require('recursive-readdir');
// Skip hidden or large irrelevant folders
var ignorelist = ['.*', 'node_modules', 'static'];
recursive('.', ignorelist, function (err, files) {
// `files` is an array of file paths
var filefull, filename, filepath;
for(let file of files) {
var container = document.getElementsByClassName('card-container')[0];
// Maybe we need this for Windows: String.raw`${file}`
filefull = __dirname + '/' + file;
filename = file.split('/').pop();
filepath = file.split('/').slice(0, -1).join('/');
container.innerHTML +=
'<div data-v-7a77af60="" class="card" data-file="' + filefull + '">' +
'<div data-v-7a77af60="" class="preview" style="background-image: url(\'' + filefull + '\')"></div>' +
'<h2 data-v-7a77af60="" class="name">' + filename + '</h2>' +
'<p data-v-7a77af60="" class="detail" ' +
'<a data-v-7a77af60="" href="#"><img data-v-7a77af60="" class="source" src="assets/folder.svg" /></a>' +
filepath +
'</p>' +
'</div>';
}
});
// Sweep
//shell.moveItemToTrash('/home/jan/Nextcloud/keeporsweep-electron/Abstract/image2.jpeg')
// Open file on click of name
$(document).on('click', '.name', function(event) {
event.preventDefault();
shell.openItem($(event.target).parent('.card').attr('data-file'));
});
// Open folder of file on click of path
$(document).on('click', '.detail', function(event) {
event.preventDefault();
shell.showItemInFolder($(event.target).parent('.card').attr('data-file'));
});