Libraryless. Click here for Pure Java version (2662L/17K).
1 | // requires JQuery |
2 | sS hdesktopNotifications() { |
3 | ret hscript([[ |
4 | function sendDesktopNotification(text, options) { |
5 | if ("Notification" in window && Notification.permission === "granted") |
6 | new Notification(text, options); |
7 | } |
8 | window.sendDesktopNotification = sendDesktopNotification; |
9 | |
10 | function initDesktopNotifications() { |
11 | if (!("Notification" in window)) |
12 | $("#notiStatus").html("Desktop notifications not supported in this browser"); |
13 | else if (Notification.permission === "granted") |
14 | $("#notiStatus").html("Desktop notifications enabled"); |
15 | else if (Notification.permission === "denied") |
16 | $("#notiStatus").html("Desktop notifications denied"); |
17 | else { |
18 | $("#notiStatus").html("Requesting permission for desktop notifications"); |
19 | Notification.requestPermission().then(function (permission) { |
20 | initDesktopNotifications(); |
21 | sendDesktopNotification("Notifications will look like this!"); |
22 | }); |
23 | } |
24 | } |
25 | |
26 | $(document).ready(initDesktopNotifications); |
27 | ]]); |
28 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028545 |
Snippet name: | hdesktopNotifications |
Eternal ID of this version: | #1028545/5 |
Text MD5: | a03eaee833e84289d056f1432f37f495 |
Transpilation MD5: | e09006f04e824890ace095819452242f |
Author: | stefan |
Category: | javax / html |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-06-27 15:37:17 |
Source code size: | 1102 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 205 / 295 |
Version history: | 4 change(s) |
Referenced in: | [show references] |