mChat Integration Woes

User avatar
DjPorkchop73
User www
User www
Posts: 80
Joined: Thu Aug 20, 2020 6:45 pm
Location: Egyptian Valley of Illinois

mChat Integration Woes

Post by DjPorkchop73 »

Ciao! I was taking a look over the integration for mChat and I can not help but take notice that the code needed to be altered in the overall_footer.html is different in V5 than it is in the older v4 version. Would you happen to have updated instructions for the java code alterations for the V5 Iframe integration as well?

Many thanks in advance either way. I hope all is very well with you. Take very good care!
If I could I would. If I don't, it's because I am lazy!

"Don't gain the world and lose your soul, wisdom is better than silver and gold" -Bob Marley
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Ciao caro! :D

First: the mChat wp forum post https://wordpress.org/support/topic/w3a ... -procedure

... there is nothing i can imagine, i, like anybody else at this point, if i do not see an online example that let me see the code on console/DOM, because ...

Allora ... i just activated the mchat, with v5 code and it result to work fine.
I'm testing into phpBB 3.3.0 and prosilver
I'm on wp 5.5, since into my localhost the wp at moment, under php 7.4.7 (but it is probably not the reason of the problem), refuse to update (and i see it is a problem of many on last 5.5)

I downloaded the plugin 2.3.9, and replaced into this test on localhost, all plugin files (patched last days to fix something about mChat widgets/shortcode) to be sure i'm with all plugin's patches applied.

I installed mChat into the linked phpBB, and applied on ACP, for the group admins, which i'm testing the user i'm logged in with, that is an admin, under Groups permissions, advanced, Set to yes all permissions about mchat, then saved.

Then i activated the mChat widget into wp, and works fine.

At this point, the mChat display with all phpBB header and footer inside the widget: so as suggested into the post at wp.org, i applied into overall_footer.html, as reported on procedure, this code (that's exactly the same, i changed nothing into my working test):

Just after:
<!-- EVENT overall_footer_body_after -->

add the follow:

Code: Select all

<script>
// a simple mChat style/display example setup for WP 
if( /#w3allmchatif/ig.exec(document.URL) != null || /#w3allmchatif/ig.exec(document.location.href) != null ){
	var boardU = "{BOARD_URL}";
	var hnofollow = 0;
$( document ).ready(function() {

$( "body" ).on("click", "a", function(e) {
	var href = $(this).attr("href");

 if( typeof href != 'undefined' && this.href[this.href.length -1] != '#' && /\?jumpto=/ig.exec(this.href) == null )
	{
	 if( href.indexOf(boardU) < 0 || href.indexOf('i=permissions&mode=setting_user_global') > -1 || href.indexOf('/mchat') > -1 ){
	 //if(href.indexOf('/mchat') > -1){
	 if( /[.+[\/mchat]$/ig.exec(href) !== null ){
		return;
	 }
	 
		hnofollow = 1;
		e.preventDefault();
		e.stopPropagation();
		window.open(href,'_blank');
		return;
	} else {
		e.preventDefault();
		e.stopPropagation();
		window.open(href,'_blank');
		return;
	}
	}
});	
	
$( "#page-header,#page-footer" ).css( { "height" : "0px", "max-height" : "0px", "overflow": "hidden" } ); // can't be none, or events will not affect
$( ".page-body,#wrap" ).css( { "margin" : "0px", "padding" : "0px" } );
$( ".page-body h2,#mchat-legend" ).css( "display", "none" );
$( "div.mchat-text blockquote div cite a" ).click(function(e) {
	if( /\?jumpto=/ig.exec(this.href) == null ){
		e.preventDefault();
		if(hnofollow < 1){
		 window.open(this.href,'_blank');
	  }
		return;
	}
});

$( "div.list-inner span.mchat-title a" ).click(function(e) {
		e.preventDefault();
		window.open(this.href,'_blank');
		return;
});

$( "body" ).on("click", ".username,.username-coloured,#mchat-legend a,cite a", function(e) {
	var href = $(this).attr("href");
	if( typeof href != 'undefined' && /\?jumpto=/ig.exec(this.href) == null ){
		e.preventDefault();
		if(hnofollow < 1){
		window.open(href,'_blank');
	}
		return;
	}
});

}); // ready
}
</script>
May the documentation lack to remember, because it is not mentioned (not sure i've not re-read the procedure) that is by the way inline into this file:
/wp-content/wp-w3all-phpbb-integration/addons/custom_js_css.php
this part that need to be switched if:
/* activate this only if on shortcode mode */

Code: Select all

<style type="text/css">
#w3all_phpbb_mchat_iframe{
/* activate this only if on shortcode mode */
/* position:absolute;top:0px; */
}
which i do not activated, since i'm on widget test, and not shortcode
All seem to work fine into my fly test. phpBB Header and Footer hidden on widget. May some theme differ by the default prosilver, and the code need to be adjusted to match correct DOM elements, it is easy do for javascript programmers, even if not so skilled like me ;)

The correct result that display to me in prosilver raw/fly test:
wpMchat.png
wpMchat.png (25.57 KiB) Viewed 3511 times
wpMchatsub.png
wpMchatsub.png (13.28 KiB) Viewed 3511 times
All will be updated soon, it is a raw procedure that can be improved to be easier and perfect.
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Ok, looking to fix issues on v5 code, mChat was not considered .. in reply as ready/patched
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Ok, the V5 iframe code (only overall_footer.html code) has been updated on fly, to fix mChat issues:
https://www.axew3.com/w3/2020/01/phpbb- ... iframe-v5/
cheers!
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Before to close all and dedicate again to an hack for phpBB, for a request that need to let users Rotate attachments images into phpBB posts (that's ready working in my tests) ... then again i will be over for 2.4.0 plugin release:

for luck i had the logger open on browser, and tested a refresh with mchat:
it was an error now resolved on overall_footer.html code.
It is all fixed now.

A note:
i see that when mchat display into home widget, mChat return a js error, that by the way do not corrupt any result. The error disappear and appear without a valid reason to me at moment, i've not follow on check why this happen.

I note also, that the button Archive should be removed and not display if on mChat WP widget, or if you click on it, the entire phpBB will display inside the widget! So you could navigate the phpBB into the widget, but in this case, again, the overall_footer.html js code V5 will return errors, even if all works, since some function need to not execute in this case, because related parent js function, outside page-forum, do not exist!

I will take a deep look into, when V6 code will be released and all about mChat rewrite/improved
User avatar
DjPorkchop73
User www
User www
Posts: 80
Joined: Thu Aug 20, 2020 6:45 pm
Location: Egyptian Valley of Illinois

Re: mChat Integration Woes

Post by DjPorkchop73 »

Hello! Thanks for the fantastic reply.

I am using the embedded Iframe so I follow the instructions that tell me the following:

In the styles/ProSilver/overall_footer.php it says to

Find:

Code: Select all

 if ('parentIFrame' in window) window.parentIFrame.scrollTo(0,50); // change 50 to another value may 0 or 100 or 500. Top distance gap in px when page scroll top
and change it to :

Code: Select all

if( typeof w3_chat_phpBBpage == 'undefined' ){ // activate fix for mchat to not scroll
  if ('parentIFrame' in window) window.parentIFrame.scrollTo(0,50); // change 50 to another value may 0 or 100 or 500. Top distance gap in px when page scroll top
}
The v5 code in question in the overall_footer.html is :

Code: Select all

if ('parentIFrame' in window){
  if( typeof w3allNOappend == 'undefined' || w3allNOappend == false ){
    window.parentIFrame.sendMessage(w3allappend);
  }
 }
For reference so you know what I am taking a look at, I am referring to your forum post at: https://www.axew3.com/w3/forum/?coding= ... ImdD05MTE=

This is of no emergency to me and I have not installed it at all on my website. I do like to look over files and code in advance prior to installing anything to make sure all is well. This is the only discrepancy I find so far. :-)
If I could I would. If I don't, it's because I am lazy!

"Don't gain the world and lose your soul, wisdom is better than silver and gold" -Bob Marley
Post Reply