<commit_before><?php
/**
 * @var array $nowplaying
 * @var \App\Entity\Station $station
 */
?>

var nowPlaying, backendStatus, frontendStatus;

$(function() {
    nowPlaying = new Vue({
        el: '#profile-nowplaying',
        data: {
            np: <?=json_encode($nowplaying) ?>,
            np_elapsed: 0,
            clock_interval: null
        },
        created: function() {
            this.clock_interval = setInterval(this.iterateTimer, 1000);
        },
        computed: {
            "time_display": function() {
                var time_played = this.np_elapsed;
                var time_total = this.np.now_playing.duration;

                if (!time_total) {
                    return null;
                }

                if (time_played > time_total) {
                    time_played = time_total;
                }

                return this.formatTime(time_played) + ' / ' + this.formatTime(time_total);
            }
        },
        methods: {
            "setNowPlaying": function(np_new) {
                this.np = np_new;

                // Update mount-specific listener counts.
                np_new.station.mounts.forEach(function(mount) {
                    $('#mount_'+mount.id+' .listeners-total').text(mount.listeners.total);
                    $('#mount_'+mount.id+' .listeners-unique').text(mount.listeners.unique);
                });

                // Update remote-specific listener counts.
                np_new.station.remotes.forEach(function(remote) {
                    $('#remote_'+remote.id+ '.listeners-total').text(remote.listeners.total);
                    $('#remote_'+remote.id+ '.listeners-unique').text(remote.listeners.unique);
                });
            },
            "formatTime": function(time) {
                var sec_num = parseInt(time, 10);

                var hours = Math.floor(sec_num / 3600);
                var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
                var seconds = sec_num - (hours * 3600) - (minutes * 60);

                if (hours < 10) {
                    hours = "0" + hours;
                }
                if (minutes < 10) {
                    minutes = "0" + minutes;
                }
                if (seconds < 10) {
                    seconds = "0" + seconds;
                }
                return (hours !== "00" ? hours + ':' : "") + minutes + ':' + seconds;
            },
            "iterateTimer": function() {
                var current_time = Math.floor(Date.now() / 1000);
                var np_elapsed = current_time - this.np.now_playing.played_at;
                if (np_elapsed < 0) {
                    np_elapsed = 0;
                } else if (np_elapsed >= this.np.now_playing.duration) {
                    np_elapsed = this.np.now_playing.duration;
                }

                this.np_elapsed = np_elapsed;
            }<commit_msg>Fix relay listener count display on profile.<commit_after><?php
/**
 * @var array $nowplaying
 * @var \App\Entity\Station $station
 */
?>

var nowPlaying, backendStatus, frontendStatus;

$(function() {
    nowPlaying = new Vue({
        el: '#profile-nowplaying',
        data: {
            np: <?=json_encode($nowplaying) ?>,
            np_elapsed: 0,
            clock_interval: null
        },
        created: function() {
            this.clock_interval = setInterval(this.iterateTimer, 1000);
        },
        computed: {
            "time_display": function() {
                var time_played = this.np_elapsed;
                var time_total = this.np.now_playing.duration;

                if (!time_total) {
                    return null;
                }

                if (time_played > time_total) {
                    time_played = time_total;
                }

                return this.formatTime(time_played) + ' / ' + this.formatTime(time_total);
            }
        },
        methods: {
            "setNowPlaying": function(np_new) {
                this.np = np_new;

                // Update mount-specific listener counts.
                np_new.station.mounts.forEach(function(mount) {
                    $('#mount_'+mount.id+' .listeners-total').text(mount.listeners.total);
                    $('#mount_'+mount.id+' .listeners-unique').text(mount.listeners.unique);
                });

                // Update remote-specific listener counts.
                np_new.station.remotes.forEach(function(remote) {
                    $('#remote_'+remote.id+' .listeners-total').text(remote.listeners.total);
                    $('#remote_'+remote.id+' .listeners-unique').text(remote.listeners.unique);
                });
            },
            "formatTime": function(time) {
                var sec_num = parseInt(time, 10);

                var hours = Math.floor(sec_num / 3600);
                var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
                var seconds = sec_num - (hours * 3600) - (minutes * 60);

                if (hours < 10) {
                    hours = "0" + hours;
                }
                if (minutes < 10) {
                    minutes = "0" + minutes;
                }
                if (seconds < 10) {
                    seconds = "0" + seconds;
                }
                return (hours !== "00" ? hours + ':' : "") + minutes + ':' + seconds;
            },
            "iterateTimer": function() {
                var current_time = Math.floor(Date.now() / 1000);
                var np_elapsed = current_time - this.np.now_playing.played_at;
                if (np_elapsed < 0) {
                    np_elapsed = 0;
                } else if (np_elapsed >= this.np.now_playing.duration) {
                    np_elapsed = this.np.now_playing.duration;
                }

                this.np_elapsed = np_elapsed;
            }
{'fraction_non_alphanumeric': 0.1256606990622336, 'fraction_numerical': 0.013640238704177323, 'mean_word_length': 1.3351910828025477, 'pattern_counts': {'":': 8, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5095992', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1549, 'n_words': 292}