@@ -7,6 +7,8 @@ export function spawnPlaylistNode(id, name, json, nodeId) {
7
7
let template = document . getElementById ( "template-playlist" ) ;
8
8
const node = template . content . cloneNode ( true ) ;
9
9
10
+ node . querySelector ( ".playlist" ) . id = `playlist-${ id } ` ;
11
+
10
12
// Set click callbacks
11
13
node . querySelector ( ".card-image" ) . onclick = ( ) => {
12
14
window . location = window . location . origin + window . location . pathname + `?playlist=${ id } ` ;
@@ -16,10 +18,10 @@ export function spawnPlaylistNode(id, name, json, nodeId) {
16
18
if ( json . musics . some ( x => x . playlists . includes ( id ) ) ) {
17
19
if ( confirm ( "This playlist contains songs, are you sure you want to delete it?" ) )
18
20
{
19
- removePlaylist ( id ) ;
21
+ removePlaylist ( id , ( ) => { document . getElementById ( `playlist- ${ id } ` ) . remove ( ) ; } , ( ) => { } ) ;
20
22
}
21
23
} else {
22
- removePlaylist ( id ) ;
24
+ removePlaylist ( id , ( ) => { document . getElementById ( `playlist- ${ id } ` ) . remove ( ) ; } , ( ) => { } ) ;
23
25
}
24
26
}
25
27
@@ -67,19 +69,22 @@ export function spawnNewPlaylistNode(nodeId, json) {
67
69
const node = template . content . cloneNode ( true ) ;
68
70
69
71
node . querySelector ( ".card-content > p" ) . innerHTML = `Create new playlist` ;
70
- node . querySelector ( ".card-image" ) . onclick = ( ) => { createNewPlaylist ( json ) ; } ;
72
+ node . querySelector ( ".card-image" ) . onclick = ( ) => { createNewPlaylist ( nodeId , json ) ; } ;
71
73
node . querySelector ( ".card-image" ) . classList . add ( "requires-admin" ) ;
72
74
if ( ! isLoggedIn ( ) ) {
73
75
node . querySelector ( ".card-image" ) . classList . add ( "is-hidden" ) ;
74
76
}
75
77
78
+ node . querySelector ( ".dropdown" ) . remove ( ) ;
79
+
76
80
document . getElementById ( nodeId ) . appendChild ( node ) ;
77
81
}
78
82
79
- function createNewPlaylist ( json )
83
+ function createNewPlaylist ( nodeId , json )
80
84
{
81
85
var playlistName = window . prompt ( "Enter new playlist name" ) ;
82
86
if ( playlistName ) {
87
+ document . getElementById ( nodeId ) . innerHTML = "" ;
83
88
createPlaylist ( playlistName , ( ) => {
84
89
json . playlists [ playlistName ] = {
85
90
name : playlistName ,
0 commit comments