From: Guillaume Pellerin Date: Thu, 12 May 2016 12:04:30 +0000 (+0200) Subject: fix playlist editing using more jquery (fixes #109 #44) X-Git-Tag: 1.6.2^2~27 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=28c9c0e5bc7764a3c02bd3064cec26b91a37e777;p=telemeta.git fix playlist editing using more jquery (fixes #109 #44) --- diff --git a/telemeta/templates/telemeta/lists.html b/telemeta/templates/telemeta/lists.html index c80f6058..32f0b99d 100644 --- a/telemeta/templates/telemeta/lists.html +++ b/telemeta/templates/telemeta/lists.html @@ -21,31 +21,33 @@ * 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 }