?
Solved

Wikipedia type linked list and content.

Posted on 2010-11-18
5
Medium Priority
?
463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 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