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