@mention members

Started by Dragooon, May 02, 2014, 01:07:58 PM

Previous topic - Next topic

Dragooon

Oh I did opposite of what I was going for :P

Try replacing the find with this
	
foreach (
$string as $k => $char)
	
{
	
	
if (
$char == '@' && (!isset($string[$k 1]) || $string[$k 1] == ' '))

Squash

Quote from: Dragooon on May 31, 2014, 01:40:36 AM
Oh I did opposite of what I was going for :P

Try replacing the find with this
	
foreach (
$string as $k => $char)
	
{
	
	
if (
$char == '@' && (!isset($string[$k 1]) || $string[$k 1] == ' '))


That fixed it...thank you so much for helping me with this. It actually may be something you want to permanently want to change in the mod.

Dragooon

Quote from: Squash on May 31, 2014, 01:50:01 AM
Quote from: Dragooon on May 31, 2014, 01:40:36 AM
Oh I did opposite of what I was going for :P

Try replacing the find with this
	
foreach (
$string as $k => $char)
	
{
	
	
if (
$char == '@' && (!isset($string[$k 1]) || $string[$k 1] == ' '))


That fixed it...thank you so much for helping me with this. It actually may be something you want to permanently want to change in the mod.
Yeah I'll see if I can implement a better fix

vkmaxx

Nice work, I have small form so I wasn't aware of the problem...

daigiatyhon

hi Dragooon, thanks for this mod. Can this Mod send message to Inbox? Now it notify to Profile/Mentions and Mentions notice is not show when user login then him maybe dont know when him was tagged.

iorkara

Hello Dragooon,

I've been using this Mod for a while now and I just want to say thank you.

I have run into an issue, actually one or two of my users. They have reported that nothing works when they type @ symbol followed by a letter.

They've reported:
Using Firefox version: 29.0.1

On my end:
SMF: 2.0.7
@mentions: 1.1.2

I have tested the Mod using Firefox 29.0.1 on my end and it works flawless.

I'm unsure why some of my users are having a problem.

Any help is very much appreciated.

Dragooon

Define nothing works? They can't post or they can't mention?

iorkara

Quote from: Dragooon on June 05, 2014, 07:11:36 AM
Define nothing works? They can't post or they can't mention?

Ah! My bad. I meant to say. They cannot mention.

4LP3RUZ1

Good mod, I like it.

I'll be waiting for UTF8 and space functionality, currently it doesn't pick up most of my member names
Frozen frogs are back :(

Dragooon

Quote from: 4LP3RUZ1 on June 06, 2014, 04:23:27 AM
Good mod, I like it.

I'll be waiting for UTF8 and space functionality, currently it doesn't pick up most of my member names
Uhm...it's supposed to work with UTF-8 and spaces, what doesn't work?

4LP3RUZ1

For example for a username starting with "Hüseyin"

if I enter the "ü" it wont work

Also another problem,
My usernames are formatted like this:

"Name Surname (userid)"

So if there are like 500 members with names "Alper" it only displays some of them, and then when I enter the space to go to the surname, it wont work again.
Frozen frogs are back :(

Dragooon

If you simply type @Hüseyin, does it create the mention? It might not show the suggestions but if you type the full name it should mention, same with Name Surname (userid), try mentioning them even if it doesn't show suggestions.

4LP3RUZ1

Ok i tried it and it works, so my problem is with the suggestions.

Because of my username policy it is very difficult for anyone to use it without suggestions though because it means you have to memorize userids :)
Frozen frogs are back :(

Dragooon

Hm, but they do remember surnames right? So allowing suggestions to incorporate spaces should do the trick?

4LP3RUZ1

+ UTF8 characters, yes

suggestions disappear when a UTF8 character is entered
Frozen frogs are back :(

Dragooon

Okay, this is lightly tested (and that too in 2.1 :P). Open Themes/default/mentions.js, replace the entire file with

/**
* Javascript interface for active suggestions while posting
*
* @author ******iz Garg <[email protected]>
* @copyright 2014 ******iz Garg
* @license Simplified BSD (2-Clause) License
*/

var mentionInit = function()
{
    var fails = [];

    var config = {
        at: '@',
        data: [],
        show_the_at: true,
        limit: 10,
        callbacks: {
            matcher: function(flag, subtext, should_start_with_space) {
                var match = '', started = false;
                var string = subtext.split('');
                for (var i = 0; i < string.length; i++)
                {
                    if (string[i] == flag && (!should_start_with_space || i == 0 || /[\s\n]/gi.test(string[i - 1])))
                    {
                        started = true;
                        match = '';
                    }
                    else if (started)
                        match = match + string[i];
                }

                if (match.length > 0)
                    return match;

                return null;
            },
            remote_filter: function (query, callback) {
                if (typeof query == 'undefined' || query.length < 2 || query.length > 60)
                    return;

                for (i in fails)
                    if (query.substr(0, fails[i].length) == fails[i])
                        return;

                $.ajax({
                    url: smf_scripturl + '?action=suggest;' + smf_sessvar + '=' + smf_sessid + ';xml',
                    method: 'GET',
                    data: {
                        search: query,
                        suggest_type: 'member'
                    },
                    success: function (data) {
                        var members = $(data).find('smf > items > item');
                        if (members.length == 0)
                            fails[fails.length] = query;

                        var callbackArray = [];
                        $.each(members, function (index, item) {
                            callbackArray[callbackArray.length] = {
                                name: $(item).text()
                            };
                        });

                        callback(callbackArray);
                    }
                });
            }
        }
    };

    if (typeof $.fn.atwho == 'undefined' && typeof jQuery.fn.atwho != 'undefined')
    {
        var iframe = jQuery('#html_message');

        if (typeof iframe[0] != 'undefined')
            jQuery(iframe[0].contentDocument.body).atwho(config);
        jQuery('textarea[name=message]').atwho(config);
    }
    else
    {
        var iframe = $('#html_message');
        if (typeof iframe[0] != 'undefined')
            $(iframe[0].contentDocument.body).atwho(config);
        $('textarea[name=message]').atwho(config);
    }
};

var atWhoElement = document.createElement('script');
atWhoElement.src = atwho_url;
atWhoElement.type = 'text/javascript';
atWhoElement.onload = mentionInit;

if (typeof $ == 'undefined' || (parseInt($.fn.jquery.substr(0, 1)) == 1 && parseInt($.fn.jquery.substr(2, 3)) < 8) || jQuery.fn.jquery != $.fn.jquery)
{
    var scriptElement = document.createElement('script');
    scriptElement.src = jquery_url;
    scriptElement.type = 'text/javascript';

    scriptElement.onload = function () {
        document.body.appendChild(atWhoElement);
    };

    document.body.appendChild(scriptElement);
}
else
    document.body.appendChild(atWhoElement);


Does it work better?

Adrek

Quote from: phantomm on May 25, 2014, 02:52:36 PM
I have small problem with one username.

It contains  <")))/
Username <")))/ and mod doesn't recognize it as username. I'm using version 1.1.2, and it worked fine on 1.0.
Github version doesn't fix it.
I can add that suggestions work with this username, but mentions do not.
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Dragooon

Quote from: phantomm on June 06, 2014, 08:38:48 AM
Quote from: phantomm on May 25, 2014, 02:52:36 PM
I have small problem with one username.

It contains  <")))/
Username <")))/ and mod doesn't recognize it as username. I'm using version 1.1.2, and it worked fine on 1.0.
Github version doesn't fix it.
I can add that suggestions work with this username, but mentions do not.
So...you cannot mention but it shows up in the popup while posting?

Adrek

Yes, username is not linked, but can be selected from dropdown suggestion list
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Dragooon

I think that's fantastic :P

Advertisement: