Added notifyjs support
This commit is contained in:
parent
fc231e1c0b
commit
d82fcd6b43
4 changed files with 27 additions and 20 deletions
|
@ -24,6 +24,7 @@
|
||||||
<script src="js/plugins/jquery.scrollTo.min.js" type="text/javascript"></script>
|
<script src="js/plugins/jquery.scrollTo.min.js" type="text/javascript"></script>
|
||||||
<script src="js/plugins/UnityShim.js" type="text/javascript"></script>
|
<script src="js/plugins/UnityShim.js" type="text/javascript"></script>
|
||||||
<script src="js/plugins/jplayer/jquery.jplayer.min.js" type="text/javascript"></script>
|
<script src="js/plugins/jplayer/jquery.jplayer.min.js" type="text/javascript"></script>
|
||||||
|
<script src="js/plugins/notifyjs/notify.js" type="text/javascript"></script>
|
||||||
<script src="js/app.js" type="text/javascript"></script>
|
<script src="js/app.js" type="text/javascript"></script>
|
||||||
<script src="js/utils.js" type="text/javascript"></script>
|
<script src="js/utils.js" type="text/javascript"></script>
|
||||||
<script src="js/controllers/main.js" type="text/javascript"></script>
|
<script src="js/controllers/main.js" type="text/javascript"></script>
|
||||||
|
|
41
js/app.js
41
js/app.js
|
@ -210,42 +210,47 @@ JamStash.service('notifications', function ($rootScope, globals) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.requestPermissionIfRequired = function () {
|
this.requestPermissionIfRequired = function () {
|
||||||
if (!this.hasNotificationPermission() && (window.webkitNotifications)) {
|
if (window.Notify.isSupported() && window.Notify.needsPermission()) {
|
||||||
window.webkitNotifications.requestPermission();
|
window.Notify.requestPermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.hasNotificationPermission = function () {
|
this.hasNotificationPermission = function () {
|
||||||
return !!(window.webkitNotifications) && (window.webkitNotifications.checkPermission() == 0);
|
return (window.Notify.needsPermission() === false);
|
||||||
|
}
|
||||||
|
this.hasNotificationSupport = function () {
|
||||||
|
return window.Notify.isSupported();
|
||||||
}
|
}
|
||||||
var notifications = new Array();
|
var notifications = new Array();
|
||||||
|
|
||||||
this.showNotification = function (pic, title, text, type, bind) {
|
this.showNotification = function (pic, title, text, type, bind) {
|
||||||
if (this.hasNotificationPermission()) {
|
if (this.hasNotificationPermission()) {
|
||||||
//closeAllNotifications()
|
//closeAllNotifications()
|
||||||
var popup;
|
var settings = {}
|
||||||
if (type == 'text') {
|
|
||||||
popup = window.webkitNotifications.createNotification(pic, title, text);
|
|
||||||
} else if (type == 'html') {
|
|
||||||
popup = window.webkitNotifications.createHTMLNotification(text);
|
|
||||||
}
|
|
||||||
if (bind = '#NextTrack') {
|
if (bind = '#NextTrack') {
|
||||||
popup.addEventListener('click', function (bind) {
|
settings.notifyClick = function() {
|
||||||
//$(bind).click();
|
|
||||||
$rootScope.nextTrack();
|
$rootScope.nextTrack();
|
||||||
this.cancel();
|
this.close();
|
||||||
})
|
};
|
||||||
}
|
}
|
||||||
notifications.push(popup);
|
if (type == 'text') {
|
||||||
|
settings.body = text;
|
||||||
|
settings.icon = pic;
|
||||||
|
} else if (type == 'html') {
|
||||||
|
settings.body = text;
|
||||||
|
}
|
||||||
|
var notification = new Notify(title, settings);
|
||||||
|
notifications.push(notification);
|
||||||
setTimeout(function (notWin) {
|
setTimeout(function (notWin) {
|
||||||
notWin.cancel();
|
notWin.close();
|
||||||
}, globals.settings.NotificationTimeout, popup);
|
}, globals.settings.NotificationTimeout, notification);
|
||||||
popup.show();
|
notification.show();
|
||||||
} else {
|
} else {
|
||||||
console.log("showNotification: No Permission");
|
console.log("showNotification: No Permission");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.closeAllNotifications = function () {
|
this.closeAllNotifications = function () {
|
||||||
for (notification in notifications) {
|
for (notification in notifications) {
|
||||||
notifications[notification].cancel();
|
notifications[notification].close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,13 +29,13 @@ function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, not
|
||||||
if ($scope.settings.Password != '' && globals.settings.Password.substring(0, 4) != 'enc:') { $scope.settings.Password = 'enc:' + utils.HexEncode($scope.settings.Password); }
|
if ($scope.settings.Password != '' && globals.settings.Password.substring(0, 4) != 'enc:') { $scope.settings.Password = 'enc:' + utils.HexEncode($scope.settings.Password); }
|
||||||
if (globals.settings.NotificationSong) {
|
if (globals.settings.NotificationSong) {
|
||||||
notifications.requestPermissionIfRequired();
|
notifications.requestPermissionIfRequired();
|
||||||
if (!notifications.hasNotificationPermission()) {
|
if (!notifications.hasNotificationSupport()) {
|
||||||
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
|
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (globals.settings.NotificationNowPlaying) {
|
if (globals.settings.NotificationNowPlaying) {
|
||||||
notifications.requestPermissionIfRequired();
|
notifications.requestPermissionIfRequired();
|
||||||
if (!notifications.hasNotificationPermission()) {
|
if (!notifications.hasNotificationSupport()) {
|
||||||
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
|
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
js/plugins/notifyjs
Submodule
1
js/plugins/notifyjs
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5ee07d7122386d3ab2606e9094a6716ba4deaa13
|
Loading…
Add table
Add a link
Reference in a new issue