You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.8 KiB
HTML
104 lines
2.8 KiB
HTML
<html>
|
|
<head>
|
|
<include src="common.htm" />
|
|
<style src="alert.css" />
|
|
<script src="libs/dayjs.min.js" />
|
|
<script>
|
|
var messages = $("#messages"),
|
|
okBtn = $("#ok"),
|
|
countdown = $("#countdown"),
|
|
timeLeft = 0;
|
|
|
|
view.minSize = [200, 100];
|
|
CommonNative.SetLargeWindowIcon(document, "");
|
|
translateWindow("span");
|
|
|
|
function countToClose() {
|
|
timeLeft--;
|
|
if (timeLeft == 0) {
|
|
view.close();
|
|
return false;
|
|
} else {
|
|
countdown.classList.add("shown");
|
|
countdown.text = "(" + timeLeft + ")";
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function addMessage(msgobj) {
|
|
var caption, icon;
|
|
switch (msgobj.type) {
|
|
case "info":
|
|
case 2:
|
|
caption = "Information";
|
|
icon = "asterisk";
|
|
timeLeft = 30;
|
|
break;
|
|
case "warning":
|
|
case 0:
|
|
caption = "Warning";
|
|
icon = "exclamation";
|
|
timeLeft = 60;
|
|
break;
|
|
case "error":
|
|
case 1:
|
|
caption = "Error";
|
|
icon = "hand";
|
|
timeLeft = 99;
|
|
break;
|
|
case "confirm":
|
|
case 3:
|
|
caption = "Confirm";
|
|
icon = "question";
|
|
timeLeft = 60;
|
|
break;
|
|
case "buzz":
|
|
case 4:
|
|
caption = "Buzz";
|
|
icon = "asterisk";
|
|
timeLeft = 15;
|
|
break;
|
|
case "custom":
|
|
case 5:
|
|
caption = "";
|
|
icon = "";
|
|
break;
|
|
}
|
|
var user = CommonNative.GetCurrentUserName();
|
|
view.caption = _(caption) + (user != "" ? " (" + user + ")" : "");
|
|
if (View.share.commonSettings.alertTopMost) view.isTopmost = true;
|
|
//view.activate(true);
|
|
var time = new Date();
|
|
msgobj.message = dayjs(time).format("DD.MM.YYYY HH:mm:ss") + "\n" + msgobj.message;
|
|
var current = messages.$("option:current");
|
|
var index = current ? current.index : 0;
|
|
messages.prepend(<option as="string" value={time.valueOf().toString()}><div auto pic={icon}></div><div class="msg">{msgobj.message}</div></option>); //
|
|
if (index == 0) messages.children[0].execCommand("set-current");
|
|
if (messages.length == 1) {
|
|
messages.children[0].post(function() {
|
|
this.state.expanded = true;
|
|
//this.flushPaint();
|
|
});
|
|
} else {
|
|
messages.children[0].state.collapsed = true
|
|
//messages.children[0].flushPaint();
|
|
}
|
|
document.timer(1s, countToClose);
|
|
countToClose();
|
|
}
|
|
|
|
okBtn.on("click", (e) => { view.close(); });
|
|
okBtn.state.focus = true;
|
|
|
|
document.on("keydown", (e) => {
|
|
if (e.keyCode == Event.VK_ESCAPE || (e.ctrlKey && e.keyCode == Event.VK_W)) view.close();
|
|
else if (e.keyCode == Event.VK_RETURN && e.target.tag != "button") view.close();
|
|
else if (e.ctrlKey && e.keyCode == Event.VK_C) Clipboard.writeText(messages.$("option:current > div.msg").text);
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<select type="list" id="messages"></select>
|
|
<button uwp wide id="ok"><div><span>OK</span><span id="countdown"></span></div></button>
|
|
</body>
|
|
</html> |