> pictools > doc > scripts
> pictools > doc > scripts
Pictools: Physpics Page Pieces
V3.3 (445)
scripts.js
/scripts.js
Defines JavaScript for visual effects on the search button and dirbar
usage, in beginpage.php: <script type="text/javascript" src="/scripts.js"></script>

Client-side actions require JavaScript code. The methods in this script are called from event handlers attached to various parts of Pictools pages.

swap(id, beswapped)

The object with the given id attribute must have these attributes:

        id   	- an identifier
        src  	- probably an image URL
        swappic	- alternate value for src
        isswapped - boolean, initially false

When isswapped is not equal to the value of beswapped, fields src and swappic are each given the value of the other. If src and swappic are images of different sizes, the width and height attributes should be omitted.

Example:

    <div ... onmouseout="swap('zf', false)" 
        onmouseover="swap('zf', true)" >
    ...
        <img id="zf" src="/images/twomugs-small.gif" 
            swappic="/images/fredOnFuji-smaller.png" 
            isswapped="false" />
    ... </div>
enableSlideshow()
The initial slideshow button is a button-like <span>. The onload event in the <body> calls this method to convert the button to an <a>.
dirbarspanin(id)
dirbarspanout(id)
Methods to change colors between light and dark blue as the mouse moves in and out of the object with name "mid"+id.
searchfocus()
searchblur()
Functions to change the appearance of the searchbox as it gains/loses focus.
xmlhttp = new ...
Defines and initializes an object for making requests from the server. Code to fetch test.txt would look like this:
if (xmlhttp) {
   xmlhttp.open("GET", "test.txt",true);
   xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
       do something with xmlhttp.responseText 
                 or xmlhttp.responseHTML
     }
   }
   xmlhttp.send(null);
}

Or fetch and parse as HTML with this function

function fetchDOM(filename) {
   if (xmlhttp) {
       xmlhttp.open("POST", filename, true); 
       xmlhttp.responseType = "document";
       xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4) 
             return xmlhttp.responseXML
       }
       try {
          xmlhttp.send(null)
       }
       catch (e){
          handle error
       }
   }
   return false;
}
 
 
Copyright © 2023 ZweiBieren, All rights reserved. Feb 5, 2023 17:05 GMT Page maintained by ZweiBieren