This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
/
index.html
63 lines (54 loc) · 2.13 KB
/
index.html
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
<html>
<head>
<title>OpenFin: PDF.JS Demo</title>
</head>
<body>
<ul>
<li><a href="#" class="pdfLink" data-target="http://localhost:7070/web/viewer.html">Default Viewer</li>
<li><a href="#" class="pdfLink" data-target="http://localhost:7070/web/viewer.html?file=http://localhost:7070/Test_PDF.pdf">Load PDF from Querystring</li>
<li><a href="#" class="pdfLink" data-target="viewframe">Load in iFrame</a></li>
</ul>
<iframe id="viewerframe" width="600" height="400"></iframe>
</body>
<script>
var win;
function createWindow(success){
win = new fin.desktop.Window({
name:"viewWindow",
url:"blank.html",
defaultWidth:800,
defaultHeight:600,
opacity:1,
autoShow:false,
saveWindowState:false
}, success);
}
function loadWindow(target){
win.navigate(target,function(){
win.isShowing(iShow => {
win.bringToFront(function(){
});
});
});
}
window.addEventListener("DOMContentLoaded",ev => {
let links = document.querySelectorAll(".pdfLink");
links.forEach(link => {
link.addEventListener("click", evt => {
let t = evt.target.getAttribute("data-target");
if (t === "viewframe"){
document.getElementById('viewerframe').src='web/viewer.html';
}
else {
if (!win || ! win.nativeWindow){
createWindow(function(){win.show(function(){loadWindow(t);})});
}
else {
loadWindow(t);
}
}
});
});
});
</script>
</html>