def flag_callback():
    """JS callback for the flagging button

    Returns
    -------
    code : :obj:`str`
    """
    code = """
            //sources: list of all different sources for the different antennas and available sources
            //n_sources: number of sources
            //flagging: status of flag_data

            let n_sources =  uf_sources.length;

            if (cb_obj.active.includes(0)){
                for (let i=0; i<n_sources; i++){
                    uf_sources[i].data.y1 = f_sources[i].data.iy1;
                    uf_sources[i].data.y2 = f_sources[i].data.iy2;
                    uf_sources[i].change.emit();
                }
            }
            else{
                for (let i=0; i<n_sources; i++){
                    uf_sources[i].data.y1 = f_sources[i].data.y1;
                    uf_sources[i].data.y2 = f_sources[i].data.y2;
                    uf_sources[i].change.emit();
                }


            }
           """
    return code
