Browse Source

fixed osx scanf behaviour, notifications

Andrew Karpow 10 years ago
parent
commit
35ab38d0e2
2 changed files with 24 additions and 5 deletions
  1. 23 4
      htdocs/js/mpd.js
  2. 1 1
      src/mpd_client.c

+ 23 - 4
htdocs/js/mpd.js

@@ -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();

+ 1 - 1
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;