To me, it was not throwing any error, anyway, when no unread post class found, due to a subsequent click into those kind of
unread links, may clicked into notification email, after the topic already visited, what happen was that the code do not follow on redirect.
To complete the task, and make it redirect even when no unread found, redirecting to the last inserted, that obviously is the right one we want to be redirected to in this case, the complete code is little different, using both above snippets like this:
overall_header.html, leave code as is ( as explained here
https://www.axew3.com/w3/forums/viewtop ... 4932#p4932 )
while remove completely the previous code into
overall_footer.html, and as before, just after this code comment:
Code: Select all
///////////////////////////////////////////////////////////////////////////
// w3all UPDATES for phpBB events
add this code
(and do you remember the line to change into very first snippet where it say
need to match on DOM! ? Change also here like you did before, this line
$( "h3 > a" ).each(function (e) { // need to match on DOM!
that need to match to elements
a inside
h3 as above:
Code: Select all
if(window.self == window.top){
if(typeof w3allUnreadTopic != 'undefined'){
var hash = window.location.hash.substr(1);
if( hash == 'unread' ){
var w3postN = 1000000; // it's assumed that will be never 1000000 posts x page, isn't it?
var w3lh,w3ns,w3nsLowN;
$( ".unreadpost" ).each(function (e) {
var hpid = $(this).attr('id');
w3ns = hpid.split('p');
console.log(w3ns[1]);
if( w3ns[1] != 'undefined' ){
if(w3ns[1] < w3postN){
//console.log('w3ns[1] AND w3postN -> '+w3ns[1]+' - '+w3postN);
w3lh = w3postN = w3ns[1];
w3nsLowN = w3ns[1];
w3Rhash = "p" + w3lh;
}
}
//console.log('hash is ' + hash);
})
// https://localhost-subdomain.w3host.com/phpbb3/viewtopic.php?p=138#p138
if( typeof w3ns != 'undefined' && typeof w3Rhash != 'undefined' ){
var redirToUnread = boardU + 'viewtopic.php?p=' + w3lh + '#' + w3Rhash;
document.location.replace(redirToUnread);
} else {
var postN = 1;
$( "h3 > a" ).each(function (e) { // need to match on DOM!
ns = this.href.split('#p');
if( typeof ns != 'undefined' && /viewtopic.php\?p=/ig.exec(this.href) != null ){
if(ns[1] > postN){
w3lh = ns[1];
}
}
})
if( typeof w3lh != 'undefined' ){
var w3redirToLast = boardU + 'viewtopic.php?p=' + w3lh + '#p' + w3lh;
var w3all_r = w3all0Normalize_phpBBUrl(w3redirToLast);
if(/adm\/index\.php/ig.exec(w3all_r) == null){
var hrefEn = window.btoa(unescape(encodeURIComponent(w3all_r)));
var hre = wordpress_url_page_f + '/?'+ w3all_custom_wp_w3fancyurl + '=' + hrefEn;
document.location.replace(hre);
}
}
}
}
}
} // END if(window.self == window.top){
it still lack of a sort of trick, that should obscure things, where time latency until redirect happen