Mercurial > hg > digilib-old
changeset 135:68e88c3bc575
unified scripts, nice xul sidebar, bugfixes
author | luginbue |
---|---|
date | Tue, 08 Jul 2003 03:00:57 +0200 |
parents | 1a0496201c75 |
children | 829cab910c99 |
files | client/digitallibrary/modules/imago.js client/digitallibrary/modules/newReferences.js client/digitallibrary/xul/alcatraz.xpi client/digitallibrary/xul/install.html |
diffstat | 4 files changed, 478 insertions(+), 151 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/modules/imago.js Tue Jul 08 03:00:57 2003 +0200 +++ b/client/digitallibrary/modules/imago.js Tue Jul 08 03:00:57 2003 +0200 @@ -1,4 +1,5 @@ /* + Copyright (C) 2003 WTWG, Uni Bern This program is free software; you can redistribute it and/or @@ -8,90 +9,23 @@ 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 +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 -*/ -/**************************************************************************** - * - imago module for digilib * - * * - * adds brightness and color manipulation to digilib * - * * - * christian luginbuehl (luginbuehl@student.unibe.ch) * - ****************************************************************************/ - -// overriding (some kind of inheriting) init in navigation_XX.js -function init_imago(pu, pn, ws, mo, mk, wx, wy, ww, wh, pt, brgt, cont, rot, rgba, rgbm) { - - // debug window to check the parameters passed - //alert ("DEBUG message (parameters in init imago.js):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh + "\npt = " + pt + "\nbrgt = " + brgt + "\ncont = " + cont + "\nrot = " + rot + "\nrgba = " + rgba + "\nrgbm = " + rgbm); - - // calling original init - init_pagesTotal(pu, pn, ws, mo, mk, wx, wy, ww, wh, pt); +Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4 - att.brgt = parseInt(brgt); - att.cont = parseFloat(cont); - att.rot = parseFloat(rot); - att.rgba = rgba; - att.rgbm = rgbm; - - focus(); -} - - -/** - * overriding 'loadPicture' in navigation - */ -function loadPicture(detailGrade, keepArea) { - - // the different detailGrades: - // 0 -> back, next, page - // 1 -> zoomout - // 2 -> zoomarea, zoompoint, moveto, scaledef +*/ - var newQuery = "fn=" + att.fn + "&pn=" + att.pn + "&ws=" + att.ws + "&mo=" + att.mo; - - if (detailGrade == 0) { - att.mk = "0/0"; - att.brgt = 0; - att.cont = 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; - - if (navigator.appName.toLowerCase() == "netscape") { // mozilla-browsers (netscape 4.xx, netscape 6.xx, etc.) - newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); - } else { // ie, opera - newQuery += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); - } - - newQuery += "&pt=" + att.pt; - - newQuery += "&brgt=" + att.brgt; - newQuery += "&cont=" + att.cont; - newQuery += "&rot=" + att.rot; - newQuery += "&rgba=" + att.rgba; - newQuery += "&rgbm=" + att.rgbm; - - newQuery += "&lv=1"; - - // debug window - checking the parameters passed to the next image - //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); - //alert(location.host + ":" + location.port + location.pathname); - location.href = location.protocol + "//" + location.host + location.pathname + "?" + newQuery; -} +/************************************************************************* + * imago.js : digilib-module * + * * + * desc: adds different image manipulation functions. * + * * + *************************************************************************/ /** @@ -99,47 +33,87 @@ */ function brightness(value) { - if ((value < -255) || (value > 255)) { - - alert ("Illegal brightness value (-255 to +255)"); + if ( (value >= -255) && (value <= 255) ) { - } else { - - att.brgt = value; + dlParams.brgt.value = value; + display(3); - loadPicture(2); } } + /** * contrast (value of contrast - range?) */ function contrast(value) { - att.cont = parseFloat(value); + dlParams.cont.value = parseFloat(value); + display(3); + +} + - loadPicture(2); +/** + * brightness/contrast in one call + */ +function brightnessContrast(brightness, contrast) { + + dlParams.cont.value = parseFloat(contrast); + + if ( (brightness >= -255) && (brightness <= 255) ) { + + dlParams.brgt.value = parseFloat(brightness); + display(3); + + } } + /** - * rotation (value from 0 to 360 degrees) + * mirror (horizontal or vertical) + */ +function mirror(direction) { + + if ( direction == 'v' ) { + if ( dlParams.mo.value.indexOf('vmir') > -1 ) { + removeMoFlag('vmir'); + } else { + addMoFlag('vmir'); + } + } + + if ( direction == 'h' ) { + if ( dlParams.mo.value.indexOf('hmir') > -1 ) { + removeMoFlag('hmir'); + } else { + addMoFlag('hmir'); + } + } + + display(3); + +} + + +/** + * rotation */ function rotation(value) { value = parseFloat(value) % 360; - if (value < 0) { + if ( value < 0 ) { value += 360; } - att.rot = value; - - loadPicture(2); + dlParams.rot.value = value; + display(3); } + /** * rgb add (r/g/b, each value from -255 to +255) */ @@ -147,35 +121,321 @@ values = value.split("/"); - if (values.length != 3) { + if ( values.length != 3 ) { alert ("Illegal parameter format (r/g/b)"); - } else if ((values[0] < -255) || (values[0] > 255)) { + } else if ( (values[0] < -255) || (values[0] > 255) ) { alert ("Illegal red additioner (-255 to 255)"); - } else if ((values[1] < -255) || (values[1] > 255)) { + } else if ( (values[1] < -255) || (values[1] > 255) ) { alert ("Illegal green additioner (-255 to 255)"); - } else if ((values[2] < -255) || (values[2] > 255)) { + } else if ( (values[2] < -255) || (values[2] > 255) ) { alert ("Illegal blue additioner (-255 to 255)"); } else { - att.rgba = value; - loadPicture(2); + dlParams.rgba.value = value; + display(3); } } + /** - * rgb multiply (r/g/b, each value from ??? ) + * rgb mutiply (r/g/b, range?) */ function rgbm(value) { values = value.split("/"); - if (values.length != 3) { + if ( values.length != 3 ) { alert ("Illegal parameter format (r/g/b)"); + } else if ( !isFinite(values[0]) ) { + alert ("Illegal red exponent"); + } else if ( !isFinite(values[1]) ) { + alert ("Illegal green exponent"); + } else if ( !isFinite(values[2]) ) { + alert ("Illegal blue exponent"); } else { - att.rgbm = value; - loadPicture(2); + dlParams.rgbm.value = value; + display(3); + + } +} + + +/** + * rgba/rgbm in one call + */ +function colors(rgba, rgbm) { + + add = rgba.split("/"); + mult = rgba.split("/"); + + if ( (add.length) == 3 && (mult.length == 3) && + (add[0] >= -255) && (add[0] <= 255) && + (add[1] >= -255) && (add[1] <= 255) && + (add[2] >= -255) && (add[2] <= 255) && + (isFinite(mult[0])) && + (isFinite(mult[1])) && + (isFinite(mult[2])) ) { + + dlParams.rgba.value = rgba; + dlParams.rgbm.value = rgbm; + + display(3); } } + + +/** + * pixel by pixel view of images + */ +function pixelByPixel() { + + removeMoFlag('osize'); + + addMoFlag('clip'); + + // change scale to 1 + dlParams.ws.value = 1.0; + + display(3); + +} + + +/** + * original size view of images + */ +function originalSize(dpi_v, dpi_h) { + + removeMoFlag('clip'); + + addMoFlag('osize'); + + // change scale to 1 + dlParams.ws.value = 1.0; + + dlParams.ddpix.value = dpi_h; + dlParams.ddpiy.value = dpi_v; + + display(3); + +} + + +/** + * scale (overriding old one) + * as pixel by pixel is some kind of scale, it does turn scale factor to 1 + * if chosen. also if a scale factor is chosen, + * then pixel by pixel is turned off. + */ +function scale(factor) { + + dlParams.ws.value = factor; + + removeMoFlag('clip'); + removeMoFlag('osize'); + + display(3); + +} + + +/** + * placeMarks (overriding old one) + * take care of rotation and mirroring when placing marks + */ +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.lay1.clip.width); + var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.lay1.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 ( (picWidth > 30) || (document.pic.complete) ) { + + 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 ( (parseFloat(mark[i][0]) >= parseFloat(dlParams.wx.value)) && + (parseFloat(mark[i][1]) >= parseFloat(dlParams.wy.value)) && + (parseFloat(mark[i][0]) <= (parseFloat(dlParams.wx.value) + parseFloat(dlParams.ww.value))) && + (parseFloat(mark[i][1]) <= (parseFloat(dlParams.wy.value) + parseFloat(dlParams.wh.value))) ) { + + mark[i][0] = (mark[i][0] - dlParams.wx.value)/dlParams.ww.value; + mark[i][1] = (mark[i][1] - dlParams.wy.value)/dlParams.wh.value; + + // mirror + if ( dlParams.mo.value.indexOf('hmir') > -1 ) { + mark[i][0] = 1 - mark[i][0]; + } + if ( dlParams.mo.value.indexOf('vmir') > -1 ) { + mark[i][1] = 1 - mark[i][1]; + } + + // just the beginning - not working currently + var ang_rad = dlParams.rot.value*2*3.1415926/360; + + var ws = Math.sin(ang_rad)/(Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.sin(ang_rad)) * picWidth; + var wc = (Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value)/(Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.sin(ang_rad)) * picWidth; + + var hs = (Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value)/(Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.cos(ang_rad)) * picHeight; + var hc = Math.cos(ang_rad)/(Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.cos(ang_rad)) * picHeight; + + var origPicWidth = Math.sqrt(Math.pow(wc, 2) + Math.pow(hs, 2)); + var origPicHeight = Math.sqrt(Math.pow(ws, 2) + Math.pow(hc, 2)); + // end of the beginning ;-) + + mark[i][0] = parseInt(xOffset + picWidth * mark[i][0]); + mark[i][1] = parseInt(yOffset + picHeight * mark[i][1]); + + 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); + } + } +} + + +/**** + * helper functions + ****/ + +/** + * Point (overriding old one) + * constructor holding different values of a point + * depending also on mirror or rotation + */ +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); + + // mirror + if ( dlParams.mo.value.indexOf('hmir') > -1 ) { + this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); + } else { + this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); + } + if ( dlParams.mo.value.indexOf('vmir') > -1 ) { + this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); + } else { + 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); + + // mirror + if ( dlParams.mo.value.indexOf('hmir') > -1 ) { + this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.pic.offsetWidth)); + } else { + this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth)); + } + if ( dlParams.mo.value.indexOf('vmir') > -1 ) { + this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.pic.offsetHeight)); + } else { + 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; + + // mirror + if ( dlParams.mo.value.indexOf('hmir') > -1 ) { + this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.lay1.clip.width)); + } else { + this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width)); + } + if ( dlParams.mo.value.indexOf('vmir') > -1 ) { + this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.lay1.clip.height)); + } else { + this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height)); + } + + } + + } + + return this; + +} + + +/** + * removeMoFlag from mo parameter + */ +function removeMoFlag(name) { + + if ( dlParams.mo.value != '' ) { + + var idx_comma_after = dlParams.mo.value.indexOf(name + ','); + var idx_comma_before = dlParams.mo.value.indexOf(',' + name); + var idx_nocomma = dlParams.mo.value.indexOf(name); + + if ( idx_comma_after > -1 ) { + dlParams.mo.value = dlParams.mo.value.slice(0, idx_comma_after) + dlParams.mo.value.slice(idx_comma_after+name.length+1); + }else if ( idx_comma_before > -1 ) { + dlParams.mo.value = dlParams.mo.value.slice(0, idx_comma_before) + dlParams.mo.value.slice(idx_comma_before+name.length+1); + } else if ( idx_nocomma > -1 ) { + dlParams.mo.value = dlParams.mo.value.slice(0, idx_nocomma) + dlParams.mo.value.slice(idx_nocomma+name.length); + } + } + +} + + +/** + * addMoFlag from mo parameter + */ +function addMoFlag(name) { + + if ( dlParams.mo.value.indexOf(name) == -1 ) { + + if ( dlParams.mo.value.length > 0 ) { + dlParams.mo.value += ',' + name; + } else { + dlParams.mo.value = name; + } + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/digitallibrary/modules/newReferences.js Tue Jul 08 03:00:57 2003 +0200 @@ -0,0 +1,78 @@ +/* + +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, 22.05.2003 , Version Alcatraz 0.4 + +*/ + +/************************************************************************* + * newReferences.js : digilib-module * + * * + * desc: creates references in the new parameter format (key-value) * + * * + *************************************************************************/ + + +/** + * ref, overriding original one + */ +function ref(select) { + + var hyperlinkRef = baseUrl + "/digilib.jsp?"; + + if ( select == 2 ) { + + // no original size is referenced at the moment, + // because the dpi values are not constant from user to user + removeMoFlag('osize'); + + var parameterString = ''; + + for ( param in dlParams ) { + if ( (dlParams[param].detail < 9) && (dlParams[param].defaultValue != dlParams[param].value) ) { + parameterString += "&" + param + "=" + dlParams[param].value; + } + } + + parameterString += "&lv=3"; // level three + + parameterString = parameterString.slice(1); + + prompt("Alcatraz-style HTML link", hyperlinkRef + parameterString); + + } else { + + var parameterString = ''; + + parameterString += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+"; + parameterString += dlParams.mo.value + "+" + dlParams.mk.value; + + if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) { + parameterString += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value; + parameterString += "+" + dlParams.wh.value; + } + + if ( select == 1 ) { + prompt("Link for HTML-documents", hyperlinkRef+ parameterString); + } + + if ( select == 0 ) { + prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + parameterString + "}{TEXT}"); + } + } +}
--- a/client/digitallibrary/xul/install.html Tue Jul 08 03:00:57 2003 +0200 +++ b/client/digitallibrary/xul/install.html Tue Jul 08 03:00:57 2003 +0200 @@ -1,58 +1,47 @@ <html> - <head> - <title>Alcatraz XUL Package</title> - <script type="text/javascript"> - <!-- - function doneFn ( name , result ){ - if (result) { - //alert("An error occured: " + result); - } - } +<head> + +<title>Install Alcatraz</title> + +<script type="application/x-javascript"> + +function install() { + InstallTrigger.install ( {'alcatraz' : 'alcatraz.xpi'} ); +} - function installXPI(xpiname){ - var xpi = new Object(); - xpi[xpiname] = xpiname; - InstallTrigger.install(xpi,doneFn); - } +</script> + +</head> +<body> - function addSidebarPanel(name, url) { - if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) - { - window.sidebar.addPanel (name,url,""); - } - else - { - alert ("To use this functionality a Netscape 6+ or Mozilla browser is needed !"); - } - } +<h3>Alcatraz XUL Package</h3> +<p>contains only DIGILIB-Buttons at the moment</p> +<h4>Installation:</h4> +<p>(maybe it is a good idea to print this side or to set a bookmark because you will have to close the browser during the installation)</p> +<ol> - //--> - </script> - </head> - <body> - <h3>Alcatraz XUL Package</h3> - <p>contains only DIGILIB-Buttons at the moment</p> - <h4>Installation:</h4> - <p>(maybe it is a good idea to print this side or to set a bookmark because you will have to close the browser during the installation)</p> - <ol> - <li>be sure to proceed with the installation with appropriate rights to write in mozilla/chrome directory (windows: administrator; unix: root)</li> - <li> - press the "install alcatraz" button<br><br> - <form> - <input type="button" name="install alcatraz" value="install alcatraz" onClick="installXPI('alcatraz.xpi');"><br> - </form> - (this button installs alcatraz.jar in mozillas chrome directory, alcatraz.jar must be readable for any user who uses alcatraz components)<br> - </li> - <li>restart mozilla</li> - <li> - enter chrome://alcatraz/content/sidebar/install.xul in the input field of the URL bar - </li> - <li> - a dialog is asking you to install the DIGILIB-Buttons, press the button - </li> - </ol> - <hr> - <address><a href="mailto:engler@philo.unibe.ch">Daniel Engler</a></address> + <li>be sure to proceed with the installation with appropriate rights to write in mozilla/chrome directory (windows: administrator; unix: root)</li> + + <li> + press the "install alcatraz" button<br><br> + <form> + <input type="button" name="install alcatraz" value="install alcatraz" onClick="install();"><br> + </form> + (this button installs alcatraz.jar in mozillas chrome directory, alcatraz.jar must be readable for any user who uses alcatraz components)<br> + </li> + + <li>restart mozilla</li> + + <li>enter chrome://alcatraz/content/sidebar/install.xul in the input field of the URL bar</li> + + <li>a dialog is asking you to install the Alcatraz-Sidebar, open the Sidebar (F9) and press the button</li> + +</ol> + +<hr> + +<address><a href="mailto:engler@philo.unibe.ch">Daniel Engler</a></address> +<address><a href="mailto:luginbuehl@student.unibe.ch">Christian Luginbuehl</a></address> <!-- Created: Mon May 12 19:44:41 CEST 2003 --> <!-- hhmts start --> Last modified: Tue May 13 20:17:00 CEST 2003