Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Clipped URL's?
 New Topic  Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 6

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 07 November 2005 :  10:37:36  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
Thanks alot for trying!
It's still the same, "..." is added and making the link longer than before =)
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 07 November 2005 :  10:54:16  Show Profile  Visit MarcelG's Homepage  Reply with Quote
Shaggy, I think I've got it! (almost)

function edit_hrefs(sURL, iType) {
	sOutput = new String(sURL);
	iMLength = intMaxLinkLength
	iHLength = iMLength/2;
	iLLength = parseInt(sOutput.length);
	if(iLLength>=iMLength&&iType!=4)sLink=sOutput.substring(0,iHLength)+"..."+sOutput.substring((iLLength),(iLLength-(iHLength+3)));
	else sLink = sOutput;

	if (iType == 1) {
		sOutput = sOutput.replace(/\b(http\:\/\/[\w+\.]+[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
			"<a href=\"$1\" target=\"_blank\">"+sLink+"<\/a>");
	} else if (iType == 2) {
		sOutput = sOutput.replace(/\b(https\:\/\/[\w+\.]+[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
			"<a href=\"$1\" target=\"_blank\">"+sLink+"<\/a>");
	} else if (iType == 3) {
		sOutput = sOutput.replace(/\b(www\.[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
			"<a href=\"http://$1\" target=\"_blank\">"+sLink+"<\/a>");
	} else if (iType == 4) {
		sOutput = sOutput.replace(/\b([\w+\-\'\#\%\.\_\,\$\!\+\*]+@[\w+\.?\-\'\#\%\~\_\.\;\,\$\!\+\*]+\.[\w+\.?\-\'\#\%\~\_\.\;\,\$\!\+\*]+)/gi,
			"<a href=\"mailto\:$1\">$1<\/a>");
	} else if (iType == 5) {
		sOutput = sOutput.replace(/\b(ftp\:\/\/[\w+\.]+[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
			"<a href=\"$1\" target=\"_blank\">"+sLink+"<\/a>");
	} else if (iType == 6) {
		sOutput = sOutput.replace(/\b(file\:\/\/\/[\w+\:\/\\]+[\w+\/\w+\.\:\/\\\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
		  	"<a href=\"$1\" target=\"_blank\">"+sLink+"<\/a>");
	}

	return sOutput;
}

I changed the blue bold part.
It's not working entirely as suspected though.

I tried to post these links, with the value for intMaxLinkLength set to 25.
www.1.com
www.12.com
www.123.com
www.1234.com
www.12345.com
www.123456.com
www.1234567.com
www.12345678.com
www.123456789.com
www.1234567890.com
www.12345678901.com
www.123456789012.com
www.1234567890123.com
www.12345678901234.com
www.123456789012345.com
www.1234567890123456.com
www.12345678901234567.com
www.123456789012345678.com
www.1234567890123456789.com
www.12345678901234567890.com
They come out like this:
quote:
www.1.com

www.12.com

www.123.com

www.1234.com

www.12345.com

www.123456.com

www.1234567.com

www.12345678.com

www.123456789.com

www.1234567890.com

www.12345678...678901.com

www.12345678...789012.com

www.12345678...890123.com

www.12345678...901234.com

www.12345678...012345.com

www.12345678...123456.com

www.12345678...234567.com

www.12345678...345678.com

www.12345678...456789.com

www.12345678...901234567890.com
The links are pointing to the correct URL though, but it seems as if they're broken up, even though the link is shorter than 20 charachters.<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 07 November 2005 11:02:46
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 07 November 2005 :  11:02:25  Show Profile  Reply with Quote
*conflustered* If it works then great

But I don't see how that can work; the first argument in the substring function should be the first character you want to display. You've got iLLength in there which should, therefore, start your substring from the last character of the URI.

*still conflustered! *

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 07 November 2005 :  11:03:38  Show Profile  Visit MarcelG's Homepage  Reply with Quote
Err...I've updated my reply...<

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 07 November 2005 :  15:23:43  Show Profile  Visit MarcelG's Homepage  Reply with Quote
Shaggy,

there's something more wrong with this code, something I didn't expect.
Here's an example (made with screenshots)
The input:

The output:
<

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 07 November 2005 :  15:57:07  Show Profile  Visit MarcelG's Homepage  Reply with Quote
BTW ; just checked phpBB ; they don't clip the urls proof

BTW ; I think I found out what's not working with your script Shaggy ;
	sOutput = new String(sURL);
	iMLength = intMaxLinkLength;
	iHLength = iMLength/2;
	iLLength = parseInt(sOutput.length);
	if(iLLength>=iMLength&&iType!=4)sLink=sOutput.substring(0,iHLength)+"..."+sOutput.substring((iLLength-iHLength),iHLength);
	else sLink = sOutput;
sOutput is not just the links, but also all the text around/after/before it, I guess per line or so.
So, if you're going to say that sLink = sOutput if sOutput is shorter than let's say 40 chars, sLink not only is the original link, but also the text after it.

I've been looking for the similar functionality in phpBB, but I haven't found it there. Now trying to find out whether or not Invision Power Board has it....some reverse engineering is in place here. <

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 07 November 2005 16:22:46
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 07 November 2005 :  16:12:58  Show Profile  Visit AnonJr's Homepage  Reply with Quote
lol. Where to next? what about just trimming it down to the domain? or just add the elips after 25 charachters.

www.reallylongurl/bla/bla/bla.asp

www.reallylongurl/bla/bl...

and keep them pointing to the same url? It might not look as cool, but it would probably simplify things for the time being.<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 07 November 2005 :  16:26:31  Show Profile  Visit MarcelG's Homepage  Reply with Quote
anyone good with php ?
Found this one:
<?php
function n3y_url_shorten($url,$chr_limit = 30,$add = '...') {
   return preg_replace("!(http:/{2}[\w\.]{2,}[/\w\-\.\?\&\=\#]*)!e", "'<a href=\"\\1\" title=\"\\1\" target=\"_blank\">'.(strlen('\\1')>=$chr_limit ? substr('\\1',0,$chr_limit).'$add':'\\1').'</a>'", $url);
}
?>
<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 07 November 2005 16:27:59
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 08 November 2005 :  08:09:09  Show Profile  Reply with Quote
Are you sure about that, Marcel? To test it, try removing everything from the edit_hrefs function, except the two lines below:

sOutput = new String(sURL);
return sOutput;


<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 08 November 2005 :  09:01:30  Show Profile  Visit MarcelG's Homepage  Reply with Quote
I did that just now, and now there simply is no URL handling left. All the text is left intact, and www.1234567890.com is shown as www.1234567890.com

BTW ; vBulletin has the clipping function!
www.vbulletin.com/forum/showthread.php?p=1008045#post1008045" target="_blank">proof<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 08 November 2005 09:15:49
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 08 November 2005 :  09:04:56  Show Profile  Reply with Quote
Ay, that was just to test what was being passed through the sLink argument of the function, you can paste the rest of the code back in. Now that we know that it is just the URI that gets passed through, we can eliminate that as the cause of our problems.

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 08 November 2005 :  09:18:03  Show Profile  Visit MarcelG's Homepage  Reply with Quote
quote:
Originally posted by Shaggy

Ay, that was just to test what was being passed through the sLink argument of the function, you can paste the rest of the code back in. Now that we know that it is just the URI that gets passed through, we can eliminate that as the cause of our problems.
But why is the part 'dus' added to the slink value if the link is shorter than the max length? as you can see in the screenshot, it's inserted into slink and not in the $1 part....

I just found out that vBulletin has the functionality to cut off long urls, built in:
http://www.vbulletin.com/forum/showthread.php?p=1008045#post1008045

Anyone have access to the source, to reverse engineer it ? <

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 08 November 2005 09:40:31
Go to Top of Page

imweazel
Starting Member

49 Posts

Posted - 08 November 2005 :  10:36:15  Show Profile  Reply with Quote
quote:
Originally posted by Shaggy

Been looking and looking and looking at this and still can't see where it's tripping up. All I can suggest is that ye try replacing my edited edit_hrefs function with the following:
MarcelG removed this code to preserve readable formatting (sorry)
If that doesn't work then maybe we should try looking at acheiving this with Gary's RegExp based edit_hrefs function.





Try changing the line to:
if(iLLength>=iMLength&&iType!=4)sLink=sOutput.substring(0,iHLength)+"..."+sOutput.substring((iLLength-iHLength),iLLength);

I think you want the end of the substring to be iLLength instead of iHLength. I believe Marcel is correct that text after the URL is being included, so this is not a complete fix.<

Edited by - MarcelG on 09 November 2005 05:02:12
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 09 November 2005 :  03:24:38  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
Text after the link is underlined together with the link when mousover. The link still work though.
I'll try your code now imweazel =)
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 09 November 2005 :  03:32:36  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
Strange..
The link length is OK now (wohoo!)
but it's something weird if there is text after the link, se here:

what's in the topic:
http://www.gotlandrace.se/tabort/before.jpg
what's displayed:
http://www.gotlandrace.se/tabort/after.jpg
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page
Page: of 6 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000 Version 3.4.07