?
Solved

Wikipedia type linked list and content.

Posted on 2010-11-18
5
Medium Priority
?
467 Views
Last Modified: 2012-06-27
Hello All;

I have asked this question in the past, but never got what I needed, so this time I am going to try my best to describe it better in hopes that someone will be able to help/assist in making this work.

OK.
I know we are all familar with Wikipedia.
I am one of the authors on the site, and the thing that I need to be able to do in my project is:

When you type in

== Main Information ==
This is some information here for the Main

=== This is sub Information ===
This is the sub of information here.

== Another set ==
This starts another set of information here

=== Another Sub set ===
This ends it for now.

OK.

When this is generated, it will perform the following (View code view below for source)
As you can see, it generates the linked list and then header information below.

Could someone shed some light on making this?


The script here
http://openwiki.com
Does what I need, but the code is so scattered and not well documented that it is a nightmare to try to figure out what will go with what in order to make it work without all the other stuff that is envolved in the wiki scripts.
And before you ask, yes, I tried to contact the author and well, the email was returned, so it no longer belongs to the person, so I have no idea on how to contact them now.

Any idea's on this would be great, as this is something that I would really like to be able to add to an existing site (Remake).

Carrzkiss

Screenshots of from Openwiki, that I have running on my system here.
This shows what it looks like and how it runs as an output.
This is the code view of openwikiThis is the output of openwiki
<li><a href="#h1">Main Information</a></li>
<li><a href="#h2">This is sub Information</a></li>
<li><a href="#h3">Another set</a></li>
<li><a href="#h4">Another Sub set</a></li>

<a name="h1"></a><h2>Main Information</h2>
This is some information here for the Main
<a name="h2"></a><h3>This is sub Information</h3>
This is the sub of information here.
<a name="h3"></a><h2>Another set</h2>
This starts another set of information here
<a name="h4"></a><h3>Another Sub set</h3>
This ends it for now.

Open in new window

0
Comment
Question by:Wayne Barron
  • 4
5 Comments
 
LVL 31

Author Comment

by:Wayne Barron
ID: 34167668
To add a little more information to this.

The information is passed through a Textarea
So <textarea name="CodeView"></textarea>

That is passed to the processing page, and then the output should be similar to what is listed above.

Thanks all;
Carrzkiss
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 34210040
The attached code should help you achieve your goal. I am displaying the result in a textarea, but you can simply modify the function to return a string and do whatever you want with it (perhaps instead of targetting a textarea - like I did - you can add a hidden field and update that hidden field. Thus on the server you should have the result exactly as you want). I also trigger the function via onclick of the button, but you can add an onchange event handler to the textarea.

On another note, if you want to do this in ASP, you can simply include the function below in a <script runat="server" language="javascript">...</script> construct and then pass it your input string and have the function return the output you want as a string and do whatever you want with the output.

Regards,
Hielo
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
function process(str){

	var r=str.match(/(\S.+)/g);
	var list=[];
	var data=[];
	for( var i=0,limit=r.length; i < limit; ++i)
	{
		if( '=== '==r[i].substring(0,4) )
		{
			var text=r[i].substring(4, r[i].length-5);
			var size=list.length+1;
			list[list.length]='<a href="#h'+size+'">'+text+'</a>';
			data[data.length] = '<a name="h'+size+'"></a><h3>'+text+'</h3>'
		}
		else if( '== '==r[i].substring(0,3) )
		{
			var text=r[i].substring(3, r[i].length-4);
			var size=list.length+1;
			list[list.length]='<a href="#h'+size+'">'+text+'</a>';
			data[data.length]='<a name="h'+size+'"></a><h2>'+text+'</h2>';
		}
		else
		{
			data[data.length]='<p>'+r[i]+'</p>';
		}
	}
	document.getElementById('result').value='<ul><li>'+list.join("</li>\n<li>") + '</li></ul>\n';
	document.getElementById('result').value+=data.join("\n");
}
//-->
</script>

</head>
<body>
<form >
<div><input type='button' onclick='process( this.form.data.value)' value='Process'/></div>
<textarea id='data' name='data' rows="12" cols="80">
== Main Information ==
This is some information here for the Main

=== This is sub Information ===
This is the sub of information here.

== Another set ==
This starts another set of information here

=== Another Sub set ===
This ends it for now.
</textarea>
<textarea id='result' name='result' rows="12" cols="80">
</textarea>
</form>

</body>
</html>

Open in new window

0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 34211462
Hello hielo
Hope that you are doing well, and Happy Thanksgiving to you and yours as well.

I am going to be doing this with ASP Classic, so I am not sure if the
script runat="server" applies does it?
I have never used it, so I am not really sure about it.

As long as I am able to insert this into a database, I am happy with however it will work to achieve what I need done.

I just had to reinstall my system and am getting everything setup now.
I will run a test drive on this code once I have my site in IIS setup.

-------
I just tested this and it works very well.
Just need to work it into a database insert statement and it will be good to go.

Thank you so much for this and your time, you have provided me with something very special this Thanksgiving Morning.

You Rock Hielo
Carrzkiss
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 34705779
Hello Hielo

I am now getting to where I can start on this project, while waiting on information on another project.

I am a little confused on a few things with your provided code, and wonder if you could assist me with a few issues or alternative coding to make this work as it is needed.

#1:
I need to be able to insert this into the database.

==Main Information==
This is some information here for the Main.

#2:
When it is read out to the live page, it will be converted over to:

<li><a href="#h1">Main Information</a></li>

<a name="h1"></a><h2>Main Information</h2>
This is some information here for the Main

---------
(Hope that makes since)
Basically what I need is the following:
-------------------------------------------------
Insert (Into the database)
==tags==

When the page is run, it will be converted to html tags, as you have provided in the javascript coding.

Then when you are updating, it is the WIKI tags that are being updated.
The only time that it is seen as HTML tags is when you view the live page.

-----------
Do you think that you could give me some pointers to make your provided code do what I am needing?

Thank You Hielo.
Carrzkiss
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 34753965
Any idea's on this Hielo?
Or do I need to open another Thread?

Please let me know, as I would really love to start on this project, it is way over-due.

Thank You
Carrzkiss
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question