4.1 Javascript: Pop-ups On Mouse Over

  4.1.1 Background
  4.1.2 End Points of the Jobname-js.tex File
  4.1.3 Configuration Commands
  4.1.4 Footnotes Contributions
  4.1.5 Overlib
  4.1.6 Boundary Cases for mouseover
  4.1.7 The Configuration File onmouseover.4ht

4.1.1 Background

There are 6 supporting dvi variations of the ‘CopyTo to-file op group’ dvi command:

From
Start copying (at current address)
Until
End copying (at current address)
Skip
Start skipping (from current address)
Cont
End skipping (at current-address)
Addr integer-label
Associate current address with the integer-label of the given group
Set integer-label
Replace the ‘current address’ in the following Skip/Cont (and From/Until ?) commands with the address associated to the integer-label of the given group by an Addr command

The code

B0  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex From bib }  
B1  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Skip bib }  
B2  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Addr1 bib }  
B3  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Addr2 bib }  
B4  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Set1 bib }  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Cont bib }  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Set2 bib }  
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Skip bib }  
B5  
\ht:special {t4ht@DCopyTo: \jobname-js.tex Until bib }  
B6

produces the string ‘ B1 B3 ’.

4.1.2 End Points of the Jobname-js.tex File

<..start js..>
 \js:on
-_-_-

<..onmouseover utilities..>
 \def\js:on{%
   \global\let\js:on=\relax
   \HCode{<!--}%
   <.js From js.>%
   \HCode{\string\def\string\jstoday{\:today} }%
   \HCode{\string\input\space onmouseover.4ht }%
   \:CheckOption{trace-onmo} \if:Option
       \HCode{<js trace="on">}%
   \else
      \Log:Note{for mouseover tracing of
           compilation, use the command line option ‘trace-onmo’}
       \HCode{<js>}%
   \fi
   <.js Until js.>%
   \HCode{-->}%
   <.end js.>}
-_-_-

<..end js..>
 \csname a:mouseover-Needs\endcsname
 \Css{.js {text-indent:0; background-color:aqua; color:black;
    border:solid 1px black;  margin:2pt; width:99\%;}}
 \Css{.js p, .<.js p.bibitem css.>, <.js p.bibitem-p css.> {text-indent:0;
    background-color:aqua; color:black; margin:2pt;}}
 \AtEndDocument{{\HCode{<!--}%
   <.js From js.>%
   \HCode{</js>}%
   <.js Until js.>%
   \HCode{-->}}}%
-_-_-

Was \Css{.js p {margin:0; text-indent:0;}} but javascript under netscape had problems dealing with 0 left margins.

<..js From js..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex From js }%
-_-_-

<..js Until js..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Until js }%
-_-_-

4.1.3 Configuration Commands

<..onmouseover utilities..>+
 \HAssign\MO:script = 0
 \NewConfigure{mouseover-script}[1]{\bgroup
   \gHAdvance\MO:script by 1
   \expandafter\NextFile \expandafter{\jobname\MO:script.tmp}%
   \HPage{}\IgnorePar <.js From var.>%
     \HCode{<\if !#1!\else mouseover-script\fi>#1\if !#1!\else =\fi}%
     \everyvbox{\IgnorePar\everyvbox{}\aftergroup\end:movar}%
     \def\end:movar{\everyvbox{}\HCode
                    {</\if !#1!\else mouseover-script\fi>}%
         <.js Until var.>\EndHPage{}%
         \egroup}%
     \vbox}
-_-_-

<..ol-hauto mouseover-script..>
 \Configure {mouseover-script}{}{\HCode{ol\string_hauto = 1;}}%
-_-_-

<..js From var..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex From var }%
-_-_-

<..js Until var..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Until var }%
-_-_-

