fixed osx scanf behaviour, notifications
authorAndrew Karpow <andy@ndyk.de>
Sat, 8 Mar 2014 11:23:21 +0000 (12:23 +0100)
committerAndrew Karpow <andy@ndyk.de>
Sat, 8 Mar 2014 11:31:22 +0000 (12:31 +0100)
htdocs/js/mpd.js
src/mpd_client.c

index 9609c42..6344679 100644 (file)
@@ -155,7 +155,7 @@ function webSocketConnect() {
                         "</td><td></td></tr>");
                     }
 
-                    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();
index d552517..97f3ac1 100644 (file)
@@ -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;