-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathprompt.html
More file actions
94 lines (91 loc) · 2.33 KB
/
Copy pathprompt.html
File metadata and controls
94 lines (91 loc) · 2.33 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'unsafe-inline'; script-src 'unsafe-inline'">
<title>Input</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 13px;
background: #f0f0f0;
padding: 16px;
display: flex;
flex-direction: column;
height: 100vh;
}
label {
display: block;
margin-bottom: 8px;
color: #333;
line-height: 1.4;
}
input {
width: 100%;
padding: 6px 8px;
font-size: 13px;
border: 1px solid #aaa;
border-radius: 2px;
margin-bottom: 12px;
background: #fff;
}
input:focus {
outline: none;
border-color: #0078d4;
}
.buttons {
display: flex;
gap: 8px;
justify-content: flex-end;
margin-top: auto;
}
button {
padding: 5px 16px;
font-size: 12px;
border-radius: 2px;
cursor: pointer;
min-width: 72px;
}
#ok {
background: #0078d4;
color: #fff;
border: 1px solid #0078d4;
}
#ok:hover { background: #106ebe; }
#cancel {
background: #fff;
color: #333;
border: 1px solid #aaa;
}
#cancel:hover { background: #e5e5e5; }
</style>
</head>
<body>
<label id="label"></label>
<input type="text" id="input" autofocus>
<div class="buttons">
<button id="cancel">Cancel</button>
<button id="ok">OK</button>
</div>
<script>
window.promptApi.onInit(function(data) {
document.getElementById('label').textContent = data.label;
document.getElementById('input').value = data.value;
});
document.getElementById('ok').addEventListener('click', function() {
window.promptApi.submit(document.getElementById('input').value);
});
document.getElementById('cancel').addEventListener('click', function() {
window.promptApi.submit(null);
});
document.getElementById('input').addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
window.promptApi.submit(document.getElementById('input').value);
} else if (e.key === 'Escape') {
window.promptApi.submit(null);
}
});
</script>
</body>
</html>