12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <html data-ng-app>
- <head>
- <title></title>
- <link href="notifications.css" type="text/css" rel="stylesheet"/>
- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
- <script type="text/javascript" src="desktop-notify-min.js"></script>
- <script>
- function NotificationCenter($scope) {
- var permissionLevels = {};
- permissionLevels[notify.PERMISSION_GRANTED] = 0;
- permissionLevels[notify.PERMISSION_DEFAULT] = 1;
- permissionLevels[notify.PERMISSION_DENIED] = 2;
- $scope.isSupported = notify.isSupported;
- $scope.permissionLevel = permissionLevels[notify.permissionLevel()];
- $scope.getClassName = function() {
- if ($scope.permissionLevel === 0) {
- return "allowed"
- } else if ($scope.permissionLevel === 1) {
- return "default"
- } else {
- return "denied"
- }
- }
- $scope.callback = function() {
- console.log("test");
- }
- $scope.requestPermissions = function() {
- notify.requestPermission(function() {
- $scope.$apply($scope.permissionLevel = permissionLevels[notify.permissionLevel()]);
- })
- }
- }
- function show() {
- notify.createNotification("Notification", {body:"Body", icon: "alert.ico"})
- }
- </script>
- </head>
- <body data-ng-controller="NotificationCenter">
- <div class="warningMsg" data-ng-show="!isSupported" style="display: none;">
- Desktop notifications are currently not supported for your browser.
- <p>
- Open the page in Chrome(version 23+), Safari(version6+), Firefox(with ff-html5notifications plugin installed) and IE9+.
- </div>
- <a class="notificationLevel" ng-class="getClassName()" data-ng-click="requestPermissions()" data-ng-pluralize data-count="permissionLevel" when="{
- '0': 'Notifications allowed.',
- '1': 'Notifications not allowed. (click to enable)',
- '2': 'Notifications denied. (Change notifications permission in you browser\'s settings)'}">
- </a>
- <button onclick="show()">Show notification</button>
- </body>
- </html>
|