function toggleSpeakerMode() {
    
    buttons_base = document.getElementsByClassName("btn-group");
    // buttons = document.childNodes[1].childNodes[0].childNodes[3].childNodes[7];
    for(var i = 0; i < buttons_base[0].childNodes.length; i++){
        button = buttons_base[0].childNodes[i];
        if(button.nodeName == "BUTTON"){
            buttons.push(button);
            button.addEventListener("click", function() {

                var canvas = document.querySelector("#popular_speaker canvas");
                var ctx = canvas.getContext('2d');

                if(this.className != "my_btn clicked"){
                    var other = document.getElementsByClassName("my_btn clicked");
                    other[0].className = other[0].className.replace(" clicked", "");
                    this.className += " clicked";
                    president_speakers_mode = !president_speakers_mode;
                    // ctx.save();
                    ctx.clearRect(0, 0, canvas.width, canvas.height);
                    // change data
                    // canvas.preload;
                    // canvas.setup;
                    setData();
                    drawEverything(speakers_sketch);
                    // let a = new p5(s7);
                    // ctx = a.getContext('2d');
                    // ctx.restore();
                }                
            });
        } 
    }
}
// Button is selected, when it's class is my_btn_clicked. When not selected, the class is my_btn
Button is selected, when it's class is my_btn_clicked. When not selected, the class is my_btn
Button is selected when it ' s class is my_btn_clicked . When not selected the class is my_btn
function toggleSpeakerMode() {
    buttons_base = document.getElementsByClassName("btn-group");
    for(var i = 0; i < buttons_base[0].childNodes.length; i++){
        button = buttons_base[0].childNodes[i];
        if(button.nodeName == "BUTTON"){
            buttons.push(button);
            button.addEventListener("click", function() {
                var canvas = document.querySelector("#popular_speaker canvas");
                var ctx = canvas.getContext('2d');
                if(this.className != "my_btn clicked"){
                    var other = document.getElementsByClassName("my_btn clicked");
                    other[0].className = other[0].className.replace(" clicked", "");
                    this.className += " clicked";
                    president_speakers_mode = !president_speakers_mode;
                    ctx.clearRect(0, 0, canvas.width, canvas.height);
                    setData();
                    drawEverything(speakers_sketch);
                }                
            });
        } 
    }
}
function toggleSpeakerMode ( ) { buttons_base = document . getElementsByClassName ( "btn-group" ) ; for ( var i = 0 ; i < buttons_base [ 0 ] . childNodes . length ; i ++ ) { button = buttons_base [ 0 ] . childNodes [ i ] ; if ( button . nodeName == "BUTTON" ) { buttons . push ( button ) ; button . addEventListener ( "click" , function ( ) { var canvas = document . querySelector ( "#popular_speaker canvas" ) ; var ctx = canvas . getContext ( '2d' ) ; if ( this . className != "my_btn clicked" ) { var other = document . getElementsByClassName ( "my_btn clicked" ) ; other [ 0 ] . className = other [ 0 ] . className . replace ( " clicked" , "" ) ; this . className += " clicked" ; president_speakers_mode = ! president_speakers_mode ; ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ; setData ( ) ; drawEverything ( speakers_sketch ) ; } } ) ; } } }
Button is selected, when it's class is my_btn_clicked.
Button is selected when it ' s class is my_btn_clicked .
// buttons = document.childNodes[1].childNodes[0].childNodes[3].childNodes[7]; // ctx.save(); // change data // canvas.preload; // canvas.setup; // let a = new p5(s7); // ctx = a.getContext('2d'); // ctx.restore();