1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* File........: hjp4lib.js
* Created.....: 2000/04/11, Guido Krueger
* Changed.....: 2007/10/28, Guido Krueger
* Copyright...: (c) 2001,2007 Guido Krueger. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for NON-COMMERCIAL purposes
* and without fee is hereby granted provided that this
* copyright notice appears in all copies.
*
* THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
* NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY
* DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
//-----------------------------------------------------------------------
//Global variables
//-----------------------------------------------------------------------
var isNS = (navigator.appName.toUpperCase().indexOf("NETSCAPE") != -1);
var isIE = (navigator.appName.toUpperCase().indexOf("MICROSOFT") != -1);
var jdkdocs = "file:///C|/jdk1.6/docs/";
var apidocs = "file:///C|/jdk1.6/docs/api/";
//---
//Nachfolgend ein Beispiel f�r UNIX-Systeme
//var jdkdocs = "file:///usr/local/jdk1.6/docs/";
//var apidocs = "file:///usr/local/jdk1.6/docs/api/";
//---
//Nachfolgend der direkte Link ins Internet
//var jdkdocs = "http://java.sun.com/javase/6/docs/";
//var apidocs = "http://java.sun.com/javase/6/docs/api/";
var keycodes = null;
var keylinks = null;
//-----------------------------------------------------------------------
//Function definitions
//-----------------------------------------------------------------------
/**
* Jumps to the API doc of the given qualified class name.
*/
function getApiDoc(classname)
{
return apidocs + classname.replace(/\./g, "/") + ".html";
}
/**
* Jumps to the JDK doc index.
*/
function getDocIndex()
{
return jdkdocs + "index.html";
}
/**
* Jumps to the API doc index.
*/
function getApiIndex()
{
return apidocs + "index.html";
}
/**
* Creates the keycodes and keylinks arrays from the given definition
* String and installs the onKbdEvent keyboard handler. keydef must have
* the following format: "code1,dest1;code2,dest2;code3,dest3;...".
*/
function installKbdHandler(keydef)
{
//define keycodes and keylinks
keycodes = new Array();
keylinks = new Array();
var index = 0;
var items = keydef.split(";");
for (var i = 0; i < items.length; ++i) {
var item = items[i].split(",");
keycodes[index] = parseInt(item[0]);
keylinks[index] = item[1];
++index;
}
//install handler
if (isNS) {
document.captureEvents(Event.KEYPRESS);
}
document.onkeypress = onKbdEvent;
}
/**
* Keyboard handler that uses the keycodes and keylinks information
* to jump to a certain destination based on the last key typed.
*/
function onKbdEvent(e)
{
//get keycode
var key = -1;
if (isNS) {
if (e.which != 0 && (typeof e.modifiers == "undefined" || e.modifiers == 0 || e.modifiers == 4)) {
key = e.which;
}
}
if (isIE) {
e = window.event;
if (!e.ctrlKey && !e.altKey && !e.shiftKey) {
key = e.keyCode;
}
e.cancelBubble = true;
}
if (keycodes != null && keylinks != null) {
for (var i = 0; i < keycodes.length; ++i) {
if (key == keycodes[i]) {
if (keylinks[i] == "APIDOCS") {
window.location = getApiIndex();
} else if (keylinks[i] == "JDKDOCS") {
window.location = getDocIndex();
} else {
window.location = keylinks[i];
}
break;
}
}
}
}
//-----------------------------------------------------------------------
//Body code
//-----------------------------------------------------------------------
|