Javascripting....

Kris Anderson kanderson at eric.uoregon.edu
Wed Nov 6 14:37:13 PST 2002


Thanks for the quick help, I'll check it out (BTW checked it out, nice
solution). Also, I might have a kludgey solution to the Javascript brace
problem. I do things in PHP and I got tired of Frontier breaking things. PHP
uses braces too. Whilest browsing the messages somebody said they used -(-
and -)- to act as the appropriate braces. So then I was like, ok how do you
then tell Frontier to change those to braces? Wheee, I looked at the
tutorials and they had a filter that did search and replace. The ol' change
foo to bar thing. So I took their filter and changed it to suit my needs. So
thusely add the following to finalFilters:

local (s = adrPageTable^.renderedText); //get the rendered text into s
s = string.replaceAll (s, "-(-", "{"); //replace all occurences of foo with
bar
s = string.replaceAll(s, "-)-","}");
adrPageTable^.renderedText = s //replace rendered text with s

Now isn't that cool. It works for my PHP stuff and it certainly should work
for Javascript. A way to stream line so you don't have to keep making s=
statements might be to create an array of items to look for and an array for
items to replace with so then you could look through the look for items and
replace with the replace items. Or some other wizbang way.

Or another thing I received from Mr. Kennett is do something like this for
javascripting. This will allow you to create a .js file appropriately called
what ever you named the outline. Yep, it uses an outline. Work is being done
to hopefully fine tune these ideas. Just publish the outline and in the
appropriate directory you should then see your shiney new js file.

 #template "no-template"  // this is simply a blank template with just
#pageHeader "" and {bodytext} as the only two lines.
#fileextension ".js"
#processMacros "false"
#renderoutlinewith "justText"

I'll have to find the above directives, looked for them previously or
something like them but either missed them or just did not find the right
spot.

Oh, if you folks wanted to use the later concept for PHP, my guess is that
since you might have a mix of PHP and HTML someplace you may or may not want
to have #processMacros "false". Just takes a bit more planning as to what to
do, unless of course you could nest the #processMacros directive. :(

Oops, more solutions. I'll check those out as well. And if a nice, somewhat
clean solution is found amongst the mix I'll gladly post a final findings
sort of thing so folks can check it out.

HTH
~Kris
----- Original Message -----
And Thanks to Mr. Kennett for his assistance in the matter too. :)

From: "David Carter-Tod" <wccartd at wcc.vccs.edu>
To: <Frontier-Users at userland.com>
Sent: Wednesday, November 06, 2002 11:55 AM
Subject: Re: Javascripting....


> 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