Source Code for suites.jsl.scriptTag

on scriptTag () {
     «scriptTag - by Philip Suh phil@gaijins.com
          «Wed, Mar 11, 1998 at 7:59:53 PM by PS
               «First pass on this script.
                    «Supports the old #javascript directive.
                    «Also will include anything that begins with jsl
                         «the first line should contain a #scriptlanguage directive
                         «with the script langauge of course!
                              «VBScript or Javascript
                         «
                         «
                         «If it's a scripttype, and DOESN'T have a directive on the first line
                         «we run the script and return the result
                    «plan to include automatic script includes later.
               «designed to be used in a #pageheader
     local (ttr="\r", adrpagetable);
     adrpagetable = html.data.adrPageTable;
     on add (s) {
          ttr = ttr + s};
     
     «backwards compatibility for #javascript directive
          «#javascript "" or #javascript "none" 
               «are ignored. No Javascript is inserted
          «#javascript can be an address
          «
          «old code
          «if defined (adrPageTable^.javaScript)  // old code
               «add ("<script language='JavaScript'>\r<!--\r")
               «add (adrPageTable^.javaScript)
               «add ("\r//-->\r</script>\r")
     if defined (adrPageTable^.javaScript) { //  3/18/1998  by PS
          if adrPageTable^.javaScript != "" && adrPageTable^.javaScript != "none" {
               while typeOf (adrPageTable^.javaScript) == addresstype {
                    adrPageTable^.javaScript = adrPageTable^.javaScript^};
               add ("<SCRIPT LANGUAGE=\"JavaScript\">\r<!--\r");
               add (string(adrPageTable^.javaScript));
               add ("\r//-->\r</SCRIPT>\r")}};
     
     «jsl directives framework
          «Based on code from Jim Correia and Jeb Bateman.
     on addScript (item) { // now in jsl.addScript Sat, Apr 4, 1998 at 11:52:48 PM by PS
          local {
               sLang = ""; «script language
               sData; «the actual text of the script
               itemType};
          
          «follow addresses till we get to a non-address object
          itemType = typeOf (adrpagetable^.[item]);
          while itemType == addresstype {
               adrPageTable^.[item] = adrPageTable^[item]^;
               itemtype = typeOf (adrPagetable^[item])};
          
          «check for #scriptLanguage, and execute scripts
               «scripts that begin with #scriptlanguage are not executed
                    «they are coerced to a string
                    «and we get Frontier's smart braces and semicolons.
               «scripts that don't begin with #scriptlanguage
                    «are executed.  Add intelligence here. :-)
          sData = string(adrPageTable^.[item]);
          if string.lower (sData) beginsWith "#scriptlanguage" {
               sLang = string.nthfield (sData, cr, 1);
               sData = sData - sLang;
               sLang = string.nthfield (sLang, ' ', 2);
               sLang = string.popTrailing (sLang, ';');
               sLang = string.popTrailing (sLang, '"');
               sLang = string.popLeading (sLang, '"')}
          else {
               if itemType == scripttype {
                    «if the script begins with a #scriptlanguage directive, just coerce it to a string
                         «this takes advantage of Frontier's automatic addition of semi-colons and parentheses.
                         «Else, run the script, and return the result.
                    sData = adrPageTable^.[item] ()}};
          
          «add  script tags if necessary.
          if sLang != "" {
               add ("<SCRIPT LANGUAGE=\"" + sLang + "\">\r<!--\r");
               add (sData);
               add (cr + "// -->\r</SCRIPT>\r")}
          else {
               add (sData)}; « scripts created via a Usertalk script have to create their own <script> tags.
          return (true)};
     for i = 1 to sizeof (adrpageTable^) {
          adrSubItem = @adrpageTable^ [i];
          itemName = string.lower (nameOf (adrSubItem^));
          msg (itemName);
          if not (itemName beginsWith "jsl_") {
               continue};
          addScript (itemName)};
     
     «add support for jsl automatic script includes
     return (ttr + cr)};

html.data.adrpagetable = @websites.["#data"];
webbrowser.displayText (scriptTag())

Go back to the main page for this script