<..onmouseover utilities..>+
 \expandafter\def\csname c:mouseover-vars:\endcsname#1#2{%
    \expandafter\def\csname mouseover-#1-init\endcsname##1{}%
    \def\:tempc##1{\expandafter\append:defI\csname
       mouseover-#1-init\endcsname{tex4ht.##1=tex4ht.\expandafter\jsHash
       \expandafter{\expandafter v####1.##1};}}%
    \Mo:vars#2,<>}
 \def\Mo:vars#1,#2<>{%
    \if !#1!\else
       \expandafter\def\csname mo#1\endcsname##1{%
           \HCode{<!--}%
           \ht:special{t4ht@DCopyTo: \jobname-js.tex From #1 }%
           \HCode{<#1-var>\jsHash{v##1.#1}=}%
           \ht:special{t4ht@DCopyTo: \jobname-js.tex Skip #1 }%
           \HCode{-->}%
           \ht:special{t4ht@DCopyTo: \jobname-js.tex Cont #1 }%
       }%
       \expandafter\def\csname endmo#1\endcsname{%
           \ht:special{t4ht@DCopyTo: \jobname-js.tex Skip #1 }%
           \HCode{<!--}%
           \ht:special{t4ht@DCopyTo: \jobname-js.tex Cont #1 }%
           \HCode{</#1-var>}%
           \ht:special{t4ht@DCopyTo: \jobname-js.tex Until #1 }%
           \HCode{-->}%
       }%
       \:tempc{#1}%
    \fi
    \if !#2!\else \expand:after{\Mo:vars#2<>}\fi
 }
-_-_-

4.1.4 Footnotes Contributions

<..js From fn..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex From fn }%
-_-_-

<..js Skip fn..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Skip fn }%
-_-_-

<..js Cont fn..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Cont fn }%
-_-_-

<..js Until fn..>
 \ht:special {t4ht@DCopyTo: \jobname-js.tex Until fn }%
-_-_-

4.1.5 Overlib

egroup for overlib, home over overlib

<..overDiv..>
 \HCode{<div id="overDiv"
          style="position:absolute;
                       visibility:hidden; z-index:1000;"></div>
 }%
-_-_-

<..onmouseover @HEAD..>
 \Configure{@HEAD}
   {\HCode{% natural place for <overlib src>, but netscape 4.7...
      <script type="text/javascript"
                  src="\jobname-js.js"></script>\Hnewline
      <.overlib src.>}}
 <.onmouseover utilities.>
 \:CheckOption{info} \if:Option
    <.overlib info.>
 \fi
-_-_-

<..overlib info..>
 \Log:Note{Option ‘mouseover’ is powered
   by the overlib.js utility of Erik Bosrup
   (http://www.bosrup.com/web/overlib/).}
 \immediate\write-1{}
 \immediate\write-1{The option requires two compilations of
   the source file.}
 \immediate\write-1{}
 \immediate\write-1{Use \string\Configure
   {mouseover-XXX}{...} to introduce extra arguments into the overlib
   function call ‘return overlib(...)’. XXX stands for
   ‘cite’, ‘footnote’, or ’gloss’. The default body is at tex4ht.body,
   and the default caption at tex4ht.caption. An empty parameter
   requests no  sensitivity of the  mouse for the
   specified type of entries.}
 \immediate\write-1{}
 \immediate\write-1{The variant \string\Configure
   {mouseover-XXX}[labels]{...} of the above command restricts the
   outcome just to the listed labels (i.e., the values listed
   in tex4ht.caption).}
 \immediate\write-1{}
 \immediate\write-1{The \string\Configure{mouseover-script}{variable-name}
   {javascript-code} command may be used to introduce code into the
   javascript file, as a content of a global variable when a name is
   given and as a bare code when the name is not given.  To be referenced,
   the name must be prefixed by ‘‘tex4ht.’.}
 \immediate\write-1{}
 \immediate\write-1{The \string\Configure{mouseover-vars}{XXX}
   {variable-list} command introduces local variables, to be referenced
   with the prefix ‘‘tex4ht.’ on their names. In addition, for each
   variable YYY  it introduces a construct \string\moYYY
   {label}...\string\endmoYYY\space for selecting a value for the variable
   at the specified label.}
 \immediate\write-1{}
 \immediate\write-1{Example:}
 \immediate\write-1{
   \string\Configure{mouseover-script}{var}{\HCode{<hr />}}}
 \immediate\write-1{<.mouseover cite config.>}
 \immediate\write-1{<.mouseover cite css.>.}
 \immediate\write-1{
   \string\moAuthor{bb}A name\string\endmoAuthor }
 \immediate\write-1{}
 \immediate\write-1{The compilation indirectly invokes the
   command ’xhtex \string\jobname-js’.  An alternative format for
   the command can be requested within a configuration of
   the form \string\Configure{mouseover-Needs}{\string\Needs{"..."}}.
   The default setting is due to
   \string\Configure{mouseover-Needs}{\string\Needs{"xhtex
   \string\jobname-js"}}}
 \immediate\write-1{In case \string\Configure{mouseover-Needs} is
   undefined, introduce the instruction
   \string\NewConfigure{mouseover-Needs}{1} before that command.
 }
-_-_-

<..onmouseover utilities..>+
 \expandafter\ifx \csname mouseover-Needs\endcsname\relax
   \NewConfigure{mouseover-Needs}{1}
   \Configure{mouseover-Needs}{\Needs{"xhtex \jobname-js"}}
 \fi
 \def\mo:args#1#2#3{\expandafter
   \ifx \csname a:mouseover-#1-#2\endcsname\empty\else
   \expandafter \ifx \csname a:mouseover-#1-#2\endcsname\relax
     <.global mouseover-type.>\else
     <.private mouseover-type.>\fi\fi}
-_-_-

<..global mouseover-type..>
 \expandafter \ifx \csname a:mouseover-#1\endcsname\empty
       \else
     \Hnewline
     onmouseover="tex4ht.body=tex4ht.#3; tex4ht.caption=’#2’;
             <.init mouseover vars.>%
               return overlib(\csname a:mouseover-#1\endcsname);"
    \Hnewline    onmouseout="nd();"\Hnewline\fi
-_-_-

<..private mouseover-type..>
 \Hnewline
  onmouseover="tex4ht.body=tex4ht.#3; tex4ht.caption=’#2’;
             <.init mouseover vars.>%
             return overlib(\csname a:mouseover-#1-#2\endcsname);"
 \Hnewline onmouseout="nd();"\Hnewline
-_-_-

<..init mouseover vars..>
 \expandafter\ifx \csname mouseover-#1-init\endcsname\relax
             \else \csname mouseover-#1-init\endcsname{#2}\fi
-_-_-

4.1.6 Boundary Cases for mouseover

<..DOCTYPE in PROLOG under mouseover..>
 \:CheckOption{xhtml} \if:Option  \else
    \:CheckOption{DOCTYPE} \if:Option
     \Log:Note{to request a DOCTYPE declaration
           use the command line option ‘DOCTYPE’}
    \else
       \edef\Preamble{\Preamble,no-DOCTYPE}
    \fi
 \fi
-_-_-

<..overlib src..>
 <script type="text/javascript" src="overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
 <!--http://www.bosrup.com/web/overlib/-->%
-_-_-

4.1.7 The Configuration File onmouseover.4ht

<..onmouseover.4ht..>
 \ifnum\the\catcode‘\%=14\else\expandafter\edef\csname
   \string:RestoreCatcodes\endcsname{\catcode‘\%=\the
   \catcode‘\%}\catcode‘\%=14\fi
 % onmouseover.4ht (2014-07-14-18:32), generated from tex4ht-html4.tex
 % Copyright (C) 2009-2010 TeX Users Group
 % Copyright (C) 2001-2009 Eitan M. Gurari
 <.TeX4ht copywrite.>
 
 \hbadness=10000 \vbadness=10000 \hfuzz=99in \vfuzz=\hfuzz
 \overfullrule=0pt   \let\makefootline\empty
 \special{t4ht.js}
 
 \newcount\CodeNumber
 \def\NoSpecials#1#2#3{\edef\temp{\the\CodeNumber}%
      \global\CodeNumber=#3
      \def\next{\catcode\CodeNumber=#1
        \ifnum \CodeNumber=#2 \let\next=\relax \fi
        \global\advance\CodeNumber by -1 \next}\next
      \global\CodeNumber=\temp  }%
 
 \expandafter\def\csname js js\endcsname{\egroup  \special{t4ht@@}%
    tex4ht=new Array() ; //\jstoday}
 \expandafter\def\csname js js trace="on"\endcsname{\global
    \let\TagTrace=\empty \csname js js\endcsname}
 \expandafter\def\csname js /js\endcsname{\egroup \special{t4ht@@}%
    \csname bye\endcsname\endinput}
 
 <.hash for onmouseover.4ht.>
 <.escape backslashes.>
 \catcode‘\<=13
 \def\jselement#1{\expandafter\def\csname js #1\endcsname##1=##2</#1>{%
    \hfill\break tex4ht.\jsHash{##1}=\hbox{"##2";}\egroup}}
 <.escape double quotes.>
 \expandafter\def\csname js \endcsname#1</>{%
    \hfill\break \hbox{#1}\egroup}
 
 \def<#1>{\bgroup
    \expandafter \ifx \csname js #1\endcsname \relax \jselement{#1}\fi
    \def<##1>{\TagTrace{\def\x{##1}\def\y####1:->{}%
       \immediate\write16{...\string<\expandafter\y\meaning\x>}}%
        \string<\scan ##1"<>>}%
    \NoSpecials{12}{0}{255}\NoSpecials{11}{65}{90}\NoSpecials{11}{97}{122}%
    \catcode‘\ =10 \catcode‘\^^M=10 \catcode‘\^^I=10 \catcode‘\<=13
    \catcode‘\\=13
    \tt \csname js #1\endcsname}
 \def\TagTrace#1{}
 \catcode‘\&=12 \catcode‘\#=12
 \endinput
-_-_-

<..escape double quotes..>
 \def\scan#1"#2<>{#1\if !#2!\expandafter\done\else
    \string\"\expandafter\scan
 \fi#2<>}
 \def\done#1>{}
-_-_-

<..escape backslashes..>
 \catcode‘/=0 \catcode‘\\=13
 /def\{/string\/string\}
 /catcode‘/\=0 \catcode‘\/=12
-_-_-

<..onmouseover utilities..>+
 \def\jsHash#1{\jsHash:a #1<>}
 \def\jsHash:a#1#2<>{%
    \ifnum ‘#1<‘0 JjV\else
    \ifnum ‘#1>‘z jJv\else
    \ifnum ‘#1>‘9
       \ifnum ‘#1<‘A jJV\else
       \ifnum ‘#1>‘Z
          \ifnum ‘#1<‘a jVV\else #1\fi
       \else #1\fi\fi
    \else #1\fi\fi\fi
    \if !#2!\expandafter\done:hash
                        \else\expandafter\jsHash:a\fi#2<>}
 \def\done:hash#1>{}
-_-_-

<..hash for onmouseover.4ht..>
 \def\jsHash#1{\jsHasha #1<>}
 \def\jsHasha#1#2<>{%
    \ifnum ‘#1<‘0 JjV\else
    \ifnum ‘#1>‘z jJv\else
    \ifnum ‘#1>‘9
       \ifnum ‘#1<‘A jJV\else
       \ifnum ‘#1>‘Z
          \ifnum ‘#1<‘a jVV\else #1\fi
       \else #1\fi\fi
    \else #1\fi\fi\fi
    \if !#2!\expandafter\done
                        \else\expandafter\jsHasha\fi#2<>}
-_-_-

<..onmouseover utilities..>+
 \expandafter\Odef\csname c:mouseover-?:\endcsname[#1]#2{%
   \def\:temp{#2}%
   \if !#1!\expandafter\let\csname a:mouseover-\:tempb\endcsname=\:temp
   \else \om:type#1,<.par del.>\fi}
 \def\om:type#1,#2<.par del.>{%
   \if !#1!\else\expandafter
      \let\csname a:mouseover-\:tempb-#1\endcsname=\:temp\fi
   \ifx !#2!\else \def\:tempa{\om:type#2<.par del.>}\expandafter\:tempa \fi
 }
-_-_-