-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.js
More file actions
75 lines (61 loc) · 2.1 KB
/
render.js
File metadata and controls
75 lines (61 loc) · 2.1 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
filePath = '';
fileName = '';
const {ipcRenderer} = require('electron');
var dragzone = document.body;
dragzone.ondragover = function (event) {
//console.log("Drag Over");
return false;
};
dragzone.ondragleave = function (event) {
//console.log("Drag Leave");
return false;
};
dragzone.ondragend = function (event) {
//console.log("Drag End");
return false;
};
dragzone.ondrop = function (event) {
event.preventDefault();
process.chdir(__dirname);
fileFullPath = event.dataTransfer.files[0].path;
fileName = event.dataTransfer.files[0].name;
ipcRenderer.send('file-dropped-in', fileFullPath, fileName);
initHTML(filePath);
return false;
};
ipcRenderer.on('init-html-page', (event, fileFullPath, videoProperty, numFrame) => {
var prop = "Format: " + videoProperty[0] + "; ";
prop += "Resolution: " + videoProperty[1] + "x" + videoProperty[2] + "; ";
prop += "FrameCount: " + videoProperty[3];
initHTML(fileFullPath, prop, numFrame);
})
ipcRenderer.on('update-html-page', (event, fileBegin, fileEnd) => {
console.log("render process: " + fileBegin + ", " + fileEnd);
var prop;
updateHTML(prop, fileBegin, fileEnd, fileName);
})
var onClickThumbnail = function () {
console.log('Info: Renderer Process - img is clicked');
var frameIndex = Number(this.id);
ipcRenderer.send('click-thumbnail', frameIndex);
}
$(document).ready(function () {
$('body').on('click', 'img', onClickThumbnail);
})
function initHTML(inFilePath, prop, numFrame) {
$("ul").empty();
$("#file").text(inFilePath);
$("#prop").text(prop);
}
function updateHTML(prop, startIndex, endIndex, inFileName) {
var titleValue = "VideoFrameViewer - Extracted Frame# " + endIndex.toString();
$("title").text(titleValue);
for (i = startIndex; i < endIndex; i++) {
var path = "img\\" + inFileName + "." + ("000000" + i).substr(-6, 6) + ".png";
var txt = $("<img>").attr({
"id" : (i - 1),
"src": path
});
$("ul").append(txt);
}
}