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)
 using bookmarks
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 09 July 2005 :  09:03:26  Show Profile  Visit MarcelG's Homepage
I've implemented bookmarks within the forumcode, and it all seems to work very well.
I added this piece of code to the extratags function in inc_func_common.asp:
fString = doCode(fString, "[bookmark]", "[/bookmark]", "<a name=""", """></A>")

Example: http://www.oxle.com/article.asp?art=613#sigs (jumping to the bookmark sigs in this article)
You can easily add a bookmark by typing this:
[bookmark]bookmarktext[/bookmark], and you can then link to that bookmark by means of adding #bookmarktext to the end of the url.
That's all.

However...I notice that when I try to link to a bookmark within a topic, the URL still opens in a new window. So, when I make a link to for instance [url="#test"]test[/url], the link opens in a new window, instead of 'jumping' to the bookmark.

You can see that behaviour in the link provided above.

I think I know what's causing it ; this line in inc_func_common.asp, in the function ReplaceURLs(ByVal strToFormat)
rc1Tag = """ target=""_blank"">"

Perhaps someone has an idea to easily circumvent this ?

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 09 July 2005 09:05:25

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 July 2005 :  07:39:35  Show Profile  Visit MarcelG's Homepage
.... bump ?

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

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 July 2005 :  08:24:11  Show Profile
This may be of help to get you started, Marcel - my function was heavily modified before I made the changes in that topic so I'd advise against a simple copy and paste. If you only want those links linking to named anchors on the same page to open in the same window as opposed to all internal links, you could modify it further to check that the first character of the URI is #.

Really must get 'round to packaging that up as a mod, along with everything else I've promised over the past few months!


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 - 11 July 2005 :  09:29:40  Show Profile  Visit MarcelG's Homepage
Okay, it works as a charm, but as you already said, it now opens all 'internal' links in the same window.
So, I tried some more to read the code, and tried to adjust it to my needs....
I failed miserably, but with the hints from your function I decided to use change the old function instead.
And...rapapaaaa ; it's done!
I've commented my changes in red, just for clarity.
Function ReplaceURLs(ByVal strToFormat)
	Dim oTag, c1Tag, oTag2, c2Tag
	Dim roTag, rc1Tag, rc12Tag, rc2Tag
	Dim oTagPos, c1TagPos, oTagPos2, c1TagPos2
	Dim Counter
	Dim strArray, strArray2
	Dim strFirstPart, strSecondPart

	oTag = "[url="""
	c1Tag = """]"
	oTag2 = "[url]"
	c2Tag = "[/url]"

	roTag = "<a href="""
	rc1Tag = """ target=""_blank"">"
	rc12Tag = """>"
	rc2Tag = "</a>"

	oTagPos = InStr(1, strToFormat, oTag, 1) 'Position of opening tag
	c1TagPos = InStr(1, strToFormat, c1Tag, 1) 'Position of closing tag

	'if opening tag and closing tag is found...
	If (oTagpos > 0) And (c1TagPos > 0) Then
		'Split string at the opening tag
		strArray = Split(strToFormat, oTag, -1, 1)
		
		'Loop through array
		For Counter = 0 To UBound(strArray)
			'if the closing tag is found in the string then...
			If (InStr(1, strArray(Counter), c1Tag, 1) > 0) Then
				'split string at the closing tag...
				strArray2 = Split(strArray(Counter), c1Tag, -1, 1)

				strArray2(0) = replace(strArray2(0), """", " ") ' ## filter out "
				strArray2(0) = replace(strArray2(0), ";", " ", 1, -1, 1) ' ## filter out ;
				strArray2(0) = replace(strArray2(0), "+", " ", 1, -1, 1) ' ## filter out +
				strArray2(0) = replace(strArray2(0), "(", " ", 1, -1, 1) ' ## filter out (
				strArray2(0) = replace(strArray2(0), ")", " ", 1, -1, 1) ' ## filter out )
				strArray2(0) = replace(strArray2(0), "*", " ", 1, -1, 1) ' ## filter out *
				strArray2(0) = replace(strArray2(0), "'", " ", 1, -1, 1) ' ## filter out '
				strArray2(0) = replace(strArray2(0), ">", " ", 1, -1, 1) ' ## filter out >
				strArray2(0) = replace(strArray2(0), "<", " ", 1, -1, 1) ' ## filter out <
				strArray2(0) = replace(strArray2(0), vbTab, " ", 1, -1, 1) ' ## filter out Tabs
				strArray2(0) = replace(strArray2(0), "view-source", " ", 1, -1, 1) ' ## filter out view-source
				strArray2(0) = replace(strArray2(0), "javascript", " ", 1, -1, 1) ' ## filter out javascript
				strArray2(0) = replace(strArray2(0), "jscript", " ", 1, -1, 1) ' ## filter out jscript
				strArray2(0) = replace(strArray2(0), "vbscript", " ", 1, -1, 1) ' ## filter out vbscript

				'if the closing url tag is found in the string and
				'[URL] is not found in the string then...
				If InStr(1, strArray2(1), c2Tag, 1) And _
					Not InStr(1, UCase(strArray2(1)), "[URL]", 1) Then

					strFirstPart = Left(strArray2(1), InStr(1, strArray2(1), c2Tag, 1)-1)
					strSecondPart = Right(strArray2(1), (Len(strArray2(1)) - Instr(1, strArray2(1), c2Tag,1) - len(c2Tag)+1))

					If strFirstPart <> "" Then
						If UCase(Left(strFirstPart, 5)) = "" Then
							ReplaceURLs = ReplaceURLs & "<a href=""" & strArray2(0) & """ target=""_blank"">" & strFirstPart & "</a>" & strSecondPart
						ElseIf UCase(Left(strArray2(0), 7)) = "http://" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 1)) = "#" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc12Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 8)) = "https://" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 4)) = "WWW." Then
							ReplaceURLs = ReplaceURLs & roTag & "http://" & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 7)) = "MAILTO:" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 6)) = "ftp://" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 7)) = "ED2K://" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf InStr(strArray2(0), "@") > 0 Then
							ReplaceURLs = ReplaceURLs & roTag & "mailto:" & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 6)) = "file:///" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						Else
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						End If
					Else
						If UCase(Left(strArray2(0), 7)) = "http://" Then
							ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 1) & strSecondPart
						ElseIf UCase(Left(strArray2(0), 8)) = "https://" Then
							ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 2) & strSecondPart
						ElseIf UCase(Left(strArray2(0), 4)) = "WWW." Then
							ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 3) & strSecondPart
						ElseIf UCase(Left(strArray2(0), 7)) = "MAILTO:" Then
							ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 4) & strSecondPart
						ElseIf UCase(Left(strArray2(0), 6)) = "ftp://" Then
							ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 5) & strSecondPart
						ElseIf UCase(Left(strArray2(0), 7)) = "ED2K://" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
						ElseIf InStr(strArray2(0), "@") > 0 Then
							ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 4) & strSecondPart
						ElseIf UCase(Left(strArray2(0), 6)) = "file:///" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strSecondPart
						ElseIf UCase(Left(strArray2(0), 1)) = "#" Then
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc12Tag & strArray2(0) & rc2Tag & strSecondPart
						Else
							ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strSecondPart
						End If
					End If
				Else
					ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strArray2(1)
				End If
			Else
				ReplaceURLs = ReplaceURLs & strArray(Counter)
			End If
		Next
	Else
		ReplaceURLs = strToFormat
	End If
	
	oTagPos2 = InStr(1, ReplaceURLs, oTag2, 1)
	c1TagPos2 = InStr(1, ReplaceURLs, c2Tag, 1)

	'if opening tag and closing tag is found then...
	If (oTagpos2 > 0) And (c1TagPos2 > 0) Then
		'split string at opening tag
		strArray = Split(ReplaceURLs, oTag2, -1, 1)

		ReplaceURLs = ""
		For Counter = 0 To Ubound(strArray)
			'if closing url tag is found in string then...
			If InStr(1, strArray(Counter), c2Tag, 1) > 0 Then
				'split string at closing url tag
				strArray2 = Split(strArray(Counter), c2Tag, -1, 1)
				
				strArray2(0) = replace(strArray2(0), """", " ") ' ## filter out "
				strArray2(0) = replace(strArray2(0), ";", " ", 1, -1, 1) ' ## filter out ;
				strArray2(0) = replace(strArray2(0), "+", " ", 1, -1, 1) ' ## filter out +
				strArray2(0) = replace(strArray2(0), "(", " ", 1, -1, 1) ' ## filter out (
				strArray2(0) = replace(strArray2(0), ")", " ", 1, -1, 1) ' ## filter out )
				strArray2(0) = replace(strArray2(0), "*", " ", 1, -1, 1) ' ## filter out *
				strArray2(0) = replace(strArray2(0), "'", " ", 1, -1, 1) ' ## filter out '
				strArray2(0) = replace(strArray2(0), ">", " ", 1, -1, 1) ' ## filter out >
				strArray2(0) = replace(strArray2(0), "<", " ", 1, -1, 1) ' ## filter out <
				strArray2(0) = replace(strArray2(0), vbTab, " ", 1, -1, 1) ' ## filter out Tabs
				strArray2(0) = replace(strArray2(0), "view-source", " ", 1, -1, 1) ' ## filter out view-source
				strArray2(0) = replace(strArray2(0), "javascript", " ", 1, -1, 1) ' ## filter out javascript
				strArray2(0) = replace(strArray2(0), "jscript", " ", 1, -1, 1) ' ## filter out jscript
				strArray2(0) = replace(strArray2(0), "vbscript", " ", 1, -1, 1) ' ## filter out vbscript

				If UCase(Left(strArray2(0), 7)) = "http://" Then
					ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 1) & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 8)) = "https://" Then
					ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 2) & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 4)) = "WWW." Then
					ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 3) & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 7)) = "MAILTO:" Then
					ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 1)) = "#:" Then
					ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc12Tag & strArray2(0) & rc2Tag & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 6)) = "ftp://" Then
					ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 5) & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 7)) = "ED2K://" Then
					ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strArray2(1)
				ElseIf InStr(strArray2(0), "@") > 0 Then
					ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 4) & strArray2(1)
				ElseIf UCase(Left(strArray2(0), 6)) = "file:///" Then
					ReplaceURLs = ReplaceURLs & edit_hrefs(strArray2(0), 7) & strArray2(1)
				Else
					ReplaceURLs = ReplaceURLs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strArray2(1)
				End If
			Else
				ReplaceURLs = ReplaceURLs & strArray(Counter)
			End If
		Next
	End If
End Function

I'm not sure if this is the most correct way to do it, but it works for me! I think the first check for # is not necessary....but I'm not sure.

Anyway, thanks a bunch for getting me on track!

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 11 July 2005 09:32:55
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 July 2005 :  09:34:16  Show Profile
You're welcome, man Nicely done. And you say you're not a programmer? Pfft!


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 - 11 July 2005 :  09:45:34  Show Profile  Visit MarcelG's Homepage
Well, I really am not...I just use the famous 'trial & error' method, and thanks to Crimson Editors 'Unlimited Undo's' I can pull it off most of the times
I just try to see which function does what, and reuse it after slight modification.
I'm still wondering why I had to put the check for the # as first char of the URL in there three times... I honoustly have no clue.

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

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 July 2005 :  10:29:26  Show Profile
quote:
Originally posted by marcelgoertz
I just use the famous 'trial & error' method
That's the only method!

The reason for the three different edits is becuase one takes care of [url]http://forum.snitz.com/[/url], another converts [url="http://forum.snitz.com/"]Snitz[/url] and the last one traps thos URIs that don't use the URL tag and passes them to the edit_hrefs function. At least, as far as I can tell - that function can be a wee bit confusing at times!


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.”

Edited by - Shaggy on 11 July 2005 10:30:27
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 July 2005 :  14:01:14  Show Profile  Visit MarcelG's Homepage
ah, ok! Thanks for clearing that up. Now you mention it, that makes sense indeed

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 11 July 2005 14:02:30
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000 Version 3.4.07