ShowSource.a
<%@ Language=JavaScript %>
<!--#include file = "include/SetGlobals.a quot;-->
<%
// get the page to di lay from the URL
var age = " quot; + Request.QueryString ( " age" );
// make sure it's a page we allow them to view!
switch ( age )
{
case "Wider":
case "COM":
case "Handle404":
case "Categorie quot;:
case "CategoryPage":
case "Colum quot;:
case "Result age":
case "Date":
case "Contact":
case " u cribe":
case "MailToList":
reak;
default:
Re o e.Redirect ( " aughtyNaughty!" );
}
// output relevant meta tags
Init( "A source example" );
// output common top of page
Header( '<a href="work.a quot gt;Work</a> --> <a href="' + age + '.a quot gt quot;' + age + '.a quot lt;/a> --> Source', 3 );
// output page content
Content ( );
// output common bottom of page
Footer ( );
%>
<% /* standard page elements */ %>
<!--#include file = "utils/Init.a quot;-->
<!--#include file = "utils/Header.a quot;-->
<!--#include file = "utils/Footer.a quot;-->
<!--#include file = "utils/ShowFile.a quot;-->
<%
// ============================================
// the content of this page
// ============================================
function Content ( )
{
Out ( '<td width="20%" gt am lt;/td>' );
Out ( '<td width="60%" gt;' );
// create handle to FileSystemObject
var oFSO = Server.CreateObject ( 'Scripting.FileSystemObject' );
// each source file that we show source for could have a related
// documentation file for us to di lay before and after the
// source. for now, I use a generic header and footer file. the
// 'true' tells ShowFile to pa through any HTML to the browser.
howFile ( oFSO, 'Generic.pre', true, false );
witch ( age )
{
case "Categorie quot;:
case "CategoryPage":
case "Colum quot;:
Out ( '< gt lt;img src=http://www.knowsky.com/"images/new.gif" gt am lt;a href=http://www.knowsky.com/"Categories.zi quot gt;Download</a> all the source for the category demo tration!< gt;' );
reak;
}
howSource ( oFSO, age + '.a ', true );
// show any extra utility file(s) too
witch ( age )
{
case "Wider":
howSource ( oFSO, 'include/SetGlobals.a ', true );
howSource ( oFSO, 'utils/Header.a ', true );
reak;
case "Categorie quot;:
case "CategoryPage":
case "Colum quot;:
case " u cribe":
case "MailToList":
howSource ( oFSO, 'utils/Database.a ', true );
reak;
case "Categorie quot;:
case "CategoryPage":
case "Colum quot;:
howSource ( oFSO, 'utils/ShowCategory.a ', true );
reak;
}
// show the generic footer
howFile ( oFSO, 'Generic. t', true, false );
// we've finished with the object so free the resource
oFSO = null;
Out ( '< gt lt;center> lt;a href="FSO.a quot gt lt;img src=http://www.knowsky.com/"images/source.gif" border=0> lt;/a> lt;/center>' );
Out ( '</td>' );
Out ( '<td width="20%" gt am lt;/td>' );
}
%>
utils/ShowFile.a
<%
// have we advertized our mailing list yet?
var bDoneLink = false;
// ============================================
// di lay the contents of the given file
// ============================================
function ShowFile ( oFSO, sFile, a HTML, howName )
{
var ForReading = 1;
// var ForWriting = 2;
// var ForA ending = 8;
// open a file for reading
var fFile = oFSO.OpenTextFile ( Server.Ma ath( sFile ), ForReading );
// read entire file contents into variable
var s = fFile.ReadAll ( );
if ( ! a HTML )
{
// replace &am with &am am so HTML di layed, not interpreted
= s.replace ( /&am /g, '&am am ' );
// replace < with &am lt; so HTML di layed, not interpreted
= s.replace ( /</g, '&am lt;' );
// replace newline with HTML equivalent
= s.replace ( /\n/g, '< r>' );
// replace ta with 3 aces
= s.replace ( /\t/g, '&am am am ' );
// show filename and change font color for source code
= '<font color=" lack" gt;' + s + '</font>';
if ( howName )
= '<h4>' + sFile + '</h4>' +
}
Out ( s );
fFile.Close ( );
}
// ============================================
// show a source file outside the table
// ============================================
function ShowSource ( oFSO, sFile, howName )
{
// advertize our mailing list before the first source file
if ( !bDoneLink )
{
DoneLink = true;
Out ( '< gt lt gt;Get informed when the source code below changes!</ gt; <a href=" u cribe.a quot gt u cribe to our mailing list.</a>' );
}
Out ( '</td>' );
Out ( '<td width="20%" gt am lt;/td> lt;/tr> lt;tr> lt;td col an=3 width="100%" bgcolor="#ff9900" gt;' );
// show news file
howFile ( oFSO, sFile, false, howName );
Out ( '</td> lt;/tr> lt;tr> lt;td width="20%" gt am lt;/td>' );
Out ( '<td width="60%" gt;' );
}
%>
an>


