Various modifications for phpBB3mChat Live Character Counter Addon

Snippets for phpBB3
Previous topicNext topic
User avatar

Topic Author
dmzx
Founder
Founder
Magic user status: Online
Posts: 5978
Joined: Jan 13th, '14, 20:45
    unknown unknown

mChat Live Character Counter Addon

Post by dmzx »

MChat Live Character Counter Addon

Display a real-time indication of your mChat message limit and how many characters you have remaining. You will be prevented from entering any more characters once you reach zero.

Requirements: jQuery maxlength plugin - see attachment (and installed and working mChat)

Image

Image

Open: mchat.php
Find This may be a partial find and not the whole line

Code: Select all

'MCHAT_MESSAGE_LNGTH'   => $config_mchat['max_message_lngth'],
Add after Add these lines on a new blank line after the preceding line(s) to find

Code: Select all

'L_MCHAT_MESSAGE_LNGTH_EXPLAIN'   => (intval($config_mchat['max_message_lngth'])) ? sprintf($user->lang['MCHAT_MESSAGE_LNGTH_EXPLAIN'], intval($config_mchat['max_message_lngth'])) : '',
Open: language/en/mods/mchat_lang.php
Find This may be a partial find and not the whole line

Code: Select all

'MCHAT_MESS_LONG'         => 'Your message is too long.\nPlease limit it to %s characters',
Add after Add these lines on a new blank line after the preceding line(s) to find

Code: Select all

'MCHAT_MESSAGE_LNGTH_EXPLAIN'   => 'Characters remaining: <span class="charsLeft error"><strong>%d</strong></span>',
Open: styles/prosilver/template/overall_header.html
Find This may be a partial find and not the whole line

Code: Select all

<!-- IF S_MCHAT_ENABLE and (S_MCHAT_ON_INDEX or U_MCHAT) -->
Find This may be a partial find and not the whole line

Code: Select all

<script type="text/javascript" src="{ROOT_PATH}mchat/jquery_cookie_mini.js"></script>
Add after Add these lines on a new blank line after the preceding line(s) to find

Code: Select all

<script type="text/javascript" src="{ROOT_PATH}mchat/jquery.maxlength.min.js"></script>
Open: styles/prosilver/template/mchat_body.html
Find This may be a partial find and not the whole line

Code: Select all

<input type="text" name="message" class="inputbox medium mChatText" id="mChatMessage" /><br />
In line find This is a partial match of a line for in-line operations

Code: Select all

class="inputbox medium mChatText
In line add after

Code: Select all

<!-- IF MCHAT_MESSAGE_LNGTH neq 0 --> limited<!-- ENDIF -->
In line find This is a partial match of a line for in-line operations

Code: Select all

id="mChatMessage"
In line add after

Code: Select all

<!-- IF MCHAT_MESSAGE_LNGTH neq 0 --> maxlength="{MCHAT_MESSAGE_LNGTH}"<!-- ENDIF -->
Find This may be a partial find and not the whole line

Code: Select all

<input id="submit_button" type="button" class="button2" onclick="mChat.add();" value="{L_MCHAT_ADD}" />
Add before Add these lines on a new blank line before the preceding line(s) to find

Code: Select all

<!-- IF MCHAT_MESSAGE_LNGTH neq 0 --><p>{L_MCHAT_MESSAGE_LNGTH_EXPLAIN}&nbsp;</p><!-- ENDIF -->
Find This may be a partial find and not the whole line

Code: Select all

<!-- IF MCHAT_ALLOW_SMILES and .smiley -->
Add before Add these lines on a new blank line before the preceding line(s) to find

Code: Select all

<!-- IF MCHAT_MESSAGE_LNGTH neq 0 -->
                <script type="text/javascript">
                // <![CDATA[
                   $('input.limited').maxlength({
                      'feedback' : '.charsLeft',
                      'useInput' : false
                   });
                // ]]>
                </script>
                <!-- ENDIF -->
Save and upload!
Upload jquery.maxlength.min.js to mchat/ folder.
Refresh templates and clear board cache.
Done!
jquery.maxlength.min.js.zip
Notes:
In case you are using the textarea mChat modification, you need to figure out the exact edits yourself, basically the following changes are required:

Code: Select all

 <!-- IF MCHAT_MESSAGE_LNGTH neq 0 -->
    <input type="hidden" name="maxlength" value="{MCHAT_MESSAGE_LNGTH}" />
    <script type="text/javascript">
    // <![CDATA[
    $('textarea.limited').maxlength({
    'feedback' : '.charsLeft',
    'useInput' : true
    });
    // ]]>
    </script>
    <!-- ENDIF -->

plus you DO NOT need to add the following to the message textarea:

Code: Select all

<!-- IF MCHAT_MESSAGE_LNGTH neq 0 --> maxlength="{MCHAT_MESSAGE_LNGTH}"<!-- ENDIF -->
grtz dmzx
You do not have the required permissions to view the files attached to this post.
binance.com ;) try it!
User avatar

clight77
Donator
Donator
Magic user status: Offline
Posts: 444
Joined: Sep 24th, '15, 14:23
    Windows 10 Firefox

Re: mChat Live Character Counter Addon

Post by clight77 »

Lovely addon
Thanks for all your efforts :)
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4844
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: mChat Live Character Counter Addon

Post by martin »

clight77 wrote:Lovely addon
Thanks for all your efforts :)
What version of mchat are you using ?? i do believe this dont work on 0.1.4
Use this to install an ext on your board no more ftp or path making.
Path too install this ext is ext/boardtools/upload
Download is here Make it easy for us to solve your issues
User avatar

clight77
Donator
Donator
Magic user status: Offline
Posts: 444
Joined: Sep 24th, '15, 14:23
    Windows 10 Firefox

Re: mChat Live Character Counter Addon

Post by clight77 »

I am using v1.3.8 of mChat and it works wonderfully :)

Of course I am using phpbb3 v3.0.12 :)
Last edited by clight77 on Oct 1st, '15, 20:28, edited 1 time in total.
User avatar

Ostdarva
Users
Users
Magic user status: Offline
Posts: 74
Joined: Sep 18th, '15, 21:46
    Windows 7 Firefox

Re: mChat Live Character Counter Addon

Post by Ostdarva »

Awesome!!!! :tumbsyes: :tumbsyes:

Image
Add me on Twitter[https://twitter.com/DarvaTV] ImageCheck me out on Twitch! [https://twitch.tv/darvatv] Image
User avatar

martin
Admin
Admin
Magic user status: Offline
Posts: 4844
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: mChat Live Character Counter Addon

Post by martin »

clight77 wrote:I am using v1.3.8 of mChat and it works wonderfully :)

Of course I am using phpbb3 v3.0.12 :)
That's why it's working then as this code is old.
User avatar

clight77
Donator
Donator
Magic user status: Offline
Posts: 444
Joined: Sep 24th, '15, 14:23
    Windows 10 Firefox

Re: mChat Live Character Counter Addon

Post by clight77 »

I have to many modifications on my site so phpbb3.1 is out of the question for me :(
Previous topicNext topic