Python Forum

Full Version: modifying counter tab
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My goal is to create a user group in which any user can opt in and out of. This is a secondary user group. When in this usergroup you see the tab counter (1) Python Forum for unread posts. If your not in the user group, then you only see the title Python Forum. This only occurs when your on the main index page (not in a thread)

The PHP file returning the content is here.

The javascript function is:
var unreadPosts = {
 
    timeout:    false,
    interval:   10,
    enable:     false,
    fid:        0,
    hide:       false,
 
    updateCounter: function() {
        if (!unreadPosts.enable) {
            return;
        }
 
        $.get( "xmlhttp.php?action=unreadPosts_getUnreads&fid" + unreadPosts.fid, function( data ) {
            $("#unreadCounter").replaceWith(data);
 
        var d = data.split('<!--')[2] //strip non-counter
        var d = d.split('-->')[1] //strip to only counter
        var d = d.slice(3, -2); //remove extra paren
        var title = document.title;
       // var title = "Python Forum";
        //if title.startsWtih('('){
        //    var title = title.split(')')[1] //remove extra num if there is one
        //}
          
 
        //var title = title.split(" ").splice(1,-2)
 
        if (d != "0"){
            var newTitle = '(' + d + ') ' + "Python Forum";
            document.title = newTitle;
        }
        else{
            document.title = "Python Forum";
        }
 
 
        });
        if (unreadPosts.timeout) clearTimeout(unreadPosts.timeout);
        unreadPosts.timeout = setTimeout('unreadPosts.updateCounter()', unreadPosts.interval * 1000);
    },
};
Does anyone know how to include this?