Click to See Complete Forum and Search --> : Text file to HTML


smdavis
08-29-2003, 12:37 AM
I'm working on a website which will contain a kind of "gig guide" (info about events going on around town) that we want to be updated dynamically. There is a newsletter editor in charge of getting updated gig information, but he has no experience in HTML or webpage creation. What we want is for him to be able to upload a text file (eg: gigguide.txt) with the updated information in plain text format (probably with the necessary delimiters), and then the webpage would use javascript to read this file, convert it into HTML and display it appropriately. This way, our newsletter editor doesn't need to go anywhere near HTML or other coding. He would just have to prepare this text file in the format we show him, and upload that to the server. In the webpage itself, the gig guide would be text contained in the cell of a table. This wouldn't just be picking up a chunk of text from a text file and dumping it into the webpage though. It would need to be properly formated with the correct spacing. An example of the type of entries might be something like this:

Saturday, 3pm
Sinatra @ The Underground
www.somewhere/sinatra.html

Sunday, 8pm
Kelly @ Lux
www.somewhere/kelly.html


Any ideas on how this can be done?

Fang
08-29-2003, 01:23 AM
Best done using a server side language (PHP, Perl etc.),
but there are various methods using javascript or activeX (IE only)

jalarie
08-29-2003, 10:24 AM
Add a line to your web page that pulles in a .js file:

&nbsp;<script type="text/javascript" src="datastuf.js"></script>

Create the data file and add lines:

&nbsp;Includes=new&nbsp;Array(
&nbsp;&nbsp;'This&nbsp;is&nbsp;the&nbsp;first&nbsp;line.&nbsp;&nbsp;',
&nbsp;&nbsp;'Line&nbsp;number&nbsp;2.&nbsp;&nbsp;',
&nbsp;&nbsp;'',
&nbsp;&nbsp;'Line&nbsp;3&nbsp;comes&nbsp;after&nbsp;a&nbsp;blank.',
&nbsp;&nbsp;'Final&nbsp;line&nbsp;has&nbsp;no&nbsp;comma.'
&nbsp;);

Add a script to print that information:

&nbsp;<script&nbsp;type="text/javascript">
&nbsp;&nbsp;<!--&nbsp;Hide&nbsp;this&nbsp;code&nbsp;from&nbsp;non-JavaScript&nbsp;browsers
&nbsp;&nbsp;&nbsp;for&nbsp;(ix1=0;&nbsp;ix1<Includes.length;&nbsp;ix1++)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;Include=Includes[ix1];
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Include&nbsp;==&nbsp;'')&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write('<br><br>\n');
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;document.write(Include+'\n');
&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;//&nbsp;End&nbsp;hiding&nbsp;-->
&nbsp;</script>

Now your update person only needs to be able to put quotes around the lines and a comma after all but the final line. Warn him/her about embedded quote marks.