mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-26 23:07:17 +00:00
remove webkit prefix from Notifications, now working with firefox!
+ probably fix bug with undefined artist or album
This commit is contained in:
parent
a70d87f7c7
commit
0730673851
@ -493,15 +493,19 @@ $('#btnrepeat').on('click', function (e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#btnnotify').on('click', function (e) {
|
$('#btnnotify').on('click', function (e) {
|
||||||
if($.cookie("notification") === "true")
|
if($.cookie("notification") === "true") {
|
||||||
$.cookie("notification", false);
|
$.cookie("notification", false);
|
||||||
else {
|
} else {
|
||||||
window.webkitNotifications.requestPermission();
|
Notification.requestPermission(function (permission) {
|
||||||
if (window.webkitNotifications.checkPermission() == 0)
|
if(!('permission' in Notification)) {
|
||||||
{
|
Notification.permission = permission;
|
||||||
$.cookie("notification", true);
|
}
|
||||||
$('btnnotify').addClass("active");
|
|
||||||
}
|
if (permission === "granted") {
|
||||||
|
$.cookie("notification", true);
|
||||||
|
$('btnnotify').addClass("active");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -577,7 +581,7 @@ $('#mpd_password_set > button').on('click', function (e) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function notificationsSupported() {
|
function notificationsSupported() {
|
||||||
return "webkitNotifications" in window;
|
return "Notification" in window;
|
||||||
}
|
}
|
||||||
|
|
||||||
function songNotify(title, artist, album) {
|
function songNotify(title, artist, album) {
|
||||||
@ -595,14 +599,13 @@ function songNotify(title, artist, album) {
|
|||||||
//chrome.notifications.create(id, options, creationCallback);
|
//chrome.notifications.create(id, options, creationCallback);
|
||||||
|
|
||||||
var textNotification = "";
|
var textNotification = "";
|
||||||
if(artist.length > 0)
|
if(typeof artist != 'undefined' && artist.length > 0)
|
||||||
textNotification += " " + artist;
|
textNotification += " " + artist;
|
||||||
if(album.length > 0)
|
if(typeof album != 'undefined' && album.length > 0)
|
||||||
textNotification += "\n " + album;
|
textNotification += "\n " + album;
|
||||||
|
|
||||||
var notification = window.webkitNotifications.createNotification("assets/favicon.ico", textNotification, title);
|
var notification = new Notification(title, {icon: 'assets/favicon.ico', body: textNotification});
|
||||||
notification.show();
|
setTimeout(function(notification) {
|
||||||
setTimeout(function(notification) {
|
notification.close();
|
||||||
notification.cancel();
|
}, 3000, notification);
|
||||||
}, 3000, notification);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user