forked from peterfreeman/electron-osx-prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt.js
30 lines (24 loc) · 923 Bytes
/
prompt.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
const { ipcRenderer } = require('electron');
const remote = require('electron').remote;
const path = require('path');
ipcRenderer.on('electron-osx-prompt-settings', (event, options) => {
document.getElementById('label').innerHTML = options.label;
document.getElementById('input').placeholder = options.placeholder;
document.getElementById('input').type = options.masked ? 'password' : 'text';
document.getElementById('prompt-img').src = options.icon;
});
document.addEventListener("DOMContentLoaded", function (event) {
document.getElementById('input').focus();
});
function enter (e) {
if (e.charCode == '13') {
Ok();
}
}
function Ok () {
let returnValue = document.getElementById('input').value.toString();
ipcRenderer.sendSync('electron-osx-prompt-return-value', returnValue);
}
function Cancel () {
ipcRenderer.sendSync('electron-osx-prompt-return-value', null);
}