-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
71 lines (63 loc) · 2.75 KB
/
index.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
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bulma.css">
<title>tubuler</title>
</head>
<body style="-webkit-app-region: drag">
<section class="section section-padding">
<form>
<div class="field is-size-1 has-text-centered">
<strong>tubuler</strong> 🤙
</div>
<div class="field">
<div class="control">
<input class="input" style="-webkit-app-region: no-drag;" type="text" id="url" autofocus placeholder="https://www.youtube.com/watch?v=stgrSjynPKs">
</div>
</div>
<div class="field">
<div class="control has-text-centered">
<input class="button is-primary" style="-webkit-app-region: no-drag;" type="submit" value="Download">
</div>
</div>
<div class="field">
<div class="box has-text-centered is-size-6" style="padding: 0; box-shadow: none; -webkit-app-region: no-drag;" id="log">
</div>
</div>
</form>
</section>
<footer style="padding: 0;">
<div class="content has-text-centered" style="-webkit-app-region: no-drag;">
<p>
<a href="https://github.com/dtcrout/tubuler/"><strong>tubuler</strong> is free and open source!</a>
</p>
</div>
</footer>
<script>
// We can probably wrap this up into a separate file
const electron = require('electron');
const { ipcRenderer, shell } = electron;
const form = document.querySelector('form');
form.addEventListener('submit', submitForm);
function submitForm(event) {
event.preventDefault();
const url = document.querySelector('#url').value;
ipcRenderer.send('url', url);
// Reset form and refocus on field
form.reset();
document.getElementById("url").focus();
}
ipcRenderer.on('log', printLog);
function printLog(event, message) {
document.getElementById('log').innerHTML = message;
}
document.addEventListener('click', redirectLink);
function redirectLink(event) {
if (event.target.tagName === 'A' && event.target.href.startsWith('http')) {
event.preventDefault();
shell.openExternal(event.target.href);
}
}
</script>
</body>
</html>