]> git.parisson.com Git - telemeta.git/commitdiff
fix playlist editing using more jquery (fixes #109 #44)
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 12 May 2016 12:04:30 +0000 (14:04 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 12 May 2016 12:09:32 +0000 (14:09 +0200)
telemeta/templates/telemeta/lists.html

index c80f6058438d95e797b97ef9cd49ee0705cc37fd..32f0b99d86ed7d7066ff987d1d7afc6ebb69a4a6 100644 (file)
       * function that get variables from the Add popup
       * and create a new playlist
       */
+    var p = playlistUtils;
+    var ID = ""; // ID var: used to edit playlist
+    var title = "";
+    var description = "";
+
     function addNewPlaylist() {
-        var title = document.getElementById('titleAdd').value;
-        var description = document.getElementById('descriptionAdd').value;
-        var p = playlistUtils;
-        p.add({
-         title,
-         description
-        });
+        title = $('#titleAdd').val();
+        description = $('#descriptionAdd').val();
+        p.add({title,description});
     }
 
-    var ID = ""; // ID var: used to edit playlist
-
     // function to change global var ID (used when edit button is pressed)
     function editVar(id) {
         ID = id;
+        for (var i=0; i< p.playlists.length; i++){
+            if (p.playlists[i].id == id){
+                $('#titleEdit').val(p.playlists[i].title);
+                $('#descriptionEdit').val(p.playlists[i].description);
+            }
+        }
     }
 
     function editPlaylist() {
-        var title = document.getElementById('titleEdit').value;
-        var description = document.getElementById('descriptionEdit').value;
-        var p = playlistUtils;
-
+        title = $('#titleEdit').val();
+        description = $('#descriptionEdit').val();
         // Use of a function that convert params then use playlist.update
         p.updateConvert(ID, title, description);
-
         ID = ""; // init ID
     }