This error appear if I don't rename hash variable.
What it mean? What kind of url you try to load to get the error?
Should not because if/when there are no unread, the code should redirect to last one, passing urls like
Code: Select all
https://localhost-subdomain.w3host.com/phpbb3/viewtopic.php?f=2&t=26&e=1&view=unread#unread
AND NOTE that as code is
this line need to match on DOM or as you see, it will return error after, because the code search for
unread, and if not found, search for the last one inserted, and if not found again, it make fail the code as before was, so it is mandatory that these elements match on DOM
$( "h3 > a" ).each(function (e) { // need to match on DOM!
The error mean that
hash var do not contain a valid value, so when the js search for value based on this it return error. Of course the code can be fixed to avoid this in any case: anyway if no unread found, we should want to redirect to the last one inserted
going to repeat steps to resume:
on the js
overall_header.html added code, just after
// END MANDATORY CHANGES line,
ADD this:
Code: Select all
if(/view=unread#unread/ig.exec(window.location.href) !== null && /viewtopic.php\?/ig.exec(window.location.href) !== null)
{
var w3allUnreadTopic = 1;
}
then change/replace this line:
document.location.replace(href0);
into this:
Code: Select all
if(typeof w3allUnreadTopic == 'undefined'){
document.location.replace(href0);
}
Save.
Now open
overall_footer.html
on added js code, just after this comment:
Code: Select all
///////////////////////////////////////////////////////////////////////////
// w3all UPDATES for phpBB events
add the follow:
Code: Select all
if(window.self == window.top){
if(typeof w3allUnreadTopic != 'undefined'){
var hash = window.location.hash.substr(1);
if( hash == 'unread' ){
$( "body" ).prepend( "<div class=\"preUnreadRedirectBG\"></div>" );
$(".preUnreadRedirectBG").css({"position":"fixed","color": "red","top":"0%","bottom":"0%","left":"0%","right":"0%","background": "rgba(0,0,0,1)","z-index": "99999","width":"100%"})
var w3postN = 1000000; // it's assumed that will be never 1000000 replies x page
var w3lh,w3ns,w3nsLowN;
$( ".unreadpost" ).each(function (e) {
var hpid = $(this).attr('id');
w3ns = hpid.split('p');
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){
Remember to recompile stale template.
It is tested working into any browser here, so let know if still in trouble