-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainWindow.html
134 lines (112 loc) · 4.88 KB
/
mainWindow.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html lang="en" style = "width: 100%; height: 100%; margin: 0; padding: 0;">
<head>
<title>YouTube-Hydrogen Player</title>
</head>
<body onkeydown="keydown1(event,this)" onmousemove="msMove()" onmouseover="msOver()" onmouseout="msOut()" style = "width: 100%; height: 100%; margin: 0; padding: 0;"><!-- -webkit-app-region: drag;"> -->
<div style="width: 100%; overflow: hidden;">
<div style="width: 600px; float: left; position: relative;">
<webview id = "yt-player" src = "startPage.html" style = "width: 100vw; height: 100vh; position: relative; z-index: 4000"></webview>
</div>
<div style="float: top-left; position: absolute; z-index: 9999999;">
<div>
<button type="button" id = "drag" tabindex="-1" style="position: absolute; top: 0; width: 20; height: 20; background-color: #ff0000; border: none; opacity: 0.3; background:rgba(255,0,0,1); color: white; -webkit-app-region: drag;"><span>...</span></button> <!--onmousemove="msMove(event) onmouseover="msOverDrag(event)" onmousedown="msDown(event)" onmouseup="msUp(event)" onclick="drag()""-->
<!--<img src="move_icon2.png" id = "drag" tabindex="-1" style="position: absolute; top: 0; width: 20px; height: 20px; -webkit-app-region: drag;">-->
</div>
<div>
<button type="button" id = "btn" tabindex="-1" style="position: absolute; top: 40vh; width: 20px; height: 20vh; background-color: #ff0000; border: none; opacity: 0; background: linear-gradient(to left, rgba(255,0,0,0),rgba(255,0,0,1)); color: white" onclick="openWindow()"><span><</span></button>
</div>
</div>
</div>
<script>
const electron = require('electron');
const {ipcRenderer} = electron;
var dragMove = 0;
var count = 0;
var isMouseOut = 1;
// ipcRenderer.on('openVideo', function(e, path) {
// const webview = document.getElementById('yt-player');
// const loadPage = () => {
// webview.loadURL(path);
// webview.removeEventListener('dom-ready', loadPage);
// };
// webview.addEventListener('dom-ready', loadPage);
// });
// Hides 'btn' after 5 seconds
var x = setInterval(function(){
//console.log(count);
if(count >= 30) {
btn.style.opacity = 0;
}
else {
btn.style.opacity = 1;
count++;
}
}, 100);
function keydown1(evt,t) {
ipcRenderer.send('keydown1', evt.keyCode);
}
function msOverDrag(e) {
var drag = document.getElementById("drag");
drag.style.opacity = 0.75;
}
function msDown(e) {
//var drag = document.getElementById("drag");
//drag.style.opacity = 1;
//ipcRenderer.send('msDown');
}
function msUp(e) {
//var drag = document.getElementById("drag");
//if(dragMove == 1)
// drag.style.opacity = 0.75;
//ipcRenderer.send('msUp');
//dragMove = 0;
}
function msMove(e) {
// var btn = document.getElementById("btn");
// btn.style.opacity = 1;
// dragMove = 1;
// ipcRenderer.send('msMove');
//console.log(x + "," + y);
count = 0;
}
function msOver(e) {
var btn = document.getElementById("btn");
//var drag = document.getElementById("drag");
// if(drag.style.opacity < 0.5) {
// drag.style.opacity = 0.5;
// }
}
function msOut(e) {
var btn = document.getElementById("btn");
//var drag = document.getElementById("drag");
btn.style.opacity = 0;
count = 30;
//drag.style.opacity = 0;
}
function openWindow(e) {
var iframe = document.getElementById("yt-player");
ipcRenderer.send('openWindow', iframe.src);
}
function webClick(e) {
console.log(e);
}
function drag(e) {
var drag = document.getElementById("drag");
}
ipcRenderer.on('element-clicked', function(e, path) {
//console.log(path);
var iframe = document.getElementById("yt-player");
//mainWindow.webContents.send('openVideo', path);
console.log(path);
// alert(iframe);
iframe.src = path;
});
document.addEventListener('keydown', event => {
if (event.key === 'Escape' || event.keyCode === 27) {
ipcRenderer.send('esc-close');
}
});
</script>
</body>
</html>