Fix: apply Desktop Notification for Chrome, Alert for IE
This commit is contained in:
@@ -80,14 +80,61 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
var timeOutEventID;
|
||||
|
||||
function ShowNotifyTimeOver(timeLeft) {
|
||||
if(Notification) { // except IE
|
||||
Notification.requestPermission(function (result) {
|
||||
Notification.permission = result;
|
||||
|
||||
console.log(result);
|
||||
if(result !== "denied")
|
||||
AddNotifyEventByNotification(timeLeft);
|
||||
else
|
||||
AddNotifyEventByAlert(timeLeft);
|
||||
});
|
||||
} else { // IE
|
||||
console.log("no notification");
|
||||
AddNotifyEventByAlert(timeLeft);
|
||||
}
|
||||
}
|
||||
|
||||
function AddNotifyEventByNotification(timeLeft) {
|
||||
console.log("AddNotifyEventByNotification : " + timeLeft);
|
||||
timeOutEventID = setTimeout(function() {
|
||||
alert("!!! 시험 시간 종료 !!!\n작업을 중단하고 선생님을 불러주세요.");
|
||||
// notify("시험 시간이 끝났습니다!!!");
|
||||
var options = {
|
||||
icon: "../../../resources/image/icon/banner_chocomae_128x128.png",
|
||||
body: "!!! 시험 시간 종료 !!!\n작업을 중단하고 선생님을 불러주세요.",
|
||||
}
|
||||
var notification = new Notification("자격증 타이머 | 초코마에", options);
|
||||
|
||||
//알림 후 5초 뒤,
|
||||
setTimeout(function () {
|
||||
//얼람 메시지 닫기
|
||||
notification.close();
|
||||
}, 5000);
|
||||
}, timeLeft);
|
||||
}
|
||||
|
||||
function AddNotifyEventByAlert(timeLeft) {
|
||||
console.log("AddNotifyEventByAlert : " + timeLeft);
|
||||
timeOutEventID = setTimeout(function() {
|
||||
alert("!!! 시험 시간 종료 !!!\n작업을 중단하고 선생님을 불러주세요.");
|
||||
}, timeLeft);
|
||||
}
|
||||
|
||||
|
||||
function CancelNotifyTimeOver() {
|
||||
console.log("CancelNotifyTimeOver");
|
||||
clearTimeout(timeOutEventID);
|
||||
}
|
||||
|
||||
function RemoveNotifyEventyByNotification() {
|
||||
console.log("RemoveNotifyEventyByNotification");
|
||||
clearTimeout(timeOutEventID);
|
||||
}
|
||||
|
||||
function RemoveNotifyEventyByAlert() {
|
||||
console.log("RemoveNotifyEventyByAlert");
|
||||
clearTimeout(timeOutEventID);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user