javascript/List_Available_Rooms.js
/**
 * Create new div element for respond 
 * @param msg
 * @returns
 */
Create new div element for respond
@param msg
@returns
Create new div element for respond @param msg @returns
function createDivReceiveMessageWithYoutube(msg){
    var useridRegex = /^(\d*\w*)*:/
    var msgWithoutID = msg.replace(useridRegex,"");
    var userID = msg.substring(0, msg.indexOf(":")+1)
    if (msgWithoutID[0] == " "){
        msgWithoutID = msgWithoutID.substring(1,msgWithoutID.length)
    }
    messageIsYouTube = IsYouTube(msgWithoutID)
    if (messageIsYouTube){
        var newDiv = document.createElement("div"); 
        newDiv.classList.add("msg-area-disptext-response");	
        var newDivInner = document.createElement("div"); 
        newDivInner.classList.add("speech-bubble-response");
        newDiv.appendChild(newDivInner);
        var newDivUser = document.createElement("div");
        newDivUser.innerHTML = userID;
        newDivInner.appendChild(newDivUser);
        var newIFrame = document.createElement("iframe")
        newIFrame.classList.add("t-video");
        var video_id = msgWithoutID.split('v=')[1];
        var ampersandPosition = video_id.indexOf('&');
        if(ampersandPosition != -1) {
        video_id = video_id.substring(0, ampersandPosition);
        }
        newMsg = "https://www.youtube.com/embed/"+video_id
        newIFrame.src = newMsg;
        newIFrame.allow = "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture";
        newDivInner.appendChild(newIFrame)
        return newDiv
    }else{
        var divReceiveMsg = document.createElement("div"); 
        divReceiveMsg.classList.add("msg-area-disptext-response");
        divReceiveMsg.classList.add("speech-bubble-response");
        divReceiveMsg.innerHTML = msg;
        return divReceiveMsg
    }
}
function createDivReceiveMessageWithYoutube ( msg ) { var useridRegex = / ^(\d*\w*)*: / var msgWithoutID = msg . replace ( useridRegex , "" ) ; var userID = msg . substring ( 0 , msg . indexOf ( ":" ) + 1 ) if ( msgWithoutID [ 0 ] == " " ) { msgWithoutID = msgWithoutID . substring ( 1 , msgWithoutID . length ) } messageIsYouTube = IsYouTube ( msgWithoutID ) if ( messageIsYouTube ) { var newDiv = document . createElement ( "div" ) ; newDiv . classList . add ( "msg-area-disptext-response" ) ; var newDivInner = document . createElement ( "div" ) ; newDivInner . classList . add ( "speech-bubble-response" ) ; newDiv . appendChild ( newDivInner ) ; var newDivUser = document . createElement ( "div" ) ; newDivUser . innerHTML = userID ; newDivInner . appendChild ( newDivUser ) ; var newIFrame = document . createElement ( "iframe" ) newIFrame . classList . add ( "t-video" ) ; var video_id = msgWithoutID . split ( 'v=' ) [ 1 ] ; var ampersandPosition = video_id . indexOf ( '&' ) ; if ( ampersandPosition != - 1 ) { video_id = video_id . substring ( 0 , ampersandPosition ) ; } newMsg = "https://www.youtube.com/embed/" + video_id newIFrame . src = newMsg ; newIFrame . allow = "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" ; newDivInner . appendChild ( newIFrame ) return newDiv } else { var divReceiveMsg = document . createElement ( "div" ) ; divReceiveMsg . classList . add ( "msg-area-disptext-response" ) ; divReceiveMsg . classList . add ( "speech-bubble-response" ) ; divReceiveMsg . innerHTML = msg ; return divReceiveMsg } }
Create new div element for respond
 @param msg
 @returns
Create new div element for respond @param msg @returns
//also remove inital space if one exists //https://stackoverflow.com/questions/51316379/this-video-is-unavailable-when-putting-music-videos-in-iframe // NOTE MUSIC VIEDOS DONT WORK... //I found a fix actually. For some reason, // music videos need a web server in order to // play. So I just did a simple http server by  //using python - m http.server 80 and it worked. I  //don't know why it would need that, so if anybody // could explain that would be great – tytyty Jul 14 '18 at 15:01  // turns out you can't just embed the  // url directly as youtube block it // it needs to be in the form: //"https://www.youtube.com/embed/"+video_id // find video ID //create embedded url // add to frame //Add 2 css to div //return divReceiveMsg;