2019-06-19, 01:04 AM
I am using this plugin, but modified to create the unread posts number in the tab. However the plugin author abandoned the plugin....so he is no help. I modified the previous linked file accordingly....
Right in the if condition that changes the document.title or leaves it as "Python Forum" I would like to add another clause that if the user is in a certain user group ( a secondary user group that wants to see this notification in the tab) then they see the number, otherwise they do not.
so pseudo code like:
But i dont know how to define "usergroup" or "tab_display_true" group within the javascript file?
In PHP to get the UID of hte user you would do similar to
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);
},
};
Right in the if condition that changes the document.title or leaves it as "Python Forum" I would like to add another clause that if the user is in a certain user group ( a secondary user group that wants to see this notification in the tab) then they see the number, otherwise they do not.
so pseudo code like:
if (d != "0"){
if (usergroup == tab_display_true){
var newTitle = '(' + d + ') ' + "Python Forum";
document.title = newTitle;
}
}
else{
document.title = "Python Forum";
}
But i dont know how to define "usergroup" or "tab_display_true" group within the javascript file?
In PHP to get the UID of hte user you would do similar to
!$mybb->user['uid']
I am assuming instead of uid there is one for usergroup?!$mybb->user['usergroup']
But still even if there is, how to you apply it to a javascript file?