public/js/music_playlist.js
/**
 * Show new tab with the lyrics of a song with the given artist and title.
 * 
 * @param {string} artist The artist of the song.
 * @param {string} title The title of the song.
 */
Show new tab with the lyrics of a song with the given artist and title.

@param {string} artist The artist of the song.
@param {string} title The title of the song.
Show new tab with the lyrics of a song with the given artist and title . @param { string } artist The artist of the song . @param { string } title The title of the song .
function showSongLyricsByArtistTitle(artist, title) {
    var url = base_url + "/api/getSongLyricsByArtistTitle/?artist=" + artist + "&title=" + title;  
    fetch(url, {
        credentials: "same-origin",
        method: 'GET',
        headers:{
            'Content-Type': 'application/json',
            'X-CSRF-TOKEN': getCSRFToken()
        }
    })
    .then(function(response) {
        return response.text();
    })
    .then(function(text) {
        var content = document.createElement('div');
        var song_text;
        if (text == '') song_text = 'Lyrics are not found.';
        else song_text = text;
        content.innerHTML = '<h2>' + artist + ' - ' + title + '</h2>' + '<p>' + song_text + '</p>';
        var w = window.open("", "_blank");
        w.document.title = 'Song lyrics'
        w.document.body.appendChild(content);
    }); 
}
function showSongLyricsByArtistTitle ( artist , title ) { var url = base_url + "/api/getSongLyricsByArtistTitle/?artist=" + artist + "&title=" + title ; fetch ( url , { credentials : "same-origin" , method : 'GET' , headers : { 'Content-Type' : 'application/json' , 'X-CSRF-TOKEN' : getCSRFToken ( ) } } ) . then ( function ( response ) { return response . text ( ) ; } ) . then ( function ( text ) { var content = document . createElement ( 'div' ) ; var song_text ; if ( text == '' ) song_text = 'Lyrics are not found.' ; else song_text = text ; content . innerHTML = '<h2>' + artist + ' - ' + title + '</h2>' + '<p>' + song_text + '</p>' ; var w = window . open ( "" , "_blank" ) ; w . document . title = 'Song lyrics' w . document . body . appendChild ( content ) ; } ) ; }
Show new tab with the lyrics of a song with the given artist and title.
Show new tab with the lyrics of a song with the given artist and title .
// Based on code from Ray Joe https://stackoverflow.com/questions/34735467/open-html-text-in-new-tab-using-window-open