| 1 |
<html> |
| 2 |
<title>Test of nsdejavu scriptability features</title> |
| 3 |
<body onload="detectPlugin()"> |
| 4 |
|
| 5 |
|
| 6 |
<p><hr><p> |
| 7 |
<!-- The plugin --> |
| 8 |
<style type="text/css"> |
| 9 |
#myplugin { width: 100%; height: 330px; } |
| 10 |
</style> |
| 11 |
<object id="myplugin" data="test.djvu" type="image/vnd.djvu"> |
| 12 |
No plugin |
| 13 |
</object> |
| 14 |
<p><hr><p> |
| 15 |
<!-- The information section --> |
| 16 |
<div id="info" onclick="detectPlugin()"> |
| 17 |
Plugin has not yet been detected. |
| 18 |
</div> |
| 19 |
<p><hr><p> |
| 20 |
<!-- The buttons --> |
| 21 |
<button onclick="setDjVuOption('pageno','1')">FirstPage</button> |
| 22 |
<button onclick="setDjVuOption('page','-1')">PrevPage</button> |
| 23 |
<button onclick="setDjVuOption('page','+1')">NextPage</button> |
| 24 |
<button onclick="setDjVuOption('pageno',getDjVuOption('pages'))">LastPage</button> |
| 25 |
<p><hr><p> |
| 26 |
<table border=0 cellspacing=4> |
| 27 |
<tr> |
| 28 |
<td>Key: </td> |
| 29 |
<td><input type="text" name="key" id="key" |
| 30 |
onchange="getButtonPressed()" value="page"></td> |
| 31 |
<td><button onclick="getButtonPressed()">Get</button></td> |
| 32 |
</tr> |
| 33 |
<tr> |
| 34 |
<td>Value: </td> |
| 35 |
<td><input type="text" name="value" id="val" |
| 36 |
onchange="setButtonPressed()"></td> |
| 37 |
<td><button onclick="setButtonPressed()">Set</button></td> |
| 38 |
</tr> |
| 39 |
</table> |
| 40 |
<p><hr><p> |
| 41 |
|
| 42 |
<!-- Javascript code --> |
| 43 |
<script> |
| 44 |
|
| 45 |
var myplugin = document.getElementById("myplugin"); |
| 46 |
var info = document.getElementById("info"); |
| 47 |
var fkey = document.getElementById("key"); |
| 48 |
var fval = document.getElementById("val"); |
| 49 |
|
| 50 |
function detectPlugin() { |
| 51 |
if (myplugin && myplugin.version && ! myplugin.onchange) { |
| 52 |
myplugin.onchange = "showInfo()"; |
| 53 |
showInfo(); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
function getDjVuOption(key) { |
| 58 |
detectPlugin(); |
| 59 |
return myplugin.getdjvuopt(key); |
| 60 |
} |
| 61 |
|
| 62 |
function setDjVuOption(key,val) { |
| 63 |
detectPlugin(); |
| 64 |
myplugin.setdjvuopt(key,val); |
| 65 |
} |
| 66 |
|
| 67 |
function showInfo() { |
| 68 |
info.innerHTML = |
| 69 |
"page=" + myplugin.getdjvuopt('page') + |
| 70 |
" (" + myplugin.getdjvuopt('pageno') + "/" + |
| 71 |
myplugin.getdjvuopt('pages') + "), " + |
| 72 |
"zoom=" + myplugin.getdjvuopt('zoom') + ", " + |
| 73 |
"rotate=" + myplugin.getdjvuopt('rotate') + ",<br>" + |
| 74 |
"version=" + myplugin.version + ", " + |
| 75 |
"onchange=" + myplugin.onchange + ",<br>" + |
| 76 |
"showposition=" + myplugin.getdjvuopt('showposition') + "."; |
| 77 |
getButtonPressed(); |
| 78 |
} |
| 79 |
|
| 80 |
function getButtonPressed() { |
| 81 |
fval.value = getDjVuOption(fkey.value); |
| 82 |
} |
| 83 |
|
| 84 |
function setButtonPressed() { |
| 85 |
setDjVuOption(fkey.value,fval.value); |
| 86 |
getButtonPressed(); |
| 87 |
} |
| 88 |
|
| 89 |
</script> |
| 90 |
|
| 91 |
<!-- Form --> |
| 92 |
</body> |
| 93 |
</html> |