Mercurial > hg > digilib-old
changeset 133:28f96364040f
unified scripts, nice xul sidebar, bugfixes
author | luginbue |
---|---|
date | Tue, 08 Jul 2003 03:00:57 +0200 |
parents | d111b3d57238 |
children | 1a0496201c75 |
files | client/digitallibrary/digilib.jsp client/digitallibrary/navigation.js client/digitallibrary/navigation_ie.js client/digitallibrary/navigation_n4.js client/digitallibrary/navigation_n6.js client/digitallibrary/navigation_o6.js |
diffstat | 6 files changed, 946 insertions(+), 1832 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/digilib.jsp Wed Jul 02 00:17:06 2003 +0200 +++ b/client/digitallibrary/digilib.jsp Tue Jul 08 03:00:57 2003 +0200 @@ -1,247 +1,249 @@ -<%@ page language="java" %> - -<%! -// authentication stuff - robert -// ----------------------------- -// create DocumentBean instance for all JSP requests -digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean(); - -// initialize DocumentBean instance in JSP init -public void jspInit() { - try { - // set servlet init-parameter - docBean.setConfig(getServletConfig()); - } catch (javax.servlet.ServletException e) { - System.out.println(e); - } -} -%> - - - - -<% - -// parsing the query -// ----------------- - -//digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(request); -digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(); -dlRequest.setWithRequest(request); -// check if authentication is needed and redirect if necessary -docBean.doAuthentication(dlRequest, response); - -%> - -<% - -// the different levels of presentation -// ------------------------------------ - - -// level 3 representation hack - lugi - // it would be much more interesting to check - // if the sidebar is actually installed and in - // the case it isn't - automatically do it. - // however this requires client-side tests and - // so slows down everything. - // we might want to talk about it for a future - // release - -if (dlRequest.getLv() == 3) { - String userAgent = request.getHeader("User-Agent").toLowerCase(); - - if (userAgent.indexOf("mozilla/5.0") == 0) { - - // mozilla 5 that does not support xul-sidebars - if (userAgent.indexOf("opera") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("chimera") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("camino") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("konqueror") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("safari") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("galeon") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("skipstone") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("k-meleon") > -1) dlRequest.setLv(2); - if (userAgent.indexOf("firebird") > -1) dlRequest.setLv(2); - - // the chance is quite big, that the browser supports xul-sidebars - dlRequest.setLv(1); - - } else { - - // redirect to level 2 because of definitive lack of sidebar support - dlRequest.setLv(2); - } -} - - - -switch (dlRequest.getLv()) { - - // LEVEL 0 -------------------------------------------------------------- - - case 0: -%> - -<% - break; // level 0 - - - - - // LEVEL 1 -------------------------------------------------------------- - - case 1: -%> - -<% - // checking if the height and width of this client is already known - if ((dlRequest.getDw() == 0) || (dlRequest.getDh() == 0)) { -%> - -<html> -<head> -<script language="Javascript"> - -function redirect() { - - if (document.body) { - - // internet explorer + opera - client = "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); - - } else { - - // mozilla-browsers (netscape 4.xx, netscape 6.xx, etc.) - client = "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); - - } -<% - if (dlRequest.isRDF()){ - String strAllParams=dlRequest.getAsString(); -%> - location.replace(document.URL+"?"+"<%=strAllParams%>" + client); -<% - }else{ -%> - location.replace(document.URL + client); -<% - } -%> -} - -</script> -</head> -<body bgcolor="#666666" onload="redirect()"> -</body> -</html> - -<% - } else { - - // add number of pages - dlRequest.setPt(docBean.getNumPages(dlRequest)); - - String imageLocation = dlRequest.getBaseURL() + "/servlet/Scaler/?" + dlRequest.getAsString(); -%> - -<html> -<head> -<title>Digital Document Library - Alcatraz (Level 1)</title> - -<script src="navigation.js" type="text/javascript"> </script> - -<!-- modules --> -<script src="modules_new/fitGIFs.js" type="text/javascript"> </script> -<script src="modules_new/pagesTotal.js" type="text/javascript"> </script> -<script src="modules_new/newReferences.js" type="text/javascript"> </script> -<script src="modules_new/imago.js" type="text/javascript"> </script> - -<script type="text/javascript"> - -var baseUrl = "<%= dlRequest.getBaseURL() %>"; - -newParameter('fn', '<%= dlRequest.getFilePath() %>', '', 1); -newParameter('pn', '<%= dlRequest.getPn() %>', '1', 1); -newParameter('ws', '<%= dlRequest.getWs() %>', '1.0', 1); -newParameter('mo', '<%= dlRequest.getMo() %>', '', 1); -newParameter('mk', '<%= dlRequest.getMk() %>', '', 2); -newParameter('wx', '<%= dlRequest.getWx() %>', '0.0', 3); -newParameter('wy', '<%= dlRequest.getWy() %>', '0.0', 3); -newParameter('ww', '<%= dlRequest.getWw() %>', '1.0', 3); -newParameter('wh', '<%= dlRequest.getWh() %>', '1.0', 3); - -newParameter('pt', '<%= dlRequest.getPt() %>', '<%= dlRequest.getPt() %>', 3); - -newParameter('brgt', '<%= dlRequest.getBrgt() %>', '0.0', 3); -newParameter('cont', '<%= dlRequest.getCont() %>', '0.0', 3); -newParameter('rot', '<%= dlRequest.getRot() %>', '0.0', 3); -newParameter('rgba', '<%= dlRequest.getRgba_s() %>', '', 3); -newParameter('rgbm', '<%= dlRequest.getRgbm_s() %>', '', 3); - -</script> - -</head> - -<body bgcolor="#666666" onload="init();"> - - <div id="lay1" style="position: absolute; left: 10px; top: 10px; visibility: visible"><img name="pic" src="<%= imageLocation %>" border="0"></div> - - <div id="dot0" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark1.gif" border="0"></div> - <div id="dot1" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark2.gif" border="0"></div> - <div id="dot2" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark3.gif" border="0"></div> - <div id="dot3" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark4.gif" border="0"></div> - <div id="dot4" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark5.gif" border="0"></div> - <div id="dot5" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark6.gif" border="0"></div> - <div id="dot6" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark7.gif" border="0"></div> - <div id="dot7" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark8.gif" border="0"></div> - <div id="eck1" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="olinks.gif" border="0"></div> - <div id="eck2" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="orechts.gif" border="0"></div> - <div id="eck3" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="ulinks.gif" border="0"></div> - <div id="eck4" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="urechts.gif" border="0"></div> - -</body> - -</html> -<% - } -%> - -<% - break; // level 1 - - - - - // LEVEL 2 -------------------------------------------------------------- - - case 2: -%> - -<% - // retrieve request in new paramter format and redirect to level 1 - dlRequest.setLv(1); - String query = "digilib.jsp?" + dlRequest.getAsString(); -%> - -<html> -<head> -<title>Digital Document Library - Alcatraz (Level 2)</title> -</head> - -<frameset cols="*,90" border="0"> - <frame name="mainFrame" src="<%= query %>" scrolling="auto"> - <frameset rows="20,*" border="0"> - <frame name="pageFrame" src="about:blank" scrolling="no" noresize> - <frame name="rightFrame" src="dlMenu.html" scrolling="no" noresize> - </frameset> -</frameset> - -</html> - -<% - break; // level 2 - -} // end switch - -%> \ No newline at end of file +<%@ page language="java" %> + +<%! +// authentication stuff - robert +// ----------------------------- +// create DocumentBean instance for all JSP requests +digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean(); + +// initialize DocumentBean instance in JSP init +public void jspInit() { + try { + // set servlet init-parameter + docBean.setConfig(getServletConfig()); + } catch (javax.servlet.ServletException e) { + System.out.println(e); + } +} +%> + + + + +<% + +// parsing the query +// ----------------- + +//digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(request); +digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(); +dlRequest.setWithRequest(request); +// check if authentication is needed and redirect if necessary +docBean.doAuthentication(dlRequest, response); + +%> + +<% + +// the different levels of presentation +// ------------------------------------ + + +// level 3 representation hack - lugi + // it would be much more interesting to check + // if the sidebar is actually installed and in + // the case it isn't - automatically do it. + // however this requires client-side tests and + // so slows down everything. + // we might want to talk about it for a future + // release + +if (dlRequest.getLv() == 3) { + String userAgent = request.getHeader("User-Agent").toLowerCase(); + + if (userAgent.indexOf("mozilla/5.0") == 0) { + + // mozilla 5 that does not support xul-sidebars + if (userAgent.indexOf("opera") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("chimera") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("camino") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("konqueror") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("safari") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("galeon") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("skipstone") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("k-meleon") > -1) dlRequest.setLv(2); + if (userAgent.indexOf("firebird") > -1) dlRequest.setLv(2); + + // the chance is quite big, that the browser supports xul-sidebars + dlRequest.setLv(1); + + } else { + + // redirect to level 2 because of definitive lack of sidebar support + dlRequest.setLv(2); + } +} + + + +switch (dlRequest.getLv()) { + + // LEVEL 0 -------------------------------------------------------------- + + case 0: +%> + +<% + break; // level 0 + + + + + // LEVEL 1 -------------------------------------------------------------- + + case 1: +%> + +<% + // checking if the height and width of this client is already known + if ((dlRequest.getDw() == 0) || (dlRequest.getDh() == 0)) { +%> + +<html> +<head> +<script language="Javascript"> + +function redirect() { + + if (document.body) { + + // internet explorer + opera + client = "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); + + } else { + + // mozilla-browsers (netscape 4.xx, netscape 6.xx, etc.) + client = "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); + + } +<% + if (dlRequest.isRDF()){ + String strAllParams=dlRequest.getAsString(); +%> + location.replace(document.URL+"?"+"<%=strAllParams%>" + client); +<% + }else{ +%> + location.replace(document.URL + client); +<% + } +%> +} + +</script> +</head> +<body bgcolor="#666666" onload="redirect()"> +</body> +</html> + +<% + } else { + + // add number of pages + dlRequest.setPt(docBean.getNumPages(dlRequest)); + + String imageLocation = dlRequest.getBaseURL() + "/servlet/Scaler/?" + dlRequest.getAsString(); +%> + +<html> +<head> +<title>Digital Document Library - Alcatraz (Level 1)</title> + +<script src="navigation.js" type="text/javascript"> </script> + +<!-- modules --> +<script src="modules/pagesTotal.js" type="text/javascript"> </script> +<script src="modules/newReferences.js" type="text/javascript"> </script> +<script src="modules/imago.js" type="text/javascript"> </script> + +<script type="text/javascript"> + +var baseUrl = "<%= dlRequest.getBaseURL() %>"; + +newParameter('fn', '<%= dlRequest.getFilePath() %>', '', 1); +newParameter('pn', '<%= dlRequest.getPn() %>', '1', 1); +newParameter('ws', '<%= dlRequest.getWs() %>', '1.0', 1); +newParameter('mo', '<%= dlRequest.getMo() %>', '', 1); +newParameter('mk', '<%= dlRequest.getMk() %>', '', 3); +newParameter('wx', '<%= dlRequest.getWx() %>', '0.0', 2); +newParameter('wy', '<%= dlRequest.getWy() %>', '0.0', 2); +newParameter('ww', '<%= dlRequest.getWw() %>', '1.0', 2); +newParameter('wh', '<%= dlRequest.getWh() %>', '1.0', 2); + +newParameter('pt', '<%= dlRequest.getPt() %>', '<%= dlRequest.getPt() %>', 9); + +newParameter('brgt', '<%= dlRequest.getBrgt() %>', '0.0', 1); +newParameter('cont', '<%= dlRequest.getCont() %>', '0.0', 1); +newParameter('rot', '<%= dlRequest.getRot() %>', '0.0', 1); +newParameter('rgba', '<%= dlRequest.getRgba_s() %>', '', 1); +newParameter('rgbm', '<%= dlRequest.getRgbm_s() %>', '', 1); + +newParameter('ddpix', '<%= dlRequest.getDdpix() %>', '', 9); +newParameter('ddpiy', '<%= dlRequest.getDdpiy() %>', '', 9); + +</script> + +</head> + +<body bgcolor="#666666" onload="init_pagesTotal();"> + + <div id="lay1" style="position: absolute; left: 10px; top: 10px; visibility: visible"><img name="pic" src="<%= imageLocation %>" border="0"></div> + + <div id="dot0" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark1.gif" border="0"></div> + <div id="dot1" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark2.gif" border="0"></div> + <div id="dot2" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark3.gif" border="0"></div> + <div id="dot3" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark4.gif" border="0"></div> + <div id="dot4" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark5.gif" border="0"></div> + <div id="dot5" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark6.gif" border="0"></div> + <div id="dot6" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark7.gif" border="0"></div> + <div id="dot7" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="mark8.gif" border="0"></div> + <div id="eck1" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="olinks.gif" border="0"></div> + <div id="eck2" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="orechts.gif" border="0"></div> + <div id="eck3" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="ulinks.gif" border="0"></div> + <div id="eck4" style="position: absolute; left: -20; top: 100; visibility: hidden"><img src="urechts.gif" border="0"></div> + +</body> + +</html> +<% + } +%> + +<% + break; // level 1 + + + + + // LEVEL 2 -------------------------------------------------------------- + + case 2: +%> + +<% + // retrieve request in new paramter format and redirect to level 1 + dlRequest.setLv(1); + String query = "digilib.jsp?" + dlRequest.getAsString(); +%> + +<html> +<head> +<title>Digital Document Library - Alcatraz (Level 2)</title> +</head> + +<frameset cols="*,90" border="0"> + <frame name="mainFrame" src="<%= query %>" scrolling="auto"> + <frameset rows="20,*" border="0"> + <frame name="pageFrame" src="about:blank" scrolling="no" noresize> + <frame name="rightFrame" src="dlMenu.html" scrolling="no" noresize> + </frameset> +</frameset> + +</html> + +<% + break; // level 2 + +} // end switch + +%>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/digitallibrary/navigation.js Tue Jul 08 03:00:57 2003 +0200 @@ -0,0 +1,697 @@ +/* + +Copyright (C) 2003 WTWG, Uni Bern + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.4 + +*/ + +var ZOOMFACTOR = Math.sqrt(2); + +dlParams = new Object(); + +function newParameter(name, value, defaultValue, detail) { + + if ( !dlParams[name] ) { + + dlParams[name] = new Object(); + + dlParams[name].value = value; + dlParams[name].defaultValue = defaultValue; + dlParams[name].detail = detail; + + return dlParams[name]; + + } else { + + alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!"); + return false; + + } +} + +function getParameter(name) { + + if ( dlParams[name] ) { + return dlParams[name].value; + } else { + return false; + } +} + + + +function listParametersAsString() { + + var params = new Array(); + + for ( param in dlParams ) { + params.push(param); + } + + return params.join(","); + +} + + +function listParameters() { + + var params = new Array(); + + for ( param in dlParams ) { + params.push(param); + } + + return params; + +} + + +function init() { + + // give a name to the window containing digilib - this way one can test if there is already a + // digilib-window open and replace the contents of it (ex. digicat) + top.window.name = "digilib"; + + placeMarks(); + + if ( document.all ) { + this.document.onkeypress = parseKeypress; + } else if ( typeof(document.addEventListener) == "function" ) { + this.document.addEventListener('keypress', parseKeypress, true); + } else { + window.captureEvents(Event.KEYDOWN); + window.onkeydown = parseKeypress; + } + + focus(); +} + + +function display(detail) { + + var queryString = ''; + + for ( param in dlParams ) { + + if ( dlParams[param].defaultValue != dlParams[param].value ) { + if ( dlParams[param].detail <= detail ) { + queryString += "&" + param + "=" + dlParams[param].value; + } else { + queryString += "&" + param + "=" + dlParams[param].defaultValue; + } + } + + } + + if ( document.body ) { + queryString += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); + } else { + queryString += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); + } + + queryString += "&lv=1"; + + queryString = queryString.slice(1); + + location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString; + +} + + +// constructor holding different values of a point +function Point(evt) { + + if ( document.all ) { + + this.pageX = parseInt(document.body.scrollLeft+event.clientX); + this.pageY = parseInt(document.body.scrollLeft+event.clientY); + + this.x = this.pageX-parseInt(document.all.lay1.style.left); + this.y = this.pageY-parseInt(document.all.lay1.style.top); + + this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); + this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); + + } else { + + this.pageX = parseInt(evt.pageX); + this.pageY = parseInt(evt.pageY); + + if ( typeof(document.getElementById) == "function" ) { + + this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); + this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); + + this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth)); + this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight)); + + } else { + + this.x = this.pageX-document.lay1.left; + this.y = this.pageY-document.lay1.top; + + this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width)); + this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height)); + + } + + } + + return this; + +} + + +function page(page, details) { + + if ( details == null ) { + details = 1; + } + + if ( page.indexOf('-') == 0 ) { + if ( dlParams.pn.value > 1 ) { + page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1); + dlParams.pn.value = page; + display(details); + } else { + alert("You are already on the first page!"); + } + + } else if ( page.indexOf('+') == 0 ) { + page = parseInt(dlParams.pn.value) + parseInt(page.slice(1)); + dlParams.pn.value = page; + display(details); + } else if ( page == parseInt(page) ) { + dlParams.pn.value = parseInt(page); + display(details); + } + +} + + +function digicat() { + + var url = baseUrl + "/digicat.jsp?" + dlParams.fn.value + "+" + dlParams.pn.value; + win = window.open(url, "digicat"); + win.focus(); + +} + + +function ref(select) { + + var hyperlinkRef = baseUrl + "/digilib.jsp?"; + hyperlinkRef += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+"; + hyperlinkRef += dlParams.mo.value + "+" + dlParams.mk.value; + + if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) { + hyperlinkRef += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value; + hyperlinkRef += "+" + dlParams.wh.value; + } + + if ( select == 0 ) { + prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + "}{TEXT}"); + } else if ( select == 1 ) { + prompt("Link for HTML-documents", hyperlinkRef); + } +} + + +function mark() { + + if ( dlParams.mk.value.split(";").length > 7 ) { + alert("Only 8 marks are possible at the moment!"); + return; + } + + function markEvent(evt) { + + var point = new Point(evt); + + if ( dlParams.mk.value != '' ) { + dlParams.mk.value += ';'; + } + + dlParams.mk.value += point.relX + '/' + point.relY; + + // stopping event capture + if ( document.all ) { + document.all.lay1.onmousedown = null; + } else if ( typeof(document.removeEventListener) == "function" ) { + document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); + } else { + document.lay1.releaseEvents(Event.MOUSEDOWN); + } + + placeMarks(); + + } + + // starting event capture + if ( document.all ) { + document.all.lay1.onmousedown = markEvent; + } else if ( typeof(document.addEventListener) == "function" ) { + document.getElementById("lay1").addEventListener("mousedown", markEvent, true); + } else { + document.lay1.captureEvents(Event.MOUSEDOWN); + document.lay1.onmousedown = markEvent; + } +} + + +function placeMarks() { + + if ( dlParams.mk.value != '' ) { + + var mark = dlParams.mk.value.split(";"); + var mark_count = mark.length; + + // maximum of marks is 8 + // we do not report this error because this is already done in function 'mark' + if ( mark_count > 8 ) mark_count = 8; + + var picWidth = (document.all) ? parseInt(document.all.lay1.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.pic.clip.width); + var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.pic.clip.height); + + // catch the cases where the picture had not been loaded already and + // make a timeout so that the coordinates are calculated with the real dimensions + if ( (document.pic.complete) || (picWidth > 30) ) { + + var xOffset = (document.all) ? parseInt(document.all.lay1.style.left) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.left) : document.lay1.left; + var yOffset = (document.all) ? parseInt(document.all.lay1.style.top) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.top) : document.lay1.top; + + for (var i = 0; i < mark_count; i++) { + mark[i] = mark[i].split("/"); + + if ( (mark[i][0] >= dlParams.wx.value) && (mark[i][1] >= dlParams.wy.value) && (mark[i][0] <= (parseFloat(dlParams.wx.value) + parseFloat(dlParams.ww.value))) && (mark[i][1] <= (parseFloat(dlParams.wy.value) + parseFloat(dlParams.wh.value))) ) { + + mark[i][0] = parseInt(xOffset + picWidth * (mark[i][0] - dlParams.wx.value)/dlParams.ww.value); + mark[i][1] = parseInt(yOffset + picHeight * (mark[i][1] - dlParams.wy.value)/dlParams.wh.value); + + if ( (document.all) || (typeof(document.getElementById) == "function") ) { + // suboptimal to place -5 pixels and not half size of mark-image + // should be changed in the future + document.getElementById("dot" + i).style.left = mark[i][0]-5; + document.getElementById("dot" + i).style.top = mark[i][1]-5; + document.getElementById("dot" + i).style.visibility = "visible"; + } else { + document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5); + document.layers[i+1].visibility = "show"; + } + } + } + + } else { + setTimeout("placeMarks()", 100); + } + } +} + + +function zoomPoint() { + + function zoomPointEvent(evt) { + + var point = new Point(evt); + + dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value*(1/ZOOMFACTOR)); + dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value*(1/ZOOMFACTOR)); + + dlParams.ww.value = cropFloat(dlParams.ww.value*(1/ZOOMFACTOR)); + dlParams.wh.value = cropFloat(dlParams.wh.value*(1/ZOOMFACTOR)); + + if ( dlParams.wx.value < 0 ) { + dlParams.wx.value = 0; + } + if ( dlParams.wy.value < 0 ) { + dlParams.wy.value = 0; + } + if ( dlParams.wx.value + dlParams.ww.value > 1 ) { + dlParams.wx.value = 1 - dlParams.ww.value; + } + if ( dlParams.wy.value + dlParams.wh.value > 1 ) { + dlParams.wy.value = 1 - dlParams.wh.value; + } + + // stopping event capture + if ( document.all ) { + document.all.lay1.onmousedown = null; + } else if ( typeof(document.removeEventListener) == "function" ) { + document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); + } else { + document.lay1.releaseEvents(Event.MOUSEDOWN); + } + + display(3); + } + + // starting event capture + if ( document.all ) { + document.all.lay1.onmousedown = zoomPointEvent; + } else if ( typeof(document.addEventListener) == "function" ) { + document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true); + } else { + document.lay1.captureEvents(Event.MOUSEDOWN); + document.lay1.onmousedown = zoomPointEvent; + } +} + + +function zoomArea() { + var state = 0; + var pt1, pt2; + + function click(evt) { + + if (state == 0) { + state = 1; + + pt1 = new Point(evt); + pt2 = pt1; + + if ( document.all ) { + + document.all.eck1.style.left = pt1.pageX; + document.all.eck1.style.top = pt1.pageY; + document.all.eck2.style.left = pt2.pageX-12; + document.all.eck2.style.top = pt1.pageY; + document.all.eck3.style.left = pt1.pageX; + document.all.eck3.style.top = pt2.pageY-12; + document.all.eck4.style.left = pt2.pageX-12; + document.all.eck4.style.top = pt2.pageY-12; + + document.all.eck1.style.visibility="visible"; + document.all.eck2.style.visibility="visible"; + document.all.eck3.style.visibility="visible"; + document.all.eck4.style.visibility="visible"; + + document.all.lay1.onmousemove = move; + document.all.eck4.onmousemove = move; + + } else if ( typeof(document.addEventListener) == "function" ) { + + document.getElementById("eck1").style.left = pt1.pageX; + document.getElementById("eck1").style.top = pt1.pageY; + document.getElementById("eck2").style.left = pt2.pageX-12; + document.getElementById("eck2").style.top = pt1.pageY; + document.getElementById("eck3").style.left = pt1.pageX; + document.getElementById("eck3").style.top = pt2.pageY-12; + document.getElementById("eck4").style.left = pt2.pageX-12; + document.getElementById("eck4").style.top = pt2.pageY-12; + + document.getElementById("eck1").style.visibility="visible"; + document.getElementById("eck2").style.visibility="visible"; + document.getElementById("eck3").style.visibility="visible"; + document.getElementById("eck4").style.visibility="visible"; + + document.getElementById("lay1").addEventListener("mousemove", move, true); + document.getElementById("eck4").addEventListener("mousemove", move, true); + + } else { + + document.eck1.moveTo(pt1.pageX, pt1.pageY); + document.eck2.moveTo(pt2.pageX-12, pt1.pageY); + document.eck3.moveTo(pt1.pageX, pt2.pageY-12); + document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12); + + document.eck1.visibility="show"; + document.eck2.visibility="show"; + document.eck3.visibility="show"; + document.eck4.visibility="show"; + + document.lay1.captureEvents(Event.MOUSEMOVE); + document.eck4.captureEvents(Event.MOUSEMOVE); + document.lay1.onmousemove = move; + document.eck4.onmousemove = move; + + } + + } else { + + pt2 = new Point(evt); + + if ( document.all ) { + + document.all.eck1.visibility="hidden"; + document.all.eck2.visibility="hidden"; + document.all.eck3.visibility="hidden"; + document.all.eck4.visibility="hidden"; + + document.all.lay1.onmousedown = null; + document.all.eck4.onmousedown = null; + document.all.lay1.onmousemove = null; + document.all.eck4.onmousemove = null; + + } else if ( typeof(document.removeEventListener) == "function" ) { + + document.getElementById("eck1").style.visibility="hidden"; + document.getElementById("eck2").style.visibility="hidden"; + document.getElementById("eck3").style.visibility="hidden"; + document.getElementById("eck4").style.visibility="hidden"; + + document.getElementById("lay1").removeEventListener("mousedown", click, true); + document.getElementById("eck4").removeEventListener("mousedown", click, true); + document.getElementById("lay1").removeEventListener("mousemove", move, true); + document.getElementById("eck4").removeEventListener("mousemove", move, true); + + } else { + + document.eck1.visibility="hide"; + document.eck2.visibility="hide"; + document.eck3.visibility="hide"; + document.eck4.visibility="hide"; + + document.lay1.releaseEvents(Event.MOUSEDOWN); + document.eck4.releaseEvents(Event.MOUSEDOWN); + document.lay1.releaseEvents(Event.MOUSEMOVE); + document.eck4.releaseEvents(Event.MOUSEMOVE); + + } + + dlParams.wx.value = cropFloat(parseFloat(Math.min(pt1.relX, pt2.relX))); + dlParams.wy.value = cropFloat(parseFloat(Math.min(pt1.relY, pt2.relY))); + + dlParams.ww.value = cropFloat(parseFloat(Math.abs(pt1.relX-pt2.relX))); + dlParams.wh.value = cropFloat(parseFloat(Math.abs(pt1.relY-pt2.relY))); + + if ( (dlParams.ww.value != 0) && (dlParams.wh.value != 0) ) { + display(3); + } + } + } + + function move(evt) { + + pt2 = new Point(evt); + + var eck1_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); + var eck1_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); + var eck2_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;; + var eck2_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); + var eck3_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); + var eck3_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; + var eck4_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; + var eck4_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; + + if ( document.all ) { + + document.all.eck1.style.left = eck1_left; + document.all.eck1.style.top = eck1_top; + document.all.eck2.style.left = eck2_left; + document.all.eck2.style.top = eck2_top; + document.all.eck3.style.left = eck3_left; + document.all.eck3.style.top = eck3_top; + document.all.eck4.style.left = eck4_left; + document.all.eck4.style.top = eck4_top; + + } else if ( typeof(document.getElementById) == "function" ) { + + document.getElementById("eck1").style.left = eck1_left; + document.getElementById("eck1").style.top = eck1_top; + document.getElementById("eck2").style.left = eck2_left; + document.getElementById("eck2").style.top = eck2_top; + document.getElementById("eck3").style.left = eck3_left; + document.getElementById("eck3").style.top = eck3_top; + document.getElementById("eck4").style.left = eck4_left; + document.getElementById("eck4").style.top = eck4_top; + + } else { + + document.eck1.moveTo(eck1_left, eck1_top); + document.eck2.moveTo(eck2_left, eck2_top); + document.eck3.moveTo(eck3_left, eck3_top); + document.eck4.moveTo(eck4_left, eck4_top); + + } + } + + // starting event capture + if ( document.all ) { + document.all.lay1.onmousedown = click; + document.all.eck4.onmousedown = click; + } else if ( typeof(document.addEventListener) == "function" ) { + document.getElementById("lay1").addEventListener("mousedown", click, true); + document.getElementById("eck4").addEventListener("mousedown", click, true); + } else { + document.lay1.captureEvents(Event.MOUSEDOWN); + document.eck4.captureEvents(Event.MOUSEDOWN); + document.lay1.onmousedown = click; + document.eck4.onmousedown = click; + } +} + + +function zoomExtends() { + + dlParams.wx.value = 0.0; + dlParams.wy.value = 0.0; + + dlParams.ww.value = 1.0; + dlParams.wh.value = 1.0; + + display(3); + +} + + +function zoomOut() { + + dlParams.wx.value = cropFloat(dlParams.wx.value-0.5*(dlParams.ww.value*(ZOOMFACTOR)-dlParams.ww.value)); + dlParams.wy.value = cropFloat(dlParams.wy.value-0.5*(dlParams.wh.value*(ZOOMFACTOR)-dlParams.wh.value)); + + dlParams.ww.value = cropFloat(dlParams.ww.value*(ZOOMFACTOR)); + dlParams.wh.value = cropFloat(dlParams.wh.value*(ZOOMFACTOR)); + + if ( dlParams.wx.value < 0 ) { + dlParams.wx.value = 0; + } + if ( dlParams.wy.value < 0 ) { + dlParams.wy.value = 0; + } + if ( dlParams.ww.value > 1 ) { + dlParams.ww.value = 1; + } + if ( dlParams.wh.value > 1 ) { + dlParams.wh.value = 1; + } + if ( dlParams.wx.value + dlParams.ww.value > 1 ) { + dlParams.wx.value = 1 - dlParams.ww.value; + } + if ( dlParams.wy.value + dlParams.wh.value > 1 ) { + dlParams.wy.value = 1 - dlParams.wh.value; + } + + display(3); +} + + +function moveTo() { + + if ( (parseFloat(dlParams.ww.value) == 1.0) && (parseFloat(dlParams.wh.value) == 1.0) ) { + alert("This function is only available when zoomed in!"); + return; + } + + function moveToEvent(event) { + + var point = new Point(event); + + dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value); + dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value); + + if ( dlParams.wx.value < 0 ) { + dlParams.wx.value = 0; + } + if ( dlParams.wy.value < 0 ) { + dlParams.wy.value = 0; + } + if ( dlParams.wx.value + dlParams.ww.value > 1 ) { + dlParams.wx.value = 1 - dlParams.ww.value; + } + if ( dlParams.wy.value + dlParams.wh.value > 1 ) { + dlParams.wy.value = 1 - dlParams.wh.value; + } + + // stopping event capture + if ( document.all ) { + document.all.lay1.onmousedown = null; + } else if ( typeof(document.removeEventListener) == "function" ) { + document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); + } else { + document.lay1.releaseEvents(Event.MOUSEDOWN) + } + + display(3); + } + + // starting event capture + if ( document.all ) { + document.all.lay1.onmousedown = moveToEvent; + } else if ( typeof(document.addEventListener) == "function" ) { + document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true); + } else { + document.lay1.captureEvents(Event.MOUSEDOWN); + document.lay1.onmousedown = moveToEvent; + } +} + + +function scale(factor) { + + dlParams.ws.value = cropFloat(factor); + display(3); + +} + + +// capturing keypresses for next and previous page +function parseKeypress(evt) { + + if ( document.all ) { + + if ( event.keyCode == 110 ) { + page('+1'); + } + if ( event.keyCode == 98 ) { + page('-1'); + } + + document.cancleBubble = true; + + } else { + + if ( evt.charCode == 110 ) { + page('+1'); + } else if ( evt.charCode == 98 ) { + page('-1'); + } else if ( evt.which == 110 ) { + page('+1'); + } else if ( evt.which == 98 ) { + // does not work currentlyfor Opera, because it catches the 'b'-key on it's own + // have to change the key or find another way - luginbuehl + page('-1'); + } + + } +} + + +// auxiliary function to crop senseless precicsion +function cropFloat(tmp) { + return parseInt(10000*tmp)/10000; +}
--- a/client/digitallibrary/navigation_ie.js Wed Jul 02 00:17:06 2003 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,389 +0,0 @@ -// this global variable has to be initialised before the frist use of the functions below -// to fill in the attributes you can use the function init provided below -// - array with all attributes -var att = new Array(); - -// fill in the values of the "att"-array -function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { - - // debug window to check the parameters passed - //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh); - - // attaching the values to the att-array - att[0] = fn; - att[1] = parseInt(pn); - att[2] = parseFloat(ws); - att[3] = mo; - att[4] = mk; - att[5] = parseFloat(wx); - att[6] = parseFloat(wy); - att[7] = parseFloat(ww); - att[8] = parseFloat(wh); - - // compatablility issue - if (att[3].indexOf("f") > -1) { - att[3] = "fit"; - } - - // converts the old mark format (0-1000) to new format(0.0 - 1.0) - // could even be useless now - if (att[4] != "0/0") { - var tmp = att[4].split(";"); - - att[4] = ""; - - for (i = 0; i < tmp.length; i++) { - tmp[i] = tmp[i].split("/"); - - if (tmp[i][0] > 1 && tmp[i][1] > 1) { - tmp[i][0] /= 1000; - tmp[i][1] /= 1000; - } - - att[4] += tmp[i][0] + "/" + tmp[i][1] + ";"; - } - att[4] = att[4].slice(0, -1); - } - - // initialisation stuff - // ==================== - - setMarks(); - - this.document.onkeypress = parseKeypress; - focus(); - - // give a name to the window containing digilib - this way one can test if there is already a - // digilib-window open and replace the contents of it (ex. digicat) - top.window.name = "digilib"; -} - - -// function that launches the ScaleServlet -// the different detailGrades: -// 0 -> back, next, page -// 1 -> zoomout -// 2 -> zoomarea, zoompoint, moveto, scaledef - -function loadPicture(detailGrade, keepArea) { - - var newQuery = "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3]; - - if (detailGrade == 0) { - att[4] = "0/0"; - } - - if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { - att[5] = 0; - att[6] = 0; - att[7] = 1; - att[8] = 1; - } - - newQuery += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8]; - newQuery += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); - - // debug window - checking the parameters passed to the next image - //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); - - location.href = location.pathname + "?" + newQuery; -} - - -// constructor holding different values of a point -function Point(event) { - - this.pageX = parseInt(document.body.scrollLeft+event.x); - this.pageY = parseInt(document.body.scrollTop+event.y); - - this.x = this.pageX-parseInt(document.all.lay1.style.left); - this.y = this.pageY-parseInt(document.all.lay1.style.top); - - this.relX = cropFloat(att[5]+(att[7]*this.x/document.all.lay1.offsetWidth)); - this.relY = cropFloat(att[6]+(att[8]*this.y/document.all.lay1.offsetHeight)); - - return this; -} - - -function backPage(keepArea) { - - att[1] = parseInt(att[1]) - 1; - - if (att[1] > 0) { - loadPicture(0, keepArea); - } else { - att[1] = parseInt(att[1]) + 1; - alert("You are already on the first page!"); - } -} - - -function nextPage(keepArea) { - - att[1] = parseInt(att[1]) + 1; - - loadPicture(0, keepArea); -} - - -function page(keepArea) { - - do { - page = prompt("Goto Page:", 1); - } while ((page != null) && (page < 1)); - - if (page != null && page != att[1]) { - att[1] = page; - loadPicture(0, keepArea); - } -} - - -function digicat() { - var url = "digicat.html?" + att[0] + "+" + att[1]; - win = window.open(url, "digicat"); - win.focus(); -} - - -function ref(refselect) { - - var hyperlinkRef = baseUrl + "/digilib.jsp?"; - hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4]; - - if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) { - hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8]; - } - - if (refselect == 1) { - prompt("Link for HTML--documents", hyperlinkRef); - } else { - prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); - } -} - - -function mark(refselect) { - - document.all.lay1.onmousedown = function() { - var point = new Point(event); - - if (att[4].split(";").length > 7) { - alert("Only 8 marks are possible at the moment!"); - return; - } - - if ((att[4] != "") && (att[4] != "0/0")) { - att[4] += ";"; - } else { - att[4] = ""; - } - - att[4] += point.relX + "/" + point.relY; - - document.all.lay1.onmousedown = function() {} - - setMarks(); - } -} - - -function zoomArea() { - var state = 0; - var pt1, pt2; - - function click() { - if (state == 0) { - state = 1; - - pt1 = new Point(event); - pt2 = pt1; - - document.all.eck1.style.left = pt1.pageX; - document.all.eck1.style.top = pt1.pageY; - document.all.eck2.style.left = pt2.pageX-12; - document.all.eck2.style.top = pt1.pageY; - document.all.eck3.style.left = pt1.pageX; - document.all.eck3.style.top = pt2.pageY-12; - document.all.eck4.style.left = pt2.pageX-12; - document.all.eck4.style.top = pt2.pageY-12; - - document.all.eck1.style.visibility="visible"; - document.all.eck2.style.visibility="visible"; - document.all.eck3.style.visibility="visible"; - document.all.eck4.style.visibility="visible"; - - document.all.lay1.onmousemove = move; - document.all.eck4.onmousemove = move; - - } else { - pt2 = new Point(event); - - document.all.eck1.visibility="hidden"; - document.all.eck2.visibility="hidden"; - document.all.eck3.visibility="hidden"; - document.all.eck4.visibility="hidden"; - - document.all.lay1.cancleBubble = true; - document.all.eck4.cancleBubble = true; - - att[5] = Math.min(pt1.relX, pt2.relX); - att[6] = Math.min(pt1.relY, pt2.relY); - - att[7] = Math.abs(pt1.relX-pt2.relX); - att[8] = Math.abs(pt1.relY-pt2.relY); - - if (att[7] != 0 && att[8] != 0) { - loadPicture(2); - } - } - } - - function move() { - pt2 = new Point(event); - - document.all.eck1.style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); - document.all.eck1.style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); - document.all.eck2.style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; - document.all.eck2.style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); - document.all.eck3.style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); - document.all.eck3.style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; - document.all.eck4.style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; - document.all.eck4.style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; - } - - document.all.lay1.onmousedown = click; - document.all.eck4.onmousedown = click; -} - - -function zoomPoint() { - - document.all.lay1.onmousedown = function() { - var point = new Point(event); - - att[5] = cropFloat(point.relX-0.5*att[7]*0.7); - att[6] = cropFloat(point.relY-0.5*att[8]*0.7); - - att[7] = cropFloat(att[7]*0.7); - att[8] = cropFloat(att[8]*0.7); - - if (att[5] < 0) { - att[5] = 0; - } - if (att[6] < 0) { - att[6] = 0; - } - if (att[5]+att[7] > 1) { - att[5] = 1-att[7]; - } - if (att[6]+att[8] > 1) { - att[6] = 1-att[8]; - } - - document.all.lay1.cancleBubble = true; - - loadPicture(2); - } -} - - -function zoomOut() { - loadPicture(1); -} - - -function moveTo() { - - document.all.lay1.onmousedown = function() { - var point = new Point(event); - - att[5] = cropFloat(point.relX-0.5*att[7]); - att[6] = cropFloat(point.relY-0.5*att[8]); - - if (att[5] < 0) { - att[5] = 0; - } - if (att[6] < 0) { - att[6] = 0; - } - if (att[5]+att[7] > 1) { - att[5] = 1-att[7]; - } - if (att[6]+att[8] > 1) { - att[6] = 1-att[8]; - } - - document.all.lay1.cancleBubble = true; - - loadPicture(2); - } -} - - -function scale(scaledef) { - - att[2] = scaledef; - loadPicture(2); -} - - -function setMarks() { - if ((att[4] != "") && (att[4] != "0/0")) { - var mark = att[4].split(";"); - - var countMarks = mark.length; - - // maximum of marks is 8 - // we do not report this error because this is already done in func. "Mark" - if (countMarks > 8) countMarks = 8; - - var picWidth = document.all.lay1.offsetWidth; - var picHeight = document.all.lay1.offsetHeight; - - // catch the cases where the picture had not been loaded already and - // make a timeout so that the coordinates are calculated with the real dimensions - if (picWidth > 30) { - - var xoffset = parseInt(document.all.lay1.style.left); - var yoffset = parseInt(document.all.lay1.style.top); - - for (var i = 0; i < countMarks; i++) { - mark[i] = mark[i].split("/"); - - if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) { - - mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]); - mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]); - - document.getElementById("dot" + i).style.left = mark[i][0]-5; - document.getElementById("dot" + i).style.top = mark[i][1]-5; - document.getElementById("dot" + i).style.visibility = "visible"; - } - } - } else { - setTimeout("setMarks()", 100); - } - } -} - - -// capturing keypresses for next and previous page -function parseKeypress() { - e = event; - - if (e.keyCode == 110) { - Nextpage(); - } - if (e.keyCode == 98) { - Backpage(); - } - document.cancleBubble = true; -} - - -// auxiliary function to crop senseless precicsion -function cropFloat(tmp) { - return parseInt(10000*tmp)/10000; -}
--- a/client/digitallibrary/navigation_n4.js Wed Jul 02 00:17:06 2003 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,374 +0,0 @@ -// this global variable has to be initialised before the frist use of the functions below -// to fill in the attributes you can use the function init provided below -// array with all attributes -var att = new Array(); - -// fill in the values of the "att"-array -function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { - - // debug window to check the parameters passed - //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh); - - // attaching the values to the att-array - att[0] = fn; - att[1] = parseInt(pn); - att[2] = parseFloat(ws); - att[3] = mo; - att[4] = mk; - att[5] = parseFloat(wx); - att[6] = parseFloat(wy); - att[7] = parseFloat(ww); - att[8] = parseFloat(wh); - - // compatablility issue - if (att[3].indexOf("f") > -1) { - att[3] = "fit"; - } - - // converts the old mark format (0-1000) to new format(0.0 - 1.0) - // could even be useless now - if (att[4] != "0/0") { - var tmp = att[4].split(";"); - - att[4] = ""; - - for (i = 0; i < tmp.length; i++) { - tmp[i] = tmp[i].split("/"); - - if (tmp[i][0] > 1 && tmp[i][1] > 1) { - tmp[i][0] /= 1000; - tmp[i][1] /= 1000; - } - - att[4] += tmp[i][0] + "/" + tmp[i][1] + ";"; - } - att[4] = att[4].slice(0, -1); - } - - // initialisation stuff - // ==================== - - setMarks(); - - window.captureEvents(Event.KEYDOWN); - window.onkeydown = parseKeypress; - - // give a name to the window containing digilib - this way one can test if there is already a - // digilib-window open and replace the contents of it (ex. digicat) - top.window.name = "digilib"; -} - - -// function that launches the ScaleServlet -// the different detailGrades: -// 0 -> back, next, page -// 1 -> zoomout -// 2 -> zoomarea, zoompoint, moveto, scaledef - -function loadPicture(detailGrade, keepArea) { - - var newQuery = "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3]; - - if (detailGrade == 0) { - att[4] = "0/0"; - } - - if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { - att[5] = 0; - att[6] = 0; - att[7] = 1; - att[8] = 1; - } - - newQuery += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8]; - newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); - - // debug window - checking the parameters passed to the next image - //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); - - location.href = location.pathname + "?" + newQuery; -} - - -// constructor holding different values of a point -function Point(event) { - - this.pageX = parseInt(event.pageX); - this.pageY = parseInt(event.pageY); - - this.x = this.pageX-document.lay1.left; - this.y = this.pageY-document.lay1.top; - - this.relX = cropFloat(att[5]+(att[7]*this.x/document.lay1.clip.width)); - this.relY = cropFloat(att[6]+(att[8]*this.y/document.lay1.clip.height)); - - return this; -} - - -function backPage(keepArea) { - - att[1] = parseInt(att[1]) - 1; - - if (att[1] > 0) { - loadPicture(0, keepArea); - } else { - att[1] = parseInt(att[1]) + 1; - alert("You are already on the first page!"); - } -} - - -function nextPage(keepArea) { - - att[1] = parseInt(att[1]) + 1; - - loadPicture(0, keepArea); -} - - -function page(keepArea) { - - do { - page = prompt("Goto Page:", 1); - } while ((page != null) && (page < 1)); - - if (page != null && page != att[1]) { - att[1] = page; - loadPicture(0, keepArea); - } -} - - -function digicat() { - var url = "digicat.html?" + att[0] + "+" + att[1]; - win = window.open(url, "digicat"); - win.focus(); -} - - -function ref(refselect) { - - var hyperlinkRef = baseUrl + "/digilib.jsp?"; - hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4]; - - if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) { - hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8]; - } - - if (refselect == 1) { - prompt("Link for HTML--documents", hyperlinkRef); - } else { - prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); - } -} - - -function mark(refselect) { - - document.lay1.captureEvents(Event.MOUSEDOWN); - document.lay1.onmousedown = function(event) { - var point = new Point(event); - - if ((att[4] != "") && (att[4] != "0/0")) { - att[4] += ";"; - } else { - att[4] = ""; - } - - att[4] += point.relX + "/" + point.relY; - - document.lay1.releaseEvents(Event.MOUSEDOWN); - setMarks(); - } -} - - -function zoomArea() { - var state = 0; - var pt1, pt2; - - function click(event) { - - if (state == 0) { - state = 1; - - pt1 = new Point(event); - pt2 = pt1; - - document.eck1.moveTo(pt1.pageX, pt1.pageY); - document.eck2.moveTo(pt2.pageX-12, pt1.pageY); - document.eck3.moveTo(pt1.pageX, pt2.pageY-12); - document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12); - - document.eck1.visibility="show"; - document.eck2.visibility="show"; - document.eck3.visibility="show"; - document.eck4.visibility="show"; - - document.lay1.captureEvents(Event.MOUSEMOVE); - document.eck4.captureEvents(Event.MOUSEMOVE); - - document.lay1.onmousemove = move; - document.eck4.onmousemove = move; - - } else { - - pt2 = new Point(event); - - document.lay1.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE); - document.eck4.releaseEvents(Event.MOUSEDOWN | Event.MOUSEMOVE); - - document.eck1.visibility="hide"; - document.eck2.visibility="hide"; - document.eck3.visibility="hide"; - document.eck4.visibility="hide"; - - att[5] = Math.min(pt1.relX, pt2.relX); - att[6] = Math.min(pt1.relY, pt2.relY); - - att[7] = Math.abs(pt1.relX-pt2.relX); - att[8] = Math.abs(pt1.relY-pt2.relY); - - if (att[7] != 0 && att[8] != 0) { - loadPicture(2); - } - } - } - - function move(event) { - - pt2 = new Point(event); - - document.eck1.moveTo(((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX), ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY)); - document.eck2.moveTo(((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12, ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY)); - document.eck3.moveTo(((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX), ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12); - document.eck4.moveTo(((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12, ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12); - } - - document.lay1.captureEvents(Event.MOUSEDOWN); - document.eck4.captureEvents(Event.MOUSEDOWN); - - document.lay1.onmousedown = click; - document.eck4.onmousedown = click; -} - - -function zoomPoint() { - - document.lay1.captureEvents(Event.MOUSEDOWN); - document.lay1.onmousedown = function(event) { - var point = new Point(event); - - att[5] = cropFloat(point.relX-0.5*att[7]*0.7); - att[6] = cropFloat(point.relY-0.5*att[8]*0.7); - - att[7] = cropFloat(att[7]*0.7); - att[8] = cropFloat(att[8]*0.7); - - if (att[5] < 0) { - att[5] = 0; - } - if (att[6] < 0) { - att[6] = 0; - } - if (att[5]+att[7] > 1) { - att[5] = 1-att[7]; - } - if (att[6]+att[8] > 1) { - att[6] = 1-att[8]; - } - - releaseEvents(Event.MOUSEDOWN); - - loadPicture(2); - } -} - - -function zoomOut() { - loadPicture(1); -} - - -function moveTo() { - - document.lay1.captureEvents(Event.MOUSEDOWN); - document.lay1.onmousedown = function(event) { - var point = new Point(event); - - att[5] = cropFloat(point.relX-0.5*att[7]); - att[6] = cropFloat(point.relY-0.5*att[8]); - - if (att[5] < 0) { - att[5] = 0; - } - if (att[6] < 0) { - att[6] = 0; - } - if (att[5]+att[7] > 1) { - att[5] = 1-att[7]; - } - if (att[6]+att[8] > 1) { - att[6] = 1-att[8]; - } - - releaseEvents(Event.MOUSEDOWN); - - loadPicture(2); - } -} - - -function scale(scaledef) { - - att[2] = scaledef; - loadPicture(2); -} - - -function setMarks() { - if ((att[4] != "") && (att[4] != "0/0")) { - var mark = att[4].split(";"); - - var countMarks = mark.length; - - // maximum of marks is 8 - // we do not report this error because this is already done in func. "Mark" - if (countMarks > 8) countMarks = 8; - - var picWidth = document.lay1.clip.width; - var picHeight = document.lay1.clip.height; - - for (var i = 0; i < countMarks; i++) { - mark[i] = mark[i].split("/"); - - if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) { - - mark[i][0] = parseInt(document.lay1.x + (picWidth*(mark[i][0]-att[5]))/att[7]); - mark[i][1] = parseInt(document.lay1.y + (picHeight*(mark[i][1]-att[6]))/att[8]); - - document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5); - document.layers[i+1].visibility = "show"; - } - } - } -} - - -// capturing keypresses for next and previous page -function parseKeypress(event) { - var whichCode = (window.Event) ? event.which : event.keyCode; - if (String.fromCharCode(whichCode) == "n") { - nextPage(); - } - if (String.fromCharCode(whichCode) == "b") { - backPage(); - } -} - - -// auxiliary function to crop senseless precicsion -function cropFloat(tmp) { - return parseInt(10000*tmp)/10000; -}
--- a/client/digitallibrary/navigation_n6.js Wed Jul 02 00:17:06 2003 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,420 +0,0 @@ -/* -Copyright (C) 2003 WTWG, Uni Bern - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - -Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 -*/ -// this global variable has to be initialised before the frist use of the functions below -// to fill in the attributes you can use the function init provided below -// - array with all attributes -var att = new Object(); - -// fill in the values of the "att"-array -function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { - - // debug window to check the parameters passed - //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh); - - // attaching the values to the att-array - att.fn = fn; - att.pn = parseInt(pn); - att.ws = parseFloat(ws); - att.mo = mo; - att.mk = mk; - att.wx = parseFloat(wx); - att.wy = parseFloat(wy); - att.ww = parseFloat(ww); - att.wh = parseFloat(wh); - - // compatablility issue -// dangerous at the time - lugi -// if (att.mo.indexOf("f") > -1) { -// att.mo = "fit"; -// } - - // converts the old mark format (0-1000) to new format(0.0 - 1.0) - // could even be useless now - if (att.mk != "0/0" && att.mk != "") { - var tmp = att.mk.split(";"); - - att.mk = ""; - - for (i = 0; i < tmp.length; i++) { - tmp[i] = tmp[i].split("/"); - - if (tmp[i][0] > 1 && tmp[i][1] > 1) { - tmp[i][0] /= 1000; - tmp[i][1] /= 1000; - } - - att.mk += tmp[i][0] + "/" + tmp[i][1] + ";"; - } - att.mk = att.mk.slice(0, -1); - } - - // initialisation stuff - // ==================== - - setMarks(); - - this.document.addEventListener('keypress', parseKeypress, true); - focus(); - - // give a name to the window containing digilib - this way one can test if there is already a - // digilib-window open and replace the contents of it (ex. digicat) - top.window.name = "digilib"; -} - - -// function that launches the ScaleServlet -// the different detailGrades: -// 0 -> back, next, page -// 1 -> zoomout -// 2 -> zoomarea, zoompoint, moveto, scaledef - -function loadPicture(detailGrade, keepArea) { - - var newQuery = "fn=" + att.fn + "&pn=" + att.pn + "&ws=" + att.ws + "&mo=" + att.mo; - - if (detailGrade == 0) { - att.mk = "0/0"; - } - - if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { - att.wx = 0; - att.wy = 0; - att.ww = 1; - att.wh = 1; - } - - newQuery += "&mk=" + att.mk + "&wx=" + att.wx + "&wy=" + att.wy + "&ww=" + att.ww + "&wh=" + att.wh; - newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); - newQuery += "&lv=1" - - // debug window - checking the parameters passed to the next image - alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); - - location.href = location.protocol + "//" + location.host + location.pathname + "?" + newQuery; -} - - -// constructor holding different values of a point -function Point(event) { - - this.pageX = parseInt(event.pageX); - this.pageY = parseInt(event.pageY); - - this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); - this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); - - this.relX = cropFloat(att.wx+(att.ww*this.x/document.pic.offsetWidth)); - this.relY = cropFloat(att.wy+(att.wh*this.y/document.pic.offsetHeight)); - - return this; -} - - -function backPage(keepArea) { - - att.pn = parseInt(att.pn) - 1; - - if (att.pn > 0) { - loadPicture(0, keepArea); - } else { - att.pn = parseInt(att.pn) + 1; - alert("You are already on the first page!"); - } -} - - -function nextPage(keepArea) { - - att.pn = parseInt(att.pn) + 1; - - loadPicture(0, keepArea); -} - - -function page(keepArea) { - - do { - page = prompt("Goto Page:", 1); - } while ((page != null) && (page < 1)); - - if (page != null && page != att.pn) { - att.pn = page; - loadPicture(0, keepArea); - } -} - - -function digicat() { - var url = baseUrl + "/digicat.jsp?" + att.fn + "+" + att.pn; - win = window.open(url, "digicat"); - win.focus(); -} - - -function ref(refselect) { - - var hyperlinkRef = baseUrl + "/digilib.jsp?"; - hyperlinkRef += att.fn + "+" + att.pn + "+" + att.ws + "+" + att.mo + "+" + att.mk; - - if ((att.wx != 0) || (att.wy != 0) || (att.ww != 1) || (att.wh != 1)) { - hyperlinkRef += "+" + att.wx + "+" + att.wy + "+" + att.ww + "+" + att.wh; - } - - if (refselect == 1) { - prompt("Link for HTML--documents", hyperlinkRef); - } else { - prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); - } -} - - -function mark() { - - if (att.mk.split(";").length > 7) { - alert("Only 8 marks are possible at the moment!"); - return; - } - - function markEvent(event) { - var point = new Point(event); - - if ((att.mk != "") && (att.mk != "0/0")) { - att.mk += ";"; - } else { - att.mk = ""; - } - att.mk += point.relX + "/" + point.relY; - - document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); - setMarks(); - } - - document.getElementById("lay1").addEventListener("mousedown", markEvent, true); -} - - -function zoomArea() { - var state = 0; - var pt1, pt2; - - function click(event) { - - if (state == 0) { - state = 1; - - pt1 = new Point(event); - pt2 = pt1; - - document.getElementById("eck1").style.left = pt1.pageX; - document.getElementById("eck1").style.top = pt1.pageY; - document.getElementById("eck2").style.left = pt2.pageX-12; - document.getElementById("eck2").style.top = pt1.pageY; - document.getElementById("eck3").style.left = pt1.pageX; - document.getElementById("eck3").style.top = pt2.pageY-12; - document.getElementById("eck4").style.left = pt2.pageX-12; - document.getElementById("eck4").style.top = pt2.pageY-12; - - document.getElementById("eck1").style.visibility="visible"; - document.getElementById("eck2").style.visibility="visible"; - document.getElementById("eck3").style.visibility="visible"; - document.getElementById("eck4").style.visibility="visible"; - - document.getElementById("lay1").addEventListener("mousemove", move, true); - document.getElementById("eck4").addEventListener("mousemove", move, true); - - } else { - - pt2 = new Point(event); - - document.getElementById("lay1").removeEventListener("mousedown", click, true); - document.getElementById("eck4").removeEventListener("mousedown", click, true); - - document.getElementById("lay1").removeEventListener("mousemove", move, true); - document.getElementById("eck4").removeEventListener("mousemove", move, true); - - document.getElementById("eck1").style.visibility="hidden"; - document.getElementById("eck2").style.visibility="hidden"; - document.getElementById("eck3").style.visibility="hidden"; - document.getElementById("eck4").style.visibility="hidden"; - - att.wx = parseFloat(Math.min(pt1.relX, pt2.relX)); - att.wy = parseFloat(Math.min(pt1.relY, pt2.relY)); - - att.ww = parseFloat(Math.abs(pt1.relX-pt2.relX)); - att.wh = parseFloat(Math.abs(pt1.relY-pt2.relY)); - - if (att.ww != 0 && att.wh != 0) { - loadPicture(2); - } - } - } - - function move(event) { - - pt2 = new Point(event); - - document.getElementById("eck1").style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); - document.getElementById("eck1").style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); - document.getElementById("eck2").style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; - document.getElementById("eck2").style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); - document.getElementById("eck3").style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); - document.getElementById("eck3").style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; - document.getElementById("eck4").style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; - document.getElementById("eck4").style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; - } - - document.getElementById("lay1").addEventListener("mousedown", click, true); - document.getElementById("eck4").addEventListener("mousedown", click, true); -} - - -function zoomPoint() { - - function zoomPointEvent(event) { - var point = new Point(event); - - att.wx = cropFloat(point.relX-0.5*att.ww*0.7); - att.wy = cropFloat(point.relY-0.5*att.wh*0.7); - - att.ww = cropFloat(att.ww*0.7); - att.wh = cropFloat(att.wh*0.7); - - if (att.wx < 0) { - att.wx = 0; - } - if (att.wy < 0) { - att.wy = 0; - } - if (att.wx+att.ww > 1) { - att.wx = 1-att.ww; - } - if (att.wy+att.wh > 1) { - att.wy = 1-att.wh; - } - - document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); - - loadPicture(2); - } - - document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true); -} - - -function zoomOut() { - - loadPicture(1); -} - - -function moveTo() { - - function moveToEvent(event) { - - var point = new Point(event); - - att.wx = cropFloat(point.relX-0.5*att.ww); - att.wy = cropFloat(point.relY-0.5*att.wh); - - if (att.wx < 0) { - att.wx = 0; - } - if (att.wy < 0) { - att.wy = 0; - } - if (att.wx+att.ww > 1) { - att.wx = 1-att.ww; - } - if (att.wy+att.wh > 1) { - att.wy = 1-att.wh; - } - - document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); - - loadPicture(2); - } - - document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true); -} - - -function scale(scaledef) { - - att.ws = scaledef; - loadPicture(2); -} - - -function setMarks() { - - if (att.mk != "" && att.mk != "0/0") { - var mark = att.mk.split(";"); - - var countMarks = mark.length; - - // maximum of marks is 8 - // we do not report this error because this is already done in func. "Mark" - if (countMarks > 8) countMarks = 8; - - var picWidth = document.pic.offsetWidth; - var picHeight = document.pic.offsetHeight; - - // catch the cases where the picture had not been loaded already and - // make a timeout so that the coordinates are calculated with the real dimensions - if (document.pic.complete) { - var xoffset = parseInt(document.getElementById("lay1").style.left); - var yoffset = parseInt(document.getElementById("lay1").style.top); - - for (var i = 0; i < countMarks; i++) { - mark[i] = mark[i].split("/"); - - if ((mark[i][0] >= att.wx) && (mark[i][1] >= att.wy) && (mark[i][0] <= (att.wx+att.ww)) && (mark[i][1] <= (att.wy+att.wh))) { - - mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att.wx)/att.ww); - mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att.wy)/att.wh); - - - document.getElementById("dot" + i).style.left = mark[i][0]-5; - document.getElementById("dot" + i).style.top = mark[i][1]-5; - document.getElementById("dot" + i).style.visibility = "visible"; - } - } - } else { - setTimeout("setMarks()", 100); - } - } -} - -// capturing keypresses for next and previous page -// ascii-values of n = 110, b = 98 -function parseKeypress (event) { - if (event.charCode == 110) { - nextPage(); - } - if (event.charCode == 98) { - backPage(); - } -} - - -// auxiliary function to crop senseless precicsion -function cropFloat(tmp) { - return parseInt(10000*tmp)/10000; -}
--- a/client/digitallibrary/navigation_o6.js Wed Jul 02 00:17:06 2003 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,402 +0,0 @@ -// this global variable has to be initialised before the frist use of the functions below -// to fill in the attributes you can use the function init provided below -// - array with all attributes -var att = new Array(); - -// fill in the values of the "att"-array -function init(fn, pn, ws, mo, mk, wx, wy, ww, wh) { - - // debug window to check the parameters passed - //alert ("DEBUG message (parameters in init):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh); - - // attaching the values to the att-array - att[0] = fn; - att[1] = parseInt(pn); - att[2] = parseFloat(ws); - att[3] = mo; - att[4] = mk; - att[5] = parseFloat(wx); - att[6] = parseFloat(wy); - att[7] = parseFloat(ww); - att[8] = parseFloat(wh); - - // compatablility issue - if (att[3].indexOf("f") > -1) { - att[3] = "fit"; - } - - // converts the old mark format (0-1000) to new format(0.0 - 1.0) - // could even be useless now - if (att[4] != "0/0") { - var tmp = att[4].split(";"); - - att[4] = ""; - - for (i = 0; i < tmp.length; i++) { - tmp[i] = tmp[i].split("/"); - - if (tmp[i][0] > 1 && tmp[i][1] > 1) { - tmp[i][0] /= 1000; - tmp[i][1] /= 1000; - } - - att[4] += tmp[i][0] + "/" + tmp[i][1] + ";"; - } - att[4] = att[4].slice(0, -1); - } - - // initialisation stuff - // ==================== - - setMarks(); - - this.document.onkeypress = parseKeypress; - focus(); - - // give a name to the window containing digilib - this way one can test if there is already a - // digilib-window open and replace the contents of it (ex. digicat) - top.window.name = "digilib"; -} - - -// function that launches the ScaleServlet -// the different detailGrades: -// 0 -> back, next, page -// 1 -> zoomout -// 2 -> zoomarea, zoompoint, moveto, scaledef - -function loadPicture(detailGrade, keepArea) { - - var newQuery = "fn=" + att[0] + "&pn=" + att[1] + "&ws=" + att[2] + "&mo=" + att[3]; - - if (detailGrade == 0) { - att[4] = "0/0"; - } - - if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { - att[5] = 0; - att[6] = 0; - att[7] = 1; - att[8] = 1; - } - - newQuery += "&mk=" + att[4] + "&wx=" + att[5] + "&wy=" + att[6] + "&ww=" + att[7] + "&wh=" + att[8]; - newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); - - // debug window - checking the parameters passed to the next image - //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); - - location.href = location.pathname + "?" + newQuery; -} - - -// constructor holding different values of a point -function Point(event) { - - this.pageX = parseInt(event.clientX); - this.pageY = parseInt(event.clientY); - - this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); - this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); - - this.relX = cropFloat(att[5]+(att[7]*this.x/document.pic.offsetWidth)); - this.relY = cropFloat(att[6]+(att[8]*this.y/document.pic.offsetHeight)); - -// alert ("page:\t" + this.pageX + "\t" + this.pageY + "\npic:\t" + this.x + "\t" + this.y + "\nrel:\t" + this.relX + "\t" + this.relY); - - return this; -} - - -function backPage(keepArea) { - - att[1] = parseInt(att[1]) - 1; - - if (att[1] > 0) { - loadPicture(0, keepArea); - } else { - att[1] = parseInt(att[1]) + 1; - alert("You are already on the first page!"); - } -} - - -function nextPage(keepArea) { - - att[1] = parseInt(att[1]) + 1; - - loadPicture(0, keepArea); -} - - -function page(keepArea) { - - do { - page = prompt("Goto Page:", 1); - } while ((page != null) && (page < 1)); - - if (page != null && page != att[1]) { - att[1] = page; - loadPicture(0, keepArea); - } -} - - -function digicat() { - var url = "digicat.html?" + att[0] + "+" + att[1]; - win = window.open(url, "digicat"); - win.focus(); -} - - -function ref(refselect) { - - var hyperlinkRef = baseUrl + "digilib.jsp?"; - hyperlinkRef += att[0] + "+" + att[1] + "+" + att[2] + "+" + att[3] + "+" + att[4]; - - if ((att[5] != 0) || (att[6] != 0) || (att[7] != 1) || (att[8] != 1)) { - hyperlinkRef += "+" + att[5] + "+" + att[6] + "+" + att[7] + "+" + att[8]; - } - - if (refselect == 1) { - prompt("Link for HTML--documents", hyperlinkRef); - } else { - prompt("Link for LaTeX--documents", "\\href{" + hyperlinkRef + "}{TEXT}"); - } -} - - -function mark() { - - if (att[4].split(";").length > 7) { - alert("Only 8 marks are possible at the moment!"); - return; - } - - function markEvent(event) { - var point = new Point(event); - - if ((att[4] != "") && (att[4] != "0/0")) { - att[4] += ";"; - } else { - att[4] = ""; - } - att[4] += point.relX + "/" + point.relY; - - document.getElementById("lay1").onmousedown = false; - setMarks(); - } - - document.getElementById("lay1").onmousedown = markEvent; -} - - -function zoomArea() { - var state = 0; - var pt1, pt2; - - function click(event) { - - if (state == 0) { - state = 1; - - pt1 = new Point(event); - pt2 = pt1; - - document.getElementById("eck1").style.left = pt1.pageX; - document.getElementById("eck1").style.top = pt1.pageY; - document.getElementById("eck2").style.left = pt2.pageX-12; - document.getElementById("eck2").style.top = pt1.pageY; - document.getElementById("eck3").style.left = pt1.pageX; - document.getElementById("eck3").style.top = pt2.pageY-12; - document.getElementById("eck4").style.left = pt2.pageX-12; - document.getElementById("eck4").style.top = pt2.pageY-12; - - document.getElementById("eck1").style.visibility="visible"; - document.getElementById("eck2").style.visibility="visible"; - document.getElementById("eck3").style.visibility="visible"; - document.getElementById("eck4").style.visibility="visible"; - - document.getElementById("lay1").onmousemove = move; - document.getElementById("eck4").onmousemove = move; - - } else { - - pt2 = new Point(event); - - document.getElementById("lay1").onmousedown = false; - document.getElementById("eck4").onmousedown = false; - - document.getElementById("eck1").style.visibility="hidden"; - document.getElementById("eck2").style.visibility="hidden"; - document.getElementById("eck3").style.visibility="hidden"; - document.getElementById("eck4").style.visibility="hidden"; - - att[5] = Math.min(pt1.relX, pt2.relX); - att[6] = Math.min(pt1.relY, pt2.relY); - - att[7] = Math.abs(pt1.relX-pt2.relX); - att[8] = Math.abs(pt1.relY-pt2.relY); - - if (att[7] != 0 && att[8] != 0) { - loadPicture(2); - } - } - } - - function move(event) { - - pt2 = new Point(event); - - document.getElementById("eck1").style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); - document.getElementById("eck1").style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); - document.getElementById("eck2").style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; - document.getElementById("eck2").style.top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); - document.getElementById("eck3").style.left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); - document.getElementById("eck3").style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; - document.getElementById("eck4").style.left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; - document.getElementById("eck4").style.top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; - } - - document.getElementById("lay1").onmousedown = click; - document.getElementById("eck4").onmousedown = click; -} - - -function zoomPoint() { - - function zoomPointEvent(event) { - var point = new Point(event); - - att[5] = cropFloat(point.relX-0.5*att[7]*0.7); - att[6] = cropFloat(point.relY-0.5*att[8]*0.7); - - att[7] = cropFloat(att[7]*0.7); - att[8] = cropFloat(att[8]*0.7); - - if (att[5] < 0) { - att[5] = 0; - } - if (att[6] < 0) { - att[6] = 0; - } - if (att[5]+att[7] > 1) { - att[5] = 1-att[7]; - } - if (att[6]+att[8] > 1) { - att[6] = 1-att[8]; - } - - document.getElementById("lay1").onmousedown = false; - - loadPicture(2); - } - - document.getElementById("lay1").onmousedown = zoomPointEvent; -} - - -function zoomOut() { - - loadPicture(1); -} - - -function moveTo() { - - function moveToEvent(event) { - - var point = new Point(event); - - att[5] = cropFloat(point.relX-0.5*att[7]); - att[6] = cropFloat(point.relY-0.5*att[8]); - - if (att[5] < 0) { - att[5] = 0; - } - if (att[6] < 0) { - att[6] = 0; - } - if (att[5]+att[7] > 1) { - att[5] = 1-att[7]; - } - if (att[6]+att[8] > 1) { - att[6] = 1-att[8]; - } - - document.getElementById("lay1").onmousedown = false; - - loadPicture(2); - } - - document.getElementById("lay1").onmousedown = moveToEvent; -} - - -function scale(scaledef) { - - att[2] = scaledef; - loadPicture(2); -} - - -function setMarks() { - - if (att[4] != "" && att[4] != "0/0") { - var mark = att[4].split(";"); - - var countMarks = mark.length; - - // maximum of marks is 8 - // we do not report this error because this is already done in func. "Mark" - if (countMarks > 8) countMarks = 8; - - var picWidth = document.pic.offsetWidth; - var picHeight = document.pic.offsetHeight; - - // catch the cases where the picture had not been loaded already and - // make a timeout so that the coordinates are calculated with the real dimensions - if (document.pic.complete) { - var xoffset = parseInt(document.getElementById("lay1").style.left); - var yoffset = parseInt(document.getElementById("lay1").style.top); - - for (var i = 0; i < countMarks; i++) { - mark[i] = mark[i].split("/"); - - if ((mark[i][0] > att[5]) && (mark[i][1] > att[6]) && (mark[i][0] < (att[5]+att[7])) && (mark[i][1] < (att[6]+att[8]))) { - - mark[i][0] = parseInt(xoffset+picWidth*(mark[i][0]-att[5])/att[7]); - mark[i][1] = parseInt(yoffset+picHeight*(mark[i][1]-att[6])/att[8]); - - - document.getElementById("dot" + i).style.left = mark[i][0]-5; - document.getElementById("dot" + i).style.top = mark[i][1]-5; - document.getElementById("dot" + i).style.visibility = "visible"; - } - } - } else { - setTimeout("setMarks()", 100); - } - } -} - -// capturing keypresses for next and previous page -// ascii-values of n = 110, b = 98 -function parseKeypress (event) { - - if (String.fromCharCode(event.which) == "n") { - nextPage(); - } - - // does not work currently, because Opera catches this key on it's own - // have to change the key or find another way - luginbuehl - if (String.fromCharCode(event.which) == "b") { - backPage(); - } -} - - -// auxiliary function to crop senseless precicsion -function cropFloat(tmp) { - return parseInt(10000*tmp)/10000; -}