2028
and must have the class 'one-playlist', playlist-form-check and one-label respectively, that is very important*/ } } function renderPlaylistRow(item) { return(`
`) } axios({ method: 'get', url: 'api/playlists/ls', }) .then(function (response) { const {out} = response.data for(let item of out) { $('#playlist-container').append(renderPlaylistRow(item)) } }); function addToPlaylist () { document.getElementById('addNewPlaylist').innerHTML = `
Loading...
` let playlistsToAdd = [] // array of playlists to add the video const checkBoxChecked = document.getElementsByClassName('one-playlist'); // every displayed playlist must have the class 'one-playlist' for (var i = 0; i < checkBoxChecked.length; i++) { if (checkBoxChecked.item(i).checked) { const playlistId = checkBoxChecked.item(i).getAttribute('data-permlink'); const playlistName = checkBoxChecked.item(i).getAttribute('value'); const owner = document.getElementById('addToPlaylistModal').getAttribute('data-author') const permlink = document.getElementById('addToPlaylistModal').getAttribute('data-permlink') playlistsToAdd.push({ playlistId: playlistId, owner: owner, permlink: permlink }) } } console.log(playlistsToAdd) // send this array and other necessary data to the backend for(let item of playlistsToAdd) { console.log(item) axios({ method: 'post', url: 'api/playlists/add', data: { id: item.playlistId, permlink: item.permlink, owner: item.owner } }) } document.getElementById('addNewPlaylist').innerHTML = `Add To Playlist(s) ` toastr.success('Added successfully!') } function createPlaylistInit() { document.getElementById('sendNewPlaylist').style.display = 'inline-block' document.getElementById('createPlaylistArea').style.display = 'block' document.getElementById('closeCreateNewPlaylist').style.display = 'inline-block' document.getElementById('createNewPlaylist').style.display = 'none' document.getElementById('addNewPlaylist').style.display = 'none' } function closeCreateNewPlaylist() { document.getElementById('sendNewPlaylist').style.display = 'none' document.getElementById('createPlaylistArea').style.display = 'none' document.getElementById('closeCreateNewPlaylist').style.display = 'none' document.getElementById('createNewPlaylist').style.display = 'inline-block' document.getElementById('addNewPlaylist').style.display = 'inline-block' } function sendNewPlaylist() { const playlistName = document.getElementById('new-playlist-name').value console.log(playlistName) // SEND THIS TO BACKEND TO STORE NEW PLAYLIST document.getElementById('sendNewPlaylist').innerHTML = `
Loading...
` axios({ method: 'post', url: 'api/playlists/create', data: { title: playlistName } }).then(function (response) { const data = response.data; console.log(data) $('#playlist-container').append(renderPlaylistRow(data)) document.getElementById('new-playlist-name').value = '' document.getElementById('sendNewPlaylist').innerHTML = `Create ` toastr.success('Created successfully!') }) } async function deletePlaylist(permlink, title) { const deleteOp = await axios.post('/api/playlists/delete', {permlink, title}) if (deleteOp.data.status === 'ok') { $('#playlist-container').html('') axios({ method: 'get', url: 'api/playlists/ls', }) .then(function (response) { const {out} = response.data for(let item of out) { $('#playlist-container').append(renderPlaylistRow(item)) } }); } if (deleteOp.data.status === 'false') { toastr.success('You can only delete your own playlists') } }
Report