-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathcustom-dialog.html
More file actions
185 lines (170 loc) · 7.88 KB
/
custom-dialog.html
File metadata and controls
185 lines (170 loc) · 7.88 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<title>wnr</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script>
window.$ = require("jquery/dist/jquery.slim.min.js");
</script>
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="res/fonts/iconfont.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<script src="supporter.js"></script>
<style>
#main {
padding: 10px 12px;
}
#timer {
width: 100% !important;
max-width: 100%;
}
#dialog-buttons {
width: 100% !important;
display: flex;
justify-content: flex-end;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
#dialog-buttons .btn {
white-space: nowrap;
flex: 0 0 auto;
}
</style>
<div class="d-flex mx-auto text-dark" id="main">
<div id="timer" class="justify-content-left align-content-left text-left"
style="transform: translateY(2px); width: 210px; -webkit-app-region: drag; -webkit-user-select: none;">
<p class="small text-grey font-weight-bolder" style="margin-left: 0" id="dialog-title">wnr</p>
<div id="dialog-spinner" class="d-none mb-2">
<div class="spinner-border spinner-border-sm text-primary" role="status"></div>
</div>
<p id="dialog-msg" class="small" style="line-height: 1.5">Message</p>
<p id="dialog-detail" class="small text-muted d-none" style="line-height: 1.5"></p>
<div id="dialog-buttons" style="width:210px" class="text-right">
<a type="button" id="dialog-cancel" class="btn btn-outline-secondary btn-sm text-right d-none"
style="font-size: 12px"
href="javascript:cancel()">
<script>document.write(i18n.__('cancel'))</script>
</a>
<a type="button" id="dialog-button-3" class="btn btn-outline-primary btn-sm text-right d-none"
style="font-size: 12px"
href="javascript:button3()">
<script>document.write(i18n.__('cancel'))</script>
</a>
<a type="button" id="dialog-ok" class="btn btn-outline-primary btn-sm text-right"
style="font-size: 12px"
href="javascript:ok()">
<script>document.write(i18n.__('ok'))</script>
</a>
</div>
</div>
</div><!-- for things with 'work' mark, when it's resting, the color should be changed -->
<script>
let executeAfter = "";
let msgNode = $("#dialog-msg");
let detailNode = $("#dialog-detail");
let currentDialogKind = "default";
let currentExitSessionId = null;
function ok() {
if (currentDialogKind === "exit-sync") {
ipc.send("custom-dialog-action", { action: "primary", exitSessionId: currentExitSessionId });
return;
}
ipc.send("custom-dialog", { mode: "off", executeAfter: executeAfter });
}
function button3() {
if (currentDialogKind === "exit-sync") {
ipc.send("custom-dialog-action", { action: "tertiary", exitSessionId: currentExitSessionId });
return;
}
ipc.send("custom-dialog", { mode: "button3_update", executeAfter: executeAfter });
}
function cancel() {
if (currentDialogKind === "exit-sync") {
ipc.send("custom-dialog-action", { action: "secondary", exitSessionId: currentExitSessionId });
return;
}
ipc.send("custom-dialog", { mode: "cancel" });
}
ipc.on("dialog-init", function (event, message) {
if (message.dialogKind === "exit-sync") {
if (currentExitSessionId != null && message.exitSessionId < currentExitSessionId) {
return;
}
currentDialogKind = "exit-sync";
currentExitSessionId = message.exitSessionId;
$("#dialog-title").text(message.title);
$("#dialog-msg").text(message.msg);
if (message.detail) detailNode.text(message.detail).removeClass("d-none");
else detailNode.text("").addClass("d-none");
$("#dialog-button-3").addClass("d-none");
$("#timer").css("width", "100%");
$("#dialog-buttons").css("width", "100%");
if (message.state === "syncing") {
$("#dialog-spinner").removeClass("d-none");
$("#dialog-ok").addClass("d-none");
$("#dialog-cancel").addClass("d-none");
$("#dialog-button-3").addClass("d-none");
document.onkeydown = function () {};
} else {
$("#dialog-spinner").addClass("d-none");
$("#dialog-ok").removeClass("d-none").text(message.primaryLabel || i18n.__('ok'));
$("#dialog-cancel").removeClass("d-none").text(message.secondaryLabel || i18n.__('cancel'));
if (message.tertiaryLabel) {
$("#dialog-button-3").removeClass("d-none").text(message.tertiaryLabel);
} else {
$("#dialog-button-3").addClass("d-none");
}
document.onkeydown = function (event1) {
let ev = document.all ? window.event : event1;
if ((ev.keyCode || ev.which) === 13) {
ok();
}
}
}
ipc.send("custom-dialog-fit", Math.round((msgNode.height() + detailNode.height()) / parseFloat(msgNode.css('line-height'))));
return;
}
currentDialogKind = "default";
currentExitSessionId = null;
$("#dialog-title").text(message.title);
$("#dialog-msg").text(message.msg);
detailNode.text("").addClass("d-none");
$("#dialog-spinner").addClass("d-none");
executeAfter = message.executeAfter;
ipc.send("custom-dialog-fit", Math.round(msgNode.height() / parseFloat(msgNode.css('line-height'))));
document.onkeydown = function () {
};
if (message.type === 1 || message.type === 2) $("#dialog-cancel").removeClass("d-none");
else $("#dialog-cancel").addClass("d-none");
if (message.type === 2) { //update_on
$("#dialog-cancel").text(i18n.__('update-refuse'));
$("#dialog-button-3").removeClass("d-none");
$("#dialog-button-3").text(i18n.__('update-chk'));
$("#dialog-ok").text(i18n.__('update-lanzous'));
$("#timer").css("width", "420px");
$("#dialog-buttons").css("width", "420px");
} else {
$("#dialog-cancel").text(i18n.__('cancel'));
$("#dialog-button-3").addClass("d-none");
$("#dialog-ok").text(i18n.__('ok'));
$("#timer").css("width", "210px");
$("#dialog-buttons").css("width", "210px");
}
if (message.type === 0) {//on
document.onkeydown = function (event1) {
let ev = document.all ? window.event : event1;
if ((ev.keyCode || ev.which) === 13) {
ok();
}
}
}
})
</script>
<script src="renderer.js"></script>
</body>
</html>