diff --git a/src/Scylla/Notification.elm b/src/Scylla/Notification.elm new file mode 100644 index 0000000..295077f --- /dev/null +++ b/src/Scylla/Notification.elm @@ -0,0 +1,11 @@ +port module Scylla.Notification exposing (..) +import Scylla.Model exposing (..) +import Json.Decode + +type alias Notification = + { name : String + , text : String + } + +port sendNotificationPort : Notification -> Cmd msg +port onNotificationClockPort : (Json.Decode.Value -> msg) -> Sub msg diff --git a/static/js/notifications.js b/static/js/notifications.js new file mode 100644 index 0000000..20d9ab4 --- /dev/null +++ b/static/js/notifications.js @@ -0,0 +1,12 @@ +if("Notification" in window) { + Notification.requestPermission(); +} + +function setupNotificationPorts(app) { + app.ports.sendNotificationPort.subscribe(function(data) { + var options = { + "body" : data.text + } + new Notification(data.name, options) + }) +}