Last active
June 9, 2017 11:30
-
-
Save rayets123/f0a1bd46b18f0a2f05f2cce9217515ad to your computer and use it in GitHub Desktop.
Revisions
-
rayets123 revised this gist
Jun 9, 2017 . No changes.There are no files selected for viewing
-
rayets123 revised this gist
Jun 9, 2017 . 1 changed file with 36 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,37 @@ sendNotification('Верните Линуса!', { body: 'Тестирование HTML5 Notifications', icon: 'icon.jpg', dir: 'auto' }); function sendNotification(title, options) { // Проверим, поддерживает ли браузер HTML5 Notifications if (!("Notification" in window)) { alert('Ваш браузер не поддерживает HTML Notifications, его необходимо обновить.'); } // Проверим, есть ли права на отправку уведомлений else if (Notification.permission === "granted") { // Если права есть, отправим уведомление var notification = new Notification(title, options); function clickFunc() { alert('Пользователь кликнул на уведомление'); } notification.onclick = clickFunc; } // Если прав нет, пытаемся их получить else if (Notification.permission !== 'denied') { Notification.requestPermission(function (permission) { // Если права успешно получены, отправляем уведомление if (permission === "granted") { var notification = new Notification(title, options); } else { alert('Вы запретили показывать уведомления'); // Юзер отклонил наш запрос на показ уведомлений } }); } else { // Пользователь ранее отклонил наш запрос на показ уведомлений // В этом месте мы можем, но не будем его беспокоить. Уважайте решения своих пользователей. } -
rayets123 created this gist
Jun 9, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ Notification.requestPermission(newMessage); function newMessage(permission) { if (permission != "granted") return false; var mailNotification = new Notification("SHOWCSGO.COM", { tag: "ache-mail", body: "SHOWCSGO.COM", icon: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/59/593fb3d18ca769b417c0f569d73075c085a0f557_full.jpg" }); };