Diff for /zogiLib/js/dllib.js between versions 1.5 and 1.11

version 1.5, 2004/11/03 15:24:46 version 1.11, 2011/07/26 18:10:24
Line 17  Foundation, Inc., 59 Temple Place - Suit Line 17  Foundation, Inc., 59 Temple Place - Suit
 Authors:  Authors:
   Christian Luginbuehl, 01.05.2003 (first version)    Christian Luginbuehl, 01.05.2003 (first version)
   DW 24.03.2004 (Changed for digiLib in Zope)    DW 24.03.2004 (Changed for digiLib in Zope)
   Robert Casties, 2.11.2004    Robert Casties, 14.7.2006
   
   ! Requires baselib.js !    ! Requires baselib.js !
   
Line 178  function bestPicSize(elem, inset) { Line 178  function bestPicSize(elem, inset) {
     inset = 25;      inset = 25;
     }      }
     var ws = getWinSize();      var ws = getWinSize();
       var wsold = ws.copy();
     var es = getElementPosition(elem);      var es = getElementPosition(elem);
     if (es) {      if (es) {
           if ((es.x > ws.width)||(es.y > ws.height)) {
               alert("es="+es+" is outside ws="+ws+" fixing...");
               ws.width = ws.width - inset;
               ws.height = ws.height - inset;
           } else {
     ws.width = ws.width - es.x - inset;      ws.width = ws.width - es.x - inset;
     ws.height = ws.height - es.y - inset;      ws.height = ws.height - es.y - inset;
     }      }
       }
       //alert("ws="+wsold+" es="+es+" -> ws="+ws);
       //alert("ws="+ws+"("+typeof(ws)+") es="+es);
     return ws;      return ws;
 }  }
   
   function setDLParam(e, s, relative) {
       // sets parameter based on HTML event
       var nam;
       var val;
       if (s.type && (s.type == "select-one")) {
           nam = s.name;
           val = s.options[s.selectedIndex].value;
       } else if (s.name && s.value) {
           nam = s.name;
           val = s.value;
       }
       if (nam && val) {
           setParameter(nam, val, relative);
           display();
       } else {
           alert("ERROR: unable to process event!");
       }
       return true;
   }
   
   
 /* **********************************************  /* **********************************************
  *     digilib specific routines   *     digilib specific routines
Line 197  function dl_param_init() { Line 226  function dl_param_init() {
     if (!baseScriptVersion) {      if (!baseScriptVersion) {
     base_init();      base_init();
     }      }
     dlScriptVersion = "1.1b";      dlScriptVersion = "1.3a";
     dlArea = new Rectangle(0.0, 0.0, 1.0, 1.0);      dlArea = new Rectangle(0.0, 0.0, 1.0, 1.0);
     dlMaxArea = new Rectangle(0.0, 0.0, 1.0, 1.0);      dlMaxArea = new Rectangle(0.0, 0.0, 1.0, 1.0);
     dlTrafo = new Transform();      dlTrafo = new Transform();
Line 208  function dl_param_init() { Line 237  function dl_param_init() {
     ZOOMFACTOR = Math.sqrt(2);      ZOOMFACTOR = Math.sqrt(2);
   
     // put the query parameters (sans "?") in the parameters array      // put the query parameters (sans "?") in the parameters array
     parseParameters(location.search.slice(1));      // non-digilib parameters get detail level 32
       parseParameters(location.search.slice(1),32);
     // treat special parameters      // treat special parameters
     dlMarks = parseMarks();      dlMarks = parseMarks();
     dlArea = parseArea();      dlArea = parseArea();
     dlFlags = parseFlags();      dlFlags = parseFlags();
       // mask for parameters when creating new URL
       dlUrlParamMask = 255;
 }  }
   
   
Line 238  function dl_init() { Line 270  function dl_init() {
     window.name = "digilib";      window.name = "digilib";
     }      }
     // put the query parameters (sans "?") in the parameters array      // put the query parameters (sans "?") in the parameters array
     parseParameters(location.search.slice(1));      //parseParameters(location.search.slice(1),32);
     // treat special parameters      // treat special parameters
     dlMarks = parseMarks();      dlMarks = parseMarks();
     dlArea = parseArea();      dlArea = parseArea();
Line 254  function dl_init() { Line 286  function dl_init() {
 function display(detail) {  function display(detail) {
     // redisplay the page      // redisplay the page
     if (! detail) {      if (! detail) {
     detail = 9;          detail = 255;
     }      }
     var queryString = getAllParameters(detail);      var queryString = getAllParameters(detail & dlUrlParamMask);
     location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString;      location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString;
 }  }
   
Line 440  function zoomFullpage() { Line 472  function zoomFullpage() {
 function moveCenter() {  function moveCenter() {
     // move visible area so that it's centered around the clicked point      // move visible area so that it's centered around the clicked point
     if ( (dlArea.width == 1.0) && (dlArea.height == 1.0) ) {      if ( (dlArea.width == 1.0) && (dlArea.height == 1.0) ) {
     // noting to do          // nothing to do
     return;      return;
     }      }
     window.focus();      window.focus();
Line 462  function moveCenter() { Line 494  function moveCenter() {
 }  }
   
 function moveBy(movx, movy) {  function moveBy(movx, movy) {
     // move visible area by movx and movy (in units of dw, dh)      // move visible area by movx and movy (in units of ww, wh)
     if ((dlArea.width == 1.0)&&(dlArea.height == 1.0)) {      if ((dlArea.width == 1.0)&&(dlArea.height == 1.0)) {
     // nothing to do      // nothing to do
     return;      return;
Line 477  function moveBy(movx, movy) { Line 509  function moveBy(movx, movy) {
     display();      display();
 }  }
   
       
   
   
 function getRef() {  function getRef() {
     // returns a reference to the current digilib set      // returns a reference to the current digilib set
     if (! baseUrl) {      if (! baseUrl) {
     var baseUrl = location.protocol + "//" + location.host + location.pathname;      var baseUrl = location.protocol + "//" + location.host + location.pathname;
     }      }
     var hyperlinkRef = baseUrl;      var hyperlinkRef = baseUrl;
     var par = getAllParameters(9);      var par = getAllParameters((7+32+64) & dlUrlParamMask); // all without ddpi, pt
     if (par.length > 0) {      if (par.length > 0) {
     hyperlinkRef += "?" + par;      hyperlinkRef += "?" + par;
     }      }
Line 500  function getRefWin(type, msg) { Line 529  function getRefWin(type, msg) {
     }      }
     prompt(msg, getRef());      prompt(msg, getRef());
 }  }
   
   function getQuality() {
       // returns the current q setting
       for (var i = 0; i < 3; i++) {
           if (hasFlag("q"+i)) {
               return i;
           }
       }
       return 1
   }
   
   function setQuality(qual) {
       // set the image quality
       for (var i = 0; i < 3; i++) {
           removeFlag("q"+i);
           if (i == qual) {
               addFlag("q"+i);
           }
       }
       setParameter("mo", getAllFlags());
       display();
   }    
   
   function setQualityWin(msg) {
       // dialog for setting quality
       if (! msg) {
           msg = "Quality (0..2)";
       }
       var q = getQuality();
       var newq = window.prompt(msg, q);
       if (newq) {
           setQuality(newq);
       }
   }
   
   function mirror(dir) {
       // mirror the image horizontally or vertically
       if (dir == "h") {
           toggleFlag("hmir");
       } else {
           toggleFlag("vmir");
       }
       setParameter("mo", getAllFlags());
       display();
   }
   
   function gotoPage(gopage, keep) {
       // goto given page nr (+/-: relative)
       var oldpn = parseInt(getParameter("pn"));
       setParameter("pn", gopage, true);
       var pn = parseInt(getParameter("pn"));
       if (pn < 1) {
           alert("No such page! (Page number too low)");
           setParameter("pn", oldpn);
           return;
       }
       if (hasParameter("pt")) {
           pt = parseInt(getParameter("pt"))
           if (pn > pt) {
               alert("No such page! (Page number too high)");
               setParameter("pn", oldpn);
               return;
           }
       }
       if (keep) {
           display(63+128); // all, no mark
       } else {    
           display(3+32+128); // fn, pn, ws, mo + pt
       }
   }
   
   function gotoPageWin() {
       // dialog to ask for new page nr
       var pn = getParameter("pn");
       var gopage = window.prompt("Go to page", pn);
       if (gopage) {
           gotoPage(gopage);
       }
   }
   
   function setParamWin(param, text, relative) {
       // dialog to ask for new parameter value
       var val = getParameter(param);
       var newval = window.prompt(text, val);
       if (newval) {
           setParameter(param, newval, relative);
           display();
       }
   }
   
   function showOptions(show) {
       // show or hide option div
       var elem = getElement("dloptions");
       showElement(elem, show);
   }
   
   function toggleOptions() {
       // toggle option div
       var elem = getElement("dloptions");
       showOptions(! isElementVisible(elem));
   }

Removed from v.1.5  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>