by axew3 » Sun Jan 17, 2021 11:02 am
The unique things that 'intentionally' do not will match with default behavior, because it has been intentionally changed to be this way, is the fact that if an user is not logged in and present a link like this:
Code: Select all
https://subdomain.w3host.com/phpbb3/viewtopic.php?f=2&t=15&e=1&view=unread#unread
the code do not redirect the user to the login page, but to the last post on topic.
Resuming all the procedure, that at moment will not be added into v6 code by default, but that work fine, is as follow:
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'){
$( "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 hash = window.location.hash.substr(1);
if( hash == 'unread'){
if("{S_USER_LOGGED_IN}" < 1){
var usp = window.location.href;
w3ns = usp.split('&e=1');
document.location.replace(w3ns[0]);
}
if("{S_USER_LOGGED_IN}" > 0){
var w3postN = 1000000;
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){ // reset to the lower if found
w3lh = w3postN = w3ns[1]; // set to actual
w3nsLowN = w3ns[1];
w3Rhash = "p" + w3nsLowN;
}
}
})
// 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 && typeof w3lh == 'undefined'){
w3lh = ns[1];
}
}
})
if( typeof w3lh != 'undefined' ){
var w3redirToLast = boardU + 'viewtopic.php?p=' + w3lh + '#p' + w3lh;
if(/adm\/index\.php/ig.exec(w3all_r) == null){
document.location.replace(w3redirToLast);
}
}
}
} // END if("{S_USER_LOGGED_IN}" > 0){
}
}
} // END if(window.self == window.top){
cheers!
The unique things that 'intentionally' do not will match with default behavior, because it has been intentionally changed to be this way, is the fact that if an user is not logged in and present a link like this:
[code]https://subdomain.w3host.com/phpbb3/viewtopic.php?f=2&t=15&e=1&view=unread#unread[/code]
the code do not redirect the user to the login page, but to the last post on topic.
[color=#BF0040][size=150]
Resuming all the procedure, that at moment will not be added into v6 code by default, but that work fine, is as follow:[/size][/color]
on the js [size=120]overall_header.html[/size] added code, just after
[c]// END MANDATORY CHANGES[/c] line,
[b]ADD this:[/b]
[code] if(/view=unread#unread/ig.exec(window.location.href) !== null && /viewtopic.php\?/ig.exec(window.location.href) !== null)
{
var w3allUnreadTopic = 1;
} [/code]
then change/replace this line:
[c]document.location.replace(href0);[/c]
[b]into this: [/b]
[code] if(typeof w3allUnreadTopic == 'undefined'){
document.location.replace(href0);
}[/code]
Save.
Now open [size=120]overall_footer.html[/size]
on added js code, just after this comment:
[code]
///////////////////////////////////////////////////////////////////////////
// w3all UPDATES for phpBB events[/code]
[b]add the follow:[/b]
[code]if(window.self == window.top){
if(typeof w3allUnreadTopic != 'undefined'){
$( "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 hash = window.location.hash.substr(1);
if( hash == 'unread'){
if("{S_USER_LOGGED_IN}" < 1){
var usp = window.location.href;
w3ns = usp.split('&e=1');
document.location.replace(w3ns[0]);
}
if("{S_USER_LOGGED_IN}" > 0){
var w3postN = 1000000;
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){ // reset to the lower if found
w3lh = w3postN = w3ns[1]; // set to actual
w3nsLowN = w3ns[1];
w3Rhash = "p" + w3nsLowN;
}
}
})
// 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 && typeof w3lh == 'undefined'){
w3lh = ns[1];
}
}
})
if( typeof w3lh != 'undefined' ){
var w3redirToLast = boardU + 'viewtopic.php?p=' + w3lh + '#p' + w3lh;
if(/adm\/index\.php/ig.exec(w3all_r) == null){
document.location.replace(w3redirToLast);
}
}
}
} // END if("{S_USER_LOGGED_IN}" > 0){
}
}
} // END if(window.self == window.top){[/code]
cheers!