mChat Integration Woes

User avatar
DjPorkchop73
User www
User www
Posts: 73
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: 2229
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 959 times
wpMchatsub.png
wpMchatsub.png (13.28 KiB) Viewed 959 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: 2229
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: 2229
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: 2229
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: 73
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

User avatar
axew3
w3all User
w3all User
Posts: 2229
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Ops, but it refer to V4 or even V3 code!
Do not consider it, going to look the procedure, the code should work fine without nothing else but as mentioned above on this post.
Going to fix

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

Re: mChat Integration Woes

Post by DjPorkchop73 »

OK thanks. I'll take a look into it again. I appreciate your input and time helping me out with this.

I did get mchat installed and working successfully on my website but strangely enough I get no widgets or shortcodes of any type to work at all. Maybe I have settings wrong in the admin panel. The only widgets I got to work so far are recent forum topics widget and w3all login widget. All others are a no go including mchat.

I am going to double and triple check everything I have done thus far. Once again, thank you so much for you valuable help. If you wish to see my url to my website I can share. I was a little reluctant to post here as I did not want you to feel as I was shamelessly plugging my website.
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
DjPorkchop73
User www
User www
Posts: 73
Joined: Thu Aug 20, 2020 6:45 pm
Location: Egyptian Valley of Illinois

Re: mChat Integration Woes

Post by DjPorkchop73 »

I return with good news 90%. I have all working almost. The widget there is no prosilver header or footer but only chat as supposed to be, on my chat page the chat is there with no header or footer as supposed to as well. However 2 things exist.

1. My mChat Iframe will not resize on widget or chat page.
2. If I attempt to just use a toggle button like you have donehere , I can not get a button to appear at all no matter what I try. I can not get that short code to work.

Here is my website if you wish to take a look. I will turn on chat visible to non logged in users. My Website

You can see the widget I put up on every page but the home page and obviously you will easily find the chat page. :) If I manage to figure it out the rest of the way, I will come back and edit this post.
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: 2229
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Here we go: i've got the same problem, activating on same page, widget and shortcode.
Resizer do not will work, because the iframe ID assigned, will be found the same:

so to resolve this, i just opened
/views/wp_w3all_phpbb_mchat_short.php
file, and where
<iframe id="w3all_phpbb_mchat_iframe"
change the ID to something else, like adding a 0 for example, so the id will be unique:
<iframe id="w3all_phpbb_mchat_iframe0"

but it is secondary problem that only come out if more than one iframe found on page, so a stupid fix for shortcode + widget on same page: +- impossible situation. It is not your problem in this case, the problem into your example install is:

Code: Select all

w3all_phpbb_mchat_iframe:404:819:init. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.
array of allowed domains is not correctly passed
to make the long story short,

/views/wp_w3all_phpbb_mchat_short.php
and
/views/wp_w3all_phpbb_mchat.php

have been patched, to correctly pass array of allowed domains.

Could you test, please, these new files versions, into your install?
The zip contain both files, that need to replace same files, into folder
/wp-content/plugins/wp-w3all-phpbb-integration/views/

you can download both patched files directly on repository:
https://plugins.trac.wordpress.org/brow ... runk/views

or download this attach that contain both (same) files:
views.zip
(2.56 KiB) Downloaded 45 times

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

Re: mChat Integration Woes

Post by DjPorkchop73 »

Thanks for the reply. I will test them files out for you on my install. I apologize for trying both shortcode and widget at the same time. I did not put thought to it when I attempted it.

I did just remove one and tried the other and either way I went, the widget nor the shortcode iframe would resize. I'll go give your fixes a try real quick.
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
DjPorkchop73
User www
User www
Posts: 73
Joined: Thu Aug 20, 2020 6:45 pm
Location: Egyptian Valley of Illinois

Re: mChat Integration Woes

Post by DjPorkchop73 »

I tried your files and I can use the frame on the page or post successfully. I can remove it and only use a widget in the sidebar if I wish as well. I then tried both as suggested to try and it worked as well successfully. Everything shows and resizes accordingly now. Nicely done on them fixes!

The only thing I cannot get to work is the Toggle Button in the lower right hand corner like on your sample page. I did activate the custom css file as instructed too and still a no go on the toggle button.
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: 2229
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: mChat Integration Woes

Post by axew3 »

Ok, this should be the last one, the file
/views/wp_w3all_phpbb_mchat_short.php
reverted the line:
<iframe id="w3all_phpbb_mchat_iframe0"
to what it was:

Code: Select all

<iframe id="w3all_phpbb_mchat_iframe"
and now works: the js code search for this ID.

As is now so, remember to not activate mChat shortcode and widgets on same page.
Or the js code needs to be changed, and the ID of the iframe element switched to something unique, or the code will fail.

Download and replace into plugin's /views/ folder:
https://plugins.trac.wordpress.org/expo ... _short.php

p.s this point (and linked post) has been added into the mChat procedure post:
viewtopic.php?p=3430#p3430

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

Re: mChat Integration Woes

Post by DjPorkchop73 »

My apologies for taking a couple days to reply. I got very busy the last couple days.

I was never able to get the toggle button working. Not sure exactly why. Maybe I have java conflict going on? I have went through all my files, uploaded all brand new files, double checked all edits and still a no go.

I'm not real sure what is failing or why but in the end, it really is not a big deal to me for now. At least the full page short code will work and or a widget which ever I choose. I do appreciate all of your help on this.
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