-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathask_password.html
91 lines (75 loc) · 2.13 KB
/
ask_password.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Shortexts Browser</title>
<style>
body{
text-align: center;
font-family: "Lucida Grande";
font-family: 'Helvetica Neue';
font-weight: 200;
font-size: 16px;
overflow: hidden;
}
input:focus {outline:none;}
#password_prompt{
position: fixed;
top:0px;
left:0px;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
color:#fff;
text-align: center;
padding: 20px;
}
</style>
</head>
<body>
<div id="password_prompt">
<div class="wrapper">
Please input the password <input type="password" id="password"> <button id="password_ok">OK</button>
</div>
</div>
<script>
// You can also require other files to run in this process
require('./renderer.js')
const ipcRenderer = require('electron').ipcRenderer;
var key_pressed = 0;
var key_released = 0;
var long_intro_delay = 300;
var callback_password_input = function(pass){
// get back to mainwindow
ipcRenderer.send('get-password', pass);
return
}
var prompt_password = function(){
//var passwrd = prompt('Introduce the master password please!');
document.querySelector("#password_prompt").style.display = 'block';
document.querySelector("#password").focus();
}
var password_input = document.querySelector("#password");
password_input.addEventListener('keyup', ev => {
var key = ev.which || ev.keyCode;
console.log('key='+key);
if (key === 13) { // 13 is enter
var e = document.createEvent('event');
e.initEvent('click', false, true);
var el = document.querySelector("#password_ok");
el.dispatchEvent(e);
}
});
var password_ok = document.querySelector("#password_ok");
password_ok.addEventListener('click', ev => {
console.log('password intro '+"");
var password = document.querySelector("#password").value;
document.querySelector("#password").value = "";
console.log('PASSWRD:'+password);
document.querySelector("#password_prompt").style.display = 'none';
callback_password_input(password);
});
prompt_password();
</script>
</body>
</html>