From a555f4ae8fc4f3d69e7774299859112c9429c120 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 12 May 2016 14:04:30 +0200 Subject: [PATCH] fix playlist editing (using more jquery) --- telemeta/templates/telemeta/lists.html | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) 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 } -- 2.39.5