Solved

Wikipedia type linked list and content.

Posted on 2010-11-18
5
455 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 30

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 500 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 30

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 30

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 30

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now