× Warning! This forum is in archival status. New contributions may not work.
Small javascript hack for DateTime in Listener Stats (hovering a point)
  • Hello again :)
    After so many months i found some time to mess around with my internet radio station again. I wanted to see in the listener stats (in a broad period of time) when all those peeks were happening but i found out that there was no such information and i had to narrow my search in a period of few hours to have a clear view.
    The /listenerstat/get-data url (if you just put /get-data after your URL when you go to listener data) has this information (as epoch timestamp) and so after i found the javascript file responsible for this page i noticed that this information is already there but not displayed. So to add this information (when hovering each point) is very easy.

    You just change the part of the code i am showing below (in bold the new code) inside file /usr/share/airtime/public/js/airtime/listenerstat/listenerstat.js



    var previousPoint = null;
            $("#flot_placeholder").bind("plothover", function (event, pos, item) {
                if (item) {
                    if (previousPoint != item.dataIndex) {
                        previousPoint = item.dataIndex;

                        $("#tooltip").remove();
                        var y = item.datapoint[1].toFixed(2);
                        var seconds = item.datapoint[0];

                        var d = new Date(seconds);

                        showTooltip(item.pageX, item.pageY,
                                    sprintf($.i18n._("Listener Count on %s: %s %s"), item.series.label, Math.floor(y),d.toUTCString()));
                    }
                }
                else {
                    $("#tooltip").remove();
                    previousPoint = null;
                }
            });



    Now if you see in the page you will notice that when you hover a point you also the utc date as information. Thats handy for me and together with all the changes on "Now Playing" for scheduling that we talked about in the past, makes my everyday life with airtime a lot easier...

    Ps. Always keep a backup of the files you change... most of the times i dont and many times i regret it ;)