-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfuncs.js
90 lines (79 loc) · 2.74 KB
/
funcs.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
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
const electron = require('electron')
let remote = electron.remote;
function setWebviewSize() {
var win = remote.getCurrentWindow();
var sizeArray = win.getSize();
if(sizeArray && sizeArray[0] === 1000) {
document.getElementById('foo').style.height= '700px';
} else {
document.getElementById('foo').style.height= '300px';
}
}
let beginning = true;
function movieMode(label) {
if(beginning) {
document.getElementById('header').remove();
document.getElementById('instructions').remove();
document.getElementById('hideShowInstruction').style.display = "block";
document.getElementById('resizeBtn').style.display = "block";
document.body.style.backgroundColor = '#000';
label.style.color = '#fff';
setWebviewSize();
beginning = false;
}
}
function setVideoSrc(type, value) {
var label = document.getElementById('videolabel');
var video = document.getElementById('foo');
if("embed" === type) {
video.src = "https://www.youtube.com/embed/" + value;
label.innerHTML = "Video ID:";
} else {
video.src = value;
label.innerHTML = "URL:";
}
}
function switchVideo() {
var el = document.getElementById('videoID');
var label = document.getElementById('videolabel');
var video = document.getElementById('foo');
if(el.value) {
document.body.focus();
if(el.value.indexOf("http") >= 0) {
if(el.value.indexOf("www.youtube.com/watch") >= 0) {
var url = new URL(el.value);
var v = url.searchParams.get("v");
if(v) {
el.value = v;
setVideoSrc("embed", v);
}
} else {
setVideoSrc("url", el.value);
}
} else {
setVideoSrc("embed", el.value);
}
movieMode(label);
}
}
function hsStuff(isShow){
var el = document.getElementById('videoID');
if(el.value && el !== document.activeElement) {
console.log(isShow ? "show" : "hide");
document.body.style.backgroundColor = isShow ? '#000' : 'transparent';
el.style.visibility = isShow ? '' : 'hidden';
document.getElementById('videolabel').style.visibility = isShow ? '' : 'hidden';
document.getElementById('hideShowInstruction').style.visibility = isShow ? '' : 'hidden';
document.getElementById('resizeBtn').style.visibility = isShow ? '' : 'hidden';
}
}
//event listeners
document.body.addEventListener('mouseleave', function(){
hsStuff(false);
})
document.body.addEventListener('mouseenter', function(){
hsStuff(true);
})
document.getElementById('videoID').addEventListener('change', function(){
switchVideo();
})