Annotation of zogiLib/js/navigation.js, revision 1.2

1.1       dwinter     1: /*
                      2: 
                      3: Copyright (C) 2003 WTWG, Uni Bern
                      4:  
                      5: This program is free software; you can redistribute it and/or
                      6: modify it under the terms of the GNU General Public License
                      7: as published by the Free Software Foundation; either version 2
                      8: of the License, or (at your option) any later version.
                      9:  
                     10: This program is distributed in the hope that it will be useful,
                     11: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     13: GNU General Public License for more details.
                     14:  
                     15: You should have received a copy of the GNU General Public License
                     16: along with this program; if not, write to the Free Software
                     17: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
                     18:  
                     19: Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.4
                     20: Changed for digiLib in Zope by DW 24.03.2004 
                     21: */
                     22: 
                     23: var ZOOMFACTOR = Math.sqrt(2);
                     24: 
                     25: dlParams = new Object();
                     26: 
                     27: function newParameter(name, value, defaultValue, detail) {
                     28: 
                     29:   if ( !dlParams[name] ) {
                     30: 
                     31:     dlParams[name] = new Object();
                     32: 
                     33:     dlParams[name].value        = value;
                     34:     dlParams[name].defaultValue = defaultValue;
                     35:     dlParams[name].detail       = detail;
                     36: 
                     37:     return dlParams[name];
                     38: 
                     39:   } else {
                     40: 
                     41:     alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!");
                     42:     return false;
                     43: 
                     44:   }
                     45: }
                     46: 
                     47: function getParameter(name) {
                     48: 
                     49:   if ( dlParams[name] ) {
                     50:     return dlParams[name].value;
                     51:   } else {
                     52:     return false;
                     53:   }
                     54: }
                     55: 
                     56: 
                     57: 
                     58: function listParametersAsString() {
                     59: 
                     60:   var params = new Array();
                     61: 
                     62:   for ( param in dlParams ) {
                     63:     params.push(param);
                     64:   }
                     65: 
                     66:   return params.join(",");
                     67: 
                     68: }
                     69: 
                     70: 
                     71: function listParameters() {
                     72: 
                     73:   var params = new Array();
                     74: 
                     75:   for ( param in dlParams ) {
                     76:     params.push(param);
                     77:   }
                     78: 
                     79:   return params;
                     80: 
                     81: }
                     82: 
                     83: 
                     84: function init() {
                     85: 
                     86:   // give a name to the window containing digilib - this way one can test if there is already a
                     87:   // digilib-window open and replace the contents of it (ex. digicat)
                     88:   top.window.name = "digilib";
                     89: 
                     90: 
                     91:   placeMarks();
                     92: 
                     93:   if ( document.all ) {
                     94:     this.document.onkeypress = parseKeypress;
                     95:   } else if ( typeof(document.addEventListener) == "function" ) {
                     96:     this.document.addEventListener('keypress', parseKeypress, true);
                     97:   } else {
                     98:     window.captureEvents(Event.KEYDOWN);
                     99:     window.onkeydown = parseKeypress;
                    100:   }
                    101:   
                    102:   focus();
                    103: }
                    104: 
                    105: 
                    106: function display(detail) {
                    107: 
                    108:   var queryString = '';
                    109: 
                    110:   for ( param in dlParams ) {
                    111: 
                    112:     if ( dlParams[param].defaultValue != dlParams[param].value ) {
                    113:       if ( dlParams[param].detail <= detail ) {
                    114:         queryString += "&" + param + "=" + dlParams[param].value;
                    115:       } else {
                    116:         queryString += "&" + param + "=" + dlParams[param].defaultValue;
                    117:       }
                    118:     }
                    119: 
                    120:   }
                    121: 
                    122:   // window size
                    123:   var wwidth, wheight;
                    124:   if (self.innerHeight) // all except Explorer
                    125:   {
                    126:       wwidth = self.innerWidth;
                    127:       wheight = self.innerHeight;
                    128:   }
                    129:   else if (document.documentElement && document.documentElement.clientHeight)
                    130:   // Explorer 6 Strict Mode
                    131:   {
                    132:       wwidth = document.documentElement.clientWidth;
                    133:       wheight = document.documentElement.clientHeight;
                    134:   }
                    135:   else if (document.body) // other Explorers
                    136:   {
                    137:       wwidth = document.body.clientWidth;
                    138:       wheight = document.body.clientHeight;
                    139:   }
                    140:   //queryString += "&dw=" + (wwidth-30) + "&dh=" + (wheight-30);   # not needed DW
                    141: 
                    142:   queryString += "&lv=1";
                    143: 
                    144:   queryString = queryString.slice(1);
                    145: 
                    146:   location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString;
                    147: 
                    148: }
                    149: 
                    150: 
                    151: // constructor holding different values of a point
                    152: function Point(evt) {
                    153: 
                    154:    if ( document.all ) {
                    155: 
                    156:     this.pageX = parseInt(document.body.scrollLeft+event.clientX);
                    157:     this.pageY = parseInt(document.body.scrollLeft+event.clientY);
                    158: 
                    159:     this.x = this.pageX-parseInt(document.all.scaler.offsetLeft);
                    160:     this.y = this.pageY-parseInt(document.all.scaler.offsetTop);
                    161: 
                    162:     this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.scaler.offsetWidth));
                    163:     this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.scaler.offsetHeight));
                    164:     
                    165:    } else {
                    166: 
                    167:     this.pageX = parseInt(evt.pageX);
                    168:     this.pageY = parseInt(evt.pageY);
                    169: 
                    170:      if ( typeof(document.getElementById) == "function" ) {
                    171:       
                    172:       this.x = this.pageX-parseInt(document.getElementById("scaler").offsetLeft);
                    173:       this.y = this.pageY-parseInt(document.getElementById("scaler").offsetTop);
                    174:       // top("2"+"::"+this.pageX+"::"+parseInt(document.getElementById("scaler").offsetLeft)+'::'+document.getElementById("scaler").offsetLeft);
                    175:       this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth));
                    176:       this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight));
                    177:       
                    178:     } else {
                    179: 
                    180:       this.x = this.pageX-document.scaler.left;
                    181:       this.y = this.pageY-document.scaler.top;
                    182: 
                    183:       this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.scaler.clip.width));
                    184:       this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.scaler.clip.height));
                    185:       
                    186:     }
                    187: 
                    188:   }
                    189: 
                    190:   return this;
                    191: 
                    192: }
                    193: 
                    194: 
                    195: function page(page, details) {
                    196: 
                    197:   if ( details == null ) {
                    198:     details = 1;
                    199:   }
                    200:   
                    201:   if ( page.indexOf('-') == 0 ) {
                    202:     if ( dlParams.pn.value > 1 ) {
                    203:       page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1);
                    204:       dlParams.pn.value = page;
                    205:       display(details);
                    206:     } else {
                    207:       alert("You are already on the first page!");
                    208:     }
                    209: 
                    210:   } else if ( page.indexOf('+') == 0 ) {
                    211:     page = parseInt(dlParams.pn.value) + parseInt(page.slice(1));
                    212:     dlParams.pn.value = page;
                    213:     display(details);
                    214:   } else if ( page == parseInt(page) ) {
                    215:     dlParams.pn.value = parseInt(page);
                    216:     display(details);
                    217:   }
                    218: 
                    219: }
                    220: 
                    221: 
                    222: function digicat() {
                    223: 
                    224:   var url = baseUrl + "/digicat.jsp?" + dlParams.fn.value + "+" + dlParams.pn.value;
                    225:   win = window.open(url, "digicat");
                    226:   win.focus();
                    227: 
                    228: }
                    229: 
                    230: 
                    231: function ref(select) {
                    232: 
                    233:    var hyperlinkRef = baseUrl + "?";
                    234:    hyperlinkRef += "fn="+dlParams.fn.value + "&pn=" + dlParams.pn.value + "&ws=" + dlParams.ws.value + "&mo=";
                    235:    hyperlinkRef += dlParams.mo.value + "&mk=" + dlParams.mk.value;
                    236:    
                    237:    if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) {
                    238:        hyperlinkRef += "&wx=" + dlParams.wx.value + "&wy=" + dlParams.wy.value + "&ww=" + dlParams.ww.value;
                    239:        hyperlinkRef += "&wh=" + dlParams.wh.value;
                    240:    }
                    241: 
                    242:    if ( select == 0 ) {
                    243:        prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + "}{TEXT}");
                    244:    } else if ( select == 1 ) {
                    245:        prompt("Link for HTML-documents", hyperlinkRef);
                    246:    }
                    247: }
                    248: 
                    249: 
                    250: function mark() {
                    251: 
                    252:    if ( dlParams.mk.value.split(";").length > 7 ) {
                    253:        alert("Only 8 marks are possible at the moment!");
                    254:        return;
                    255:    }
                    256: 
                    257:    function markEvent(evt) {
                    258: 
                    259:     var point = new Point(evt);
                    260: 
                    261:        if ( dlParams.mk.value != '' ) {
                    262:            dlParams.mk.value += ';';
                    263:        }
                    264: 
                    265:        dlParams.mk.value += point.relX + '/' + point.relY;
                    266: 
                    267:     // stopping event capture
                    268:    if ( document.all ) {
                    269:      document.all.scaler.onmousedown = null;
                    270:    } else if ( typeof(document.removeEventListener) == "function" ) {
                    271:       document.getElementById("scaler").removeEventListener("mousedown", markEvent, true);
                    272:     } else {
                    273:       document.scaler.releaseEvents(Event.MOUSEDOWN);
                    274:     }
                    275: 
                    276:     placeMarks();
                    277: 
                    278:    }
                    279: 
                    280:   // starting event capture
                    281:    if ( document.all ) {
                    282:      document.all.scaler.onmousedown = markEvent;
                    283:    } else if ( typeof(document.addEventListener) == "function" ) {
                    284:     document.getElementById("scaler").addEventListener("mousedown", markEvent, true);
                    285:   } else {
                    286:     document.scaler.captureEvents(Event.MOUSEDOWN);
                    287:     document.scaler.onmousedown = markEvent;
                    288:   }
                    289: }
                    290: 
                    291: 
                    292: function placeMarks() {
                    293: 
                    294:    if ( dlParams.mk.value != '' ) {
                    295: 
                    296:        var mark = dlParams.mk.value.split(";");
                    297:        var mark_count = mark.length;
                    298: 
                    299:        // maximum of marks is 8
                    300:        // we do not report this error because this is already done in function 'mark'
                    301:        if ( mark_count > 8 ) mark_count = 8;
                    302: 
                    303:        var picWidth  = (document.all) ? parseInt(document.all.scaler.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.pic.clip.width);
                    304:        var picHeight = (document.all) ? parseInt(document.all.scaler.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.pic.clip.height);
                    305: 
                    306:        // catch the s where the picture had not been loaded already and
                    307:        // make a timeout so that the coordinates are calculated with the real dimensions
                    308:        //if ( (document.pic.complete) || (picWidth > 30) ) {
                    309:                 if ( (picWidth > 30) ) {
                    310: 
                    311:        var xOffset = (document.all) ? parseInt(document.all.scaler.offsetLeft) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('scaler').offsetLeft) : document.scaler.left;
                    312:        var yOffset = (document.all) ? parseInt(document.all.scaler.offsetTop) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('scaler').offsetTop) : document.scaler.top;
                    313: 
                    314:            for (var i = 0; i < mark_count; i++) {
                    315:                mark[i] = mark[i].split("/");
                    316: 
                    317:                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))) ) {
                    318: 
                    319:                    mark[i][0] = parseInt(xOffset + picWidth * (mark[i][0] - dlParams.wx.value)/dlParams.ww.value);
                    320:                    mark[i][1] = parseInt(yOffset + picHeight * (mark[i][1] - dlParams.wy.value)/dlParams.wh.value);
                    321: 
                    322:                    if ( (document.all) || (typeof(document.getElementById) == "function") ) {
                    323:             // suboptimal to place -5 pixels and not half size of mark-image
                    324:             // should be changed in the future
                    325:             document.getElementById("dot" + i).style.left = mark[i][0]-5;
                    326:             document.getElementById("dot" + i).style.top = mark[i][1]-5;
                    327:             document.getElementById("dot" + i).style.visibility = "visible";
                    328:           } else {
                    329:                    document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5);
                    330:                    document.layers[i+1].visibility = "show";
                    331:           }
                    332:                }
                    333:            }
                    334: 
                    335:        } else {
                    336:            setTimeout("placeMarks()", 100);
                    337:        }
                    338:    }
                    339: }
                    340: 
                    341: 
                    342: function zoomPoint() {
1.2     ! dwinter   343:   window.focus()
1.1       dwinter   344:   function zoomPointEvent(evt) {
                    345: 
                    346:     var point = new Point(evt);
                    347: 
                    348:        dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value*(1/ZOOMFACTOR));
                    349:        dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value*(1/ZOOMFACTOR));
                    350: 
                    351:        dlParams.ww.value = cropFloat(dlParams.ww.value*(1/ZOOMFACTOR));
                    352:        dlParams.wh.value = cropFloat(dlParams.wh.value*(1/ZOOMFACTOR));
                    353: 
                    354:        if ( dlParams.wx.value < 0 ) {
                    355:            dlParams.wx.value = 0;
                    356:        }
                    357:        if ( dlParams.wy.value < 0 ) {
                    358:            dlParams.wy.value = 0;
                    359:        }
                    360:        if ( dlParams.wx.value + dlParams.ww.value > 1 ) {
                    361:            dlParams.wx.value = 1 - dlParams.ww.value;
                    362:        }
                    363:        if ( dlParams.wy.value + dlParams.wh.value > 1 ) {
                    364:            dlParams.wy.value = 1 - dlParams.wh.value;
                    365:        }
                    366: 
                    367:     // stopping event capture
                    368:    if ( document.all ) {
                    369:      document.all.scaler.onmousedown = null;
                    370:    } else if ( typeof(document.removeEventListener) == "function" ) {
                    371:       document.getElementById("scaler").removeEventListener("mousedown", zoomPointEvent, true);
                    372:     } else {
                    373:       document.scaler.releaseEvents(Event.MOUSEDOWN);
                    374:     }
                    375:        
                    376:        display(3);
                    377:    }
                    378: 
                    379:   // starting event capture
                    380:    if ( document.all ) {
                    381:      document.all.scaler.onmousedown = zoomPointEvent;
                    382:    } else if ( typeof(document.addEventListener) == "function" ) {
                    383:     document.getElementById("scaler").addEventListener("mousedown", zoomPointEvent, true);
                    384:   } else {
                    385:     document.scaler.captureEvents(Event.MOUSEDOWN);
                    386:     document.scaler.onmousedown = zoomPointEvent;
                    387:   }
                    388: }
                    389: 
                    390: 
                    391: function zoomArea() {
                    392:    var state = 0;
                    393:    var pt1, pt2;
1.2     ! dwinter   394:    window.focus()
1.1       dwinter   395: 
                    396:    function click(evt) {
                    397: 
                    398:        if (state == 0) {
                    399:            state = 1;
                    400:            
                    401:            pt1 = new Point(evt);
                    402:            
                    403:            pt2 = pt1;
                    404:            
                    405:        if ( document.all ) {
                    406: 
                    407:         document.all.eck1.style.left = pt1.pageX;
                    408:         document.all.eck1.style.top = pt1.pageY;
                    409:         document.all.eck2.style.left = pt2.pageX-12;
                    410:         document.all.eck2.style.top = pt1.pageY;
                    411:         document.all.eck3.style.left = pt1.pageX;
                    412:         document.all.eck3.style.top = pt2.pageY-12;
                    413:         document.all.eck4.style.left = pt2.pageX-12;
                    414:         document.all.eck4.style.top = pt2.pageY-12;
                    415: 
                    416:         document.all.eck1.style.visibility="visible";
                    417:         document.all.eck2.style.visibility="visible";
                    418:         document.all.eck3.style.visibility="visible";
                    419:         document.all.eck4.style.visibility="visible";
                    420: 
                    421:          document.all.scaler.onmousemove = move;
                    422:          document.all.eck4.onmousemove = move;
                    423: 
                    424:        } else if ( typeof(document.addEventListener) == "function" ) {
                    425: 
                    426:         document.getElementById("eck1").style.left = pt1.pageX;
                    427:         document.getElementById("eck1").style.top = pt1.pageY;
                    428:         document.getElementById("eck2").style.left = pt2.pageX-12;
                    429:         document.getElementById("eck2").style.top = pt1.pageY;
                    430:         document.getElementById("eck3").style.left = pt1.pageX;
                    431:         document.getElementById("eck3").style.top = pt2.pageY-12;
                    432:         document.getElementById("eck4").style.left = pt2.pageX-12;
                    433:         document.getElementById("eck4").style.top = pt2.pageY-12;
                    434: 
                    435:         document.getElementById("eck1").style.visibility="visible";
                    436:         document.getElementById("eck2").style.visibility="visible";
                    437:         document.getElementById("eck3").style.visibility="visible";
                    438:         document.getElementById("eck4").style.visibility="visible";
                    439: 
                    440:         document.getElementById("scaler").addEventListener("mousemove", move, true);
                    441:         document.getElementById("eck4").addEventListener("mousemove", move, true);
                    442: 
                    443:       } else {
                    444: 
                    445:         document.eck1.moveTo(pt1.pageX, pt1.pageY);
                    446:         document.eck2.moveTo(pt2.pageX-12, pt1.pageY);
                    447:         document.eck3.moveTo(pt1.pageX, pt2.pageY-12);
                    448:         document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12);
                    449: 
                    450:         document.eck1.visibility="show";
                    451:         document.eck2.visibility="show";
                    452:         document.eck3.visibility="show";
                    453:         document.eck4.visibility="show";
                    454: 
                    455:         document.scaler.captureEvents(Event.MOUSEMOVE);
                    456:         document.eck4.captureEvents(Event.MOUSEMOVE);
                    457:         document.scaler.onmousemove = move;
                    458:         document.eck4.onmousemove = move;
                    459: 
                    460:       }
                    461: 
                    462:     } else {
                    463: 
                    464:       pt2 = new Point(evt);
                    465:            
                    466:       if ( document.all ) {
                    467: 
                    468:         document.all.eck1.visibility="hidden";
                    469:         document.all.eck2.visibility="hidden";
                    470:         document.all.eck3.visibility="hidden";
                    471:         document.all.eck4.visibility="hidden";
                    472: 
                    473:         document.all.scaler.onmousedown = null;
                    474:         document.all.eck4.onmousedown = null;
                    475:         document.all.scaler.onmousemove = null;
                    476:         document.all.eck4.onmousemove = null;
                    477: 
                    478:       } else if ( typeof(document.removeEventListener) == "function" ) {
                    479: 
                    480:         document.getElementById("eck1").style.visibility="hidden";
                    481:         document.getElementById("eck2").style.visibility="hidden";
                    482:         document.getElementById("eck3").style.visibility="hidden";
                    483:         document.getElementById("eck4").style.visibility="hidden";
                    484: 
                    485:         document.getElementById("scaler").removeEventListener("mousedown", click, true);
                    486:         document.getElementById("eck4").removeEventListener("mousedown", click, true);
                    487:         document.getElementById("scaler").removeEventListener("mousemove", move, true);
                    488:         document.getElementById("eck4").removeEventListener("mousemove", move, true);
                    489: 
                    490:       } else {
                    491: 
                    492:         document.eck1.visibility="hide";
                    493:         document.eck2.visibility="hide";
                    494:         document.eck3.visibility="hide";
                    495:         document.eck4.visibility="hide";
                    496: 
                    497:         document.scaler.releaseEvents(Event.MOUSEDOWN);
                    498:         document.eck4.releaseEvents(Event.MOUSEDOWN);
                    499:         document.scaler.releaseEvents(Event.MOUSEMOVE);
                    500:         document.eck4.releaseEvents(Event.MOUSEMOVE);
                    501: 
                    502:       }
                    503:       
                    504:       dlParams.wx.value = cropFloat(parseFloat(Math.min(pt1.relX, pt2.relX)));
                    505:       
                    506:       dlParams.wy.value = cropFloat(parseFloat(Math.min(pt1.relY, pt2.relY)));
                    507: 
                    508:       dlParams.ww.value = cropFloat(parseFloat(Math.abs(pt1.relX-pt2.relX)));
                    509:       dlParams.wh.value = cropFloat(parseFloat(Math.abs(pt1.relY-pt2.relY)));
                    510: 
                    511:       if ( (dlParams.ww.value != 0) && (dlParams.wh.value != 0) ) {
                    512:         display(3);
                    513:       }
                    514:     }
                    515:   }
                    516: 
                    517:   function move(evt) {
                    518: 
                    519:     pt2 = new Point(evt);
                    520: 
                    521:     var eck1_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX);
                    522:     var eck1_top  = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY);
                    523:     var eck2_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;;
                    524:     var eck2_top  = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY);
                    525:     var eck3_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX);
                    526:     var eck3_top  = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12;
                    527:     var eck4_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;
                    528:     var eck4_top  = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12;
                    529: 
                    530:     if ( document.all ) {
                    531:       
                    532:       document.all.eck1.style.left = eck1_left;
                    533:       document.all.eck1.style.top  = eck1_top;
                    534:       document.all.eck2.style.left = eck2_left;
                    535:       document.all.eck2.style.top  = eck2_top;
                    536:       document.all.eck3.style.left = eck3_left;
                    537:       document.all.eck3.style.top  = eck3_top;
                    538:       document.all.eck4.style.left = eck4_left;
                    539:       document.all.eck4.style.top  = eck4_top;
                    540: 
                    541:     } else if ( typeof(document.getElementById) == "function" ) {
                    542: 
                    543:       document.getElementById("eck1").style.left = eck1_left;
                    544:       document.getElementById("eck1").style.top  = eck1_top;
                    545:       document.getElementById("eck2").style.left = eck2_left;
                    546:       document.getElementById("eck2").style.top  = eck2_top;
                    547:       document.getElementById("eck3").style.left = eck3_left;
                    548:       document.getElementById("eck3").style.top  = eck3_top;
                    549:       document.getElementById("eck4").style.left = eck4_left;
                    550:       document.getElementById("eck4").style.top  = eck4_top;
                    551: 
                    552:     } else {
                    553: 
                    554:       document.eck1.moveTo(eck1_left, eck1_top);
                    555:       document.eck2.moveTo(eck2_left, eck2_top);
                    556:       document.eck3.moveTo(eck3_left, eck3_top);
                    557:       document.eck4.moveTo(eck4_left, eck4_top);
                    558: 
                    559:     }
                    560:   }
                    561: 
                    562:   // starting event capture
                    563:   if ( document.all ) {
                    564:     document.all.scaler.onmousedown = click;
                    565:     document.all.eck4.onmousedown = click;
                    566:   } else if ( typeof(document.addEventListener) == "function" ) {
                    567:       document.getElementById("scaler").addEventListener("mousedown", click, true);
                    568:       document.getElementById("eck4").addEventListener("mousedown", click, true);
                    569:   } else {
                    570:     document.scaler.captureEvents(Event.MOUSEDOWN);
                    571:     document.eck4.captureEvents(Event.MOUSEDOWN);
                    572:     document.scaler.onmousedown = click;
                    573:     document.eck4.onmousedown = click;
                    574:   }
                    575: }
                    576: 
                    577: 
                    578: function zoomExtends() {
                    579: 
                    580:   dlParams.wx.value = 0.0;
                    581:   dlParams.wy.value = 0.0;
                    582:   
                    583:   dlParams.ww.value = 1.0;
                    584:   dlParams.wh.value = 1.0;
                    585: 
                    586:   display(3);
                    587: 
                    588: }
                    589: 
                    590: 
                    591: function zoomOut() {
                    592: 
                    593:   dlParams.wx.value = cropFloat(dlParams.wx.value-0.5*(dlParams.ww.value*(ZOOMFACTOR)-dlParams.ww.value));
                    594:   dlParams.wy.value = cropFloat(dlParams.wy.value-0.5*(dlParams.wh.value*(ZOOMFACTOR)-dlParams.wh.value));
                    595: 
                    596:   dlParams.ww.value = cropFloat(dlParams.ww.value*(ZOOMFACTOR));
                    597:   dlParams.wh.value = cropFloat(dlParams.wh.value*(ZOOMFACTOR));
                    598: 
                    599:    if ( dlParams.wx.value < 0 ) {
                    600:        dlParams.wx.value = 0;
                    601:    }
                    602:    if ( dlParams.wy.value < 0 ) {
                    603:        dlParams.wy.value = 0;
                    604:    }
                    605:   if ( dlParams.ww.value > 1 ) {
                    606:     dlParams.ww.value = 1;
                    607:   }
                    608:   if ( dlParams.wh.value > 1 ) {
                    609:     dlParams.wh.value = 1;
                    610:   }
                    611:    if ( dlParams.wx.value + dlParams.ww.value > 1 ) {
                    612:        dlParams.wx.value = 1 - dlParams.ww.value;
                    613:    }
                    614:    if ( dlParams.wy.value + dlParams.wh.value > 1 ) {
                    615:        dlParams.wy.value = 1 - dlParams.wh.value;
                    616:    }
                    617: 
                    618:    display(3);
                    619: }
                    620: 
                    621: 
                    622: function moveTo() {
                    623: 
                    624:    if ( (parseFloat(dlParams.ww.value) == 1.0) && (parseFloat(dlParams.wh.value) == 1.0) ) {
                    625:        alert("This function is only available when zoomed in!");
                    626:        return;
                    627:    }
                    628: 
                    629:   function moveToEvent(event) {
                    630: 
                    631:     var point = new Point(event);
                    632: 
                    633:        dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value);
                    634:        dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value);
                    635: 
                    636:        if ( dlParams.wx.value < 0 ) {
                    637:            dlParams.wx.value = 0;
                    638:        }
                    639:        if ( dlParams.wy.value < 0 ) {
                    640:            dlParams.wy.value = 0;
                    641:        }
                    642:        if ( dlParams.wx.value + dlParams.ww.value > 1 ) {
                    643:            dlParams.wx.value = 1 - dlParams.ww.value;
                    644:        }
                    645:        if ( dlParams.wy.value + dlParams.wh.value > 1 ) {
                    646:            dlParams.wy.value = 1 - dlParams.wh.value;
                    647:        }
                    648: 
                    649:     // stopping event capture
                    650:    if ( document.all ) {
                    651:      document.all.scaler.onmousedown = null;
                    652:    } else if ( typeof(document.removeEventListener) == "function" ) {
                    653:       document.getElementById("scaler").removeEventListener("mousedown", moveToEvent, true);
                    654:     } else {
                    655:       document.scaler.releaseEvents(Event.MOUSEDOWN)
                    656:     }
                    657:        
                    658:        display(3);
                    659:    }
                    660: 
                    661:   // starting event capture
                    662:    if ( document.all ) {
                    663:      document.all.scaler.onmousedown = moveToEvent;
                    664:    } else if ( typeof(document.addEventListener) == "function" ) {
                    665:     document.getElementById("scaler").addEventListener("mousedown", moveToEvent, true);
                    666:   } else {
                    667:     document.scaler.captureEvents(Event.MOUSEDOWN);
                    668:     document.scaler.onmousedown = moveToEvent;
                    669:   }
                    670: }
                    671: 
                    672: 
                    673: function scale(factor) {
                    674: 
                    675:   dlParams.ws.value = cropFloat(factor);
                    676:   display(3);
                    677: 
                    678: }
                    679: 
                    680: 
                    681: // capturing keypresses for next and previous page
                    682: function parseKeypress(evt) {
                    683: 
                    684:   if ( document.all ) {
                    685: 
                    686:    if ( event.keyCode == 110 ) {
                    687:          page('+1');
                    688:    }
                    689:    if ( event.keyCode == 98 ) {
                    690:          page('-1');
                    691:    }
                    692: 
                    693:    document.cancleBubble = true;
                    694: 
                    695:   } else {
                    696: 
                    697:    if ( evt.charCode == 110 ) {
                    698:          page('+1');
                    699:      } else if ( evt.charCode == 98 ) {
                    700:          page('-1');
                    701:      } else if ( evt.which == 110 ) {
                    702:          page('+1');
                    703:    } else if ( evt.which == 98 ) {
                    704:        // does not work currentlyfor Opera, because it catches the 'b'-key on it's own
                    705:        // have to change the key or find another way - luginbuehl
                    706:          page('-1');
                    707:    }
                    708: 
                    709:   }
                    710: }
                    711: 
                    712: 
                    713: // auxiliary function to crop senseless precicsion
                    714: function cropFloat(tmp) {
                    715:   return parseInt(10000*tmp)/10000;
                    716: }

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