The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Turn of auto hyperlink in posts

4 posters

Go down

Solved Turn of auto hyperlink in posts

Post by Zanzazaar November 5th 2021, 12:08 am

Hi!
Is it possible to turn of auto hyperlink in posts? I need to use url in posts by JS but when it is turned automaticly into hyperlink it breaks my script. Turning it automaticly is not needed for me.


Last edited by Zanzazaar on November 9th 2021, 3:40 pm; edited 1 time in total
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Ape November 5th 2021, 7:29 pm

I have looked over the ACP and I don't think it can be turned off unless @pedxz knows of away to stop it using javaScript


staff posts - Turn of auto hyperlink in posts Left1212staff posts - Turn of auto hyperlink in posts Center11staff posts - Turn of auto hyperlink in posts Right112
staff posts - Turn of auto hyperlink in posts Ape_b110
staff posts - Turn of auto hyperlink in posts Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19150
Reputation : 1994
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by tikky November 7th 2021, 10:43 am

Hello @Zanzazaar,

breaks my script
Can you share this script?
tikky
tikky
Forumember

Posts : 898
Reputation : 157
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 8th 2021, 5:06 pm

@pedxz

Code:
$(function() {

 

  $('div.postbody div').each(function () {

    if ($(this).text().indexOf('[imie]') != -1) $(this).html($(this).html().replace(/\[imie\](.+?)\[\/imie\]/gi, '<div class="mainSquare"><img src="https://66.media.tumblr.com/22bd78b829ff310508e1647b7e424d0b/tumblr_ow2jhkQQ5t1sy4y3mo6_1280.png" class="headerSquare"><div class="nameSquare">$1 </div>'));


   
    if ($(this).text().indexOf('[portret]') != -1) $(this).html($(this).html().replace(/\[portret\](.+?)\[\/portret\]/gi, '<img src="$1" class="iconSquare"></img><div class="kp3w">'));
    if ($(this).text().indexOf('[cecha]') != -1) $(this).html($(this).html().replace(/\[cecha\](.+?)\[\/cecha\]/gi, '<div class="kp3">$1 </div>'));
    if ($(this).text().indexOf('[opis]') != -1) $(this).html($(this).html().replace(/\[opis\](.+?)\[\/opis\]/gi, '</div><div class="kp4"><div class="kp4t">Opis</div><div class="kp4d">$1 </div></div></div>'));

 
  });
 
 


});

It is about that part

Code:
    if ($(this).text().indexOf('[portret]') != -1) $(this).html($(this).html().replace(/\[portret\](.+?)\[\/portret\]/gi, '<img src="$1" class="iconSquare"></img><div class="kp3w">'));
It works if user is logged of, but after log in, links in posts are automaticaly changed into hyperlinks, due to that I cannot change that part with that JS.


Last edited by Zanzazaar on November 8th 2021, 10:13 pm; edited 1 time in total
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 8th 2021, 9:07 pm

SLGray wrote:Check this:  AP > General > Messages & Emails > Configuration
Messages Section
Allow Embed Links via [EMBED] :
Already tried this one, I turned it off and it didn't helped...
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by SLGray November 8th 2021, 9:11 pm

Could you send me a test account and a link to a post that has this issue?


staff posts - Turn of auto hyperlink in posts Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51505
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 8th 2021, 10:14 pm

K, it is on PW Smile
Little change in a code, I was checking something in the meantime, one symbol was wrong
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by SLGray November 8th 2021, 10:39 pm

Your PM has  been received  with thanks.
Please read our forum rules:  ESF General Rules
I was going to say I do not see any issue.

Is this solved now?


staff posts - Turn of auto hyperlink in posts Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51505
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 8th 2021, 11:07 pm

Did you tried as logged user? On what browser? It does only broke for logged users. For guests it works as intended.
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Ape November 9th 2021, 12:17 am

The reason why it works when your not logged in is because All links on our forums are not clickable when not logged in but they are when your logged in.


staff posts - Turn of auto hyperlink in posts Left1212staff posts - Turn of auto hyperlink in posts Center11staff posts - Turn of auto hyperlink in posts Right112
staff posts - Turn of auto hyperlink in posts Ape_b110
staff posts - Turn of auto hyperlink in posts Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19150
Reputation : 1994
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 9th 2021, 12:24 am

And thats why I want to make them non clickable also for logged users Smile It is not needed as there is bbcode url
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by SLGray November 9th 2021, 4:23 am

I was using Firefox on a PC.  I was logged in using the test account you gave me,


staff posts - Turn of auto hyperlink in posts Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51505
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 9th 2021, 6:21 am

BTW, sorry for edgy content with that image, it in for an example Very Happy
No repro (logged of on firefox, should always look like that):
https://imgur.com/9ihFtIn
Repro (logged in on firefox):
https://imgur.com/ZkFK04o

There should be "image in the circle" and shouldn't aby part of html visible. This issue is visible for me on edge, opera gx, firefox on two devices and again for one more user that was trying to help me.
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by tikky November 9th 2021, 1:11 pm

Zanzazaar wrote:It works if user is logged of, but after log in, links in posts are automaticaly changed into hyperlinks, due to that I cannot change that part with that JS.
Change your script to:
Code:
(function($) {
    'use strict';

    $(function() {

        $([
            '.post-entry > div',
            '.content > div',
            '#preview .postbody > div',
        ].join(', ')).each(function() {
            var $this = $(this);

            $this.html($this.html().replace(
                /\[imie\]([^\]]+)\[\/imie\]/gi,
                function(text, imie) {
                    return $('<div>', {
                        'html': [
                            '<img src="https://66.media.tumblr.com/22bd78b829ff310508e1647b7e424d0b/tumblr_ow2jhkQQ5t1sy4y3mo6_1280.png" class="headerSquare" loading="lazy">',
                            '<div class="nameSquare">' + imie + '</div>'
                        ].join('\n'),
                        'class': 'mainSquare',
                    }).prop('outerHTML');
                }
            ));

            $this.html($this.html().replace(
                /\[portret\]([^\[]+)\[\/portret\]/g,
                function(text, portret) {
                    return $('<img>', {
                        'src': location.protocol + '//' + portret,
                        'class': 'iconSquare',
                        'loading': 'lazy'
                    }).prop('outerHTML');
                }
            ));

            $this.html($this.html().replace(
                /\[cecha\]([^\]]+)\[\/cecha\]/gi,
                function(text, cecha) {
                    return $('<div>', {
                        'class': 'kp3',
                        'text': cecha
                    }).prop('outerHTML');
                }
            ));

            $this.html($this.html().replace(
                /\[opis\]([^\]]+)\[\/opis\]/gi,
                function(text, opis) {
                    return $('<div>', {
                        'class': 'kp4',
                        'html': [
                            '<div class="kp4t">Opis</div>',
                            '<div class="kp4d">' + opis + '</div>'
                        ].join('\n')
                    }).prop('outerHTML');
                }
            ));
 
        });


    });
})(jQuery);
When using the tag
Code:
[portret]
use the link without the
Code:
http
Code:
[portret]i.servimg.com/u/f62/09/00/43/96/xppj910.png[/portret]
Because Forumotion automatically links everything that uses http Very Happy Or in your code replace this:
Code:
            if ($(this).text().indexOf('[portret]') != -1) $(this).html($(this).html().replace(/\[portret\](.+?)\[\/portret\]/gi, '<img src="$1" class="iconSquare"></img><div class="kp3w">'));
to
Code:
 if ($(this).text().indexOf('[portret]') != -1) $(this).html($(this).html().replace(/\[portret\]([^\[]+)\[\/portret\]/g, '<img src="http://$1" class="iconSquare" loading="lazy" /><div class="kp3w">'));
But you also have to do the explanation above and don't use the protocol in the url
tikky
tikky
Forumember

Posts : 898
Reputation : 157
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Zanzazaar November 9th 2021, 3:16 pm

Second solution is one of two work arounds that I was thinking about. Secondary is to use bbcode img and put it choosen div by something like those codes and use css by targeting only images in choosen div.

I think I will stay with my current code as it is not only for me and that looks shorter , but if I may ask, is ther any advantage of putting funkction in second part of regex?
Zanzazaar
Zanzazaar
New Member

Male Posts : 10
Reputation : 1
Language : Polski

https://hashira.forumpolish.com

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by tikky November 9th 2021, 3:26 pm

Zanzazaar wrote:I think I will stay with my current code as it is not only for me and that looks shorter , but if I may ask, is ther any advantage of putting funkction in second part of regex?
The only difference in codes is that I don't see the need for:
Code:
  if ($(this).text().indexOf('[portret]') != -1)
About the function it's just more correct and gives more options
tikky
tikky
Forumember

Posts : 898
Reputation : 157
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Turn of auto hyperlink in posts

Post by Ape November 9th 2021, 3:56 pm

Thank you @pedxz for your help Smile
Problem solved & topic archived.
Please read our forum rules: ESF General Rules


staff posts - Turn of auto hyperlink in posts Left1212staff posts - Turn of auto hyperlink in posts Center11staff posts - Turn of auto hyperlink in posts Right112
staff posts - Turn of auto hyperlink in posts Ape_b110
staff posts - Turn of auto hyperlink in posts Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19150
Reputation : 1994
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

tikky likes this post

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum