From 35ab38d0e23b809da9535b18745f6f34d19ade04 Mon Sep 17 00:00:00 2001 From: Andrew Karpow Date: Sat, 8 Mar 2014 12:23:21 +0100 Subject: [PATCH] fixed osx scanf behaviour, notifications --- htdocs/js/mpd.js | 27 +++++++++++++++++++++++---- src/mpd_client.c | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index 9609c42..6344679 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -155,7 +155,7 @@ function webSocketConnect() { ""); } - if(obj.data[obj.data.length-1].id >= pagination + MAX_ELEMENTS_PER_PAGE) + if(obj.data[obj.data.length-1].pos + 1 >= pagination + MAX_ELEMENTS_PER_PAGE) $('#next').removeClass('hide'); if(pagination > 0) $('#prev').removeClass('hide'); @@ -358,7 +358,7 @@ function webSocketConnect() { } if ($.cookie("notification") === "true") - songNotify(obj.data.title, obj.data.artist + " " + obj.data.album ); + songNotify(obj.data.title, obj.data.artist, obj.data.album ); else $('.top-right').notify({ message:{html: notification}, @@ -573,8 +573,27 @@ function notificationsSupported() { return "webkitNotifications" in window; } -function songNotify(artist, title) { - var notification = window.webkitNotifications.createNotification("assets/favicon.ico", artist, title); +function songNotify(title, artist, album) { + /*var opt = { + type: "list", + title: title, + message: title, + items: [] + } + if(artist.length > 0) + opt.items.push({title: "Artist", message: artist}); + if(album.length > 0) + opt.items.push({title: "Album", message: album}); +*/ + //chrome.notifications.create(id, options, creationCallback); + + var textNotification = ""; + if(artist.length > 0) + textNotification += " " + artist; + if(album.length > 0) + textNotification += "\n " + album; + + var notification = window.webkitNotifications.createNotification("assets/favicon.ico", textNotification, title); notification.show(); setTimeout(function(notification) { notification.cancel(); diff --git a/src/mpd_client.c b/src/mpd_client.c index d552517..97f3ac1 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -46,7 +46,7 @@ int callback_mpd(struct mg_connection *c) size_t n = 0; unsigned int uint_buf, uint_buf_2; int int_buf; - char *p_charbuf; + char *p_charbuf = NULL; if(cmd_id == -1) return MG_CLIENT_CONTINUE; -- 2.20.1