Javascripting....

David Carter-Tod wccartd at wcc.vccs.edu
Wed Nov 6 11:55:03 PST 2002


At 11:18 AM 11/6/2002 -0800, Kris Anderson wrote:
>I've tried making subtables and putting my script in WP text but the only
>success with that is putting the WP text at the root of the Frontier file
>under websites giving it some # name like #editorScript (as a WP text
>element).

Some of this is off the top of my head, but I hope it helps.

All # elements are hierarchical and that includes tables.  To refer to an 
object inside a table in the traditional web site rendering process you 
need to de-reference it typically.  For example, if you have a table called 
#javascripts with a myscript text object containing javascript, then in the 
rendering process you can include it in a page by using:

{javascripts^.myscript}

Matt Neuberg posted a script a long time ago that showed how to make #tools 
tables both hierarchical and accumulative (i.e. same behavior as the 
#glossary).  Here's what I have as part of my firstFilter:

new (tabletype, @adrpagetable^.temptools);
adrpagetable^.tools = @adrpagetable^.temptools;
« bubble up looking for #tools tables
local (nomad = parentof(adrpagetable^.adrObject^));
loop {
         if nomad == nil or nomad == @root {
                 break};
         if defined (nomad^.["#tools"]) {
                 local (adr = @nomad^.["#tools"]);
                 local (ct = sizeOf (adr^), i, theName);
                 for i = 1 to ct {
                         theName = nameOf(adr^[i]);
                         if not defined (adrpagetable^.temptools.[theName]) {
                                 adrpagetable^.temptools.[theName] = 
adr^[i]}}};
         nomad = parentof(nomad^)}

This means that in any sub-table I can have a #tools table containing what 
I need and just refer to it by name.  Also the #prefs table and the 
#glossary table both behave this way by default.  Those are both reasonable 
locations for javascript although the usage will vary, e.g a javascript in 
the glossary can just be referred to with "myscript".

The most common issue you run into with Javascript (or at least, I do), is 
that when you include curly quotes, Frontier can sometimes misinterpret 
those as Frontier scripts and you end up with macro errors in your 
pages.  Again, putting these in sub-# tables helps.  Also you can use 
something like:

{string(javascripts^.myscript)}

Other times you may just need to escape the code, e.g. \{

Another tool that might be of use is the Javascript Suite:
http://www.spinwardstars.com/frontier/suites/js.html

Although Sam hasn't done anything with it for a long time, it will work 
just fine in the latest version of Frontier.  There's a fair amount of 
stuff out there like this that still works.

http://old.scriptmeridian.org/doodads/html.html

HTH

David
--
David Carter-Tod
<wccartd at wcc.vccs.edu>

Instructional Technologist/Distance Education Contact
Wytheville Community College, 1000 E. Main St.,
Wytheville, VA 24382
(wk) 276-223-4784
http://www.wcc.vccs.edu/

Online certificate in web site design:
http://www.wcc.vccs.edu/websiteDesign




More information about the Frontier-Users mailing list