-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
301 lines (284 loc) · 8.72 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="./manifest.json" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!-- <link rel="stylesheet" href="./viewer/styles.f0604e6743391e0f9dcc.css" /> -->
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>HTML App</title>
</head>
<!-- <base href="./" /> -->
<!--
<script>
var global = global || window;
</script> -->
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script>
document.addEventListener('DOMContentLoaded', function() {
loadViewer();
}, false);
var eViewerObj = null;
let licenseKey = "<LICENSE KEY GOES HERE>";
function loadViewer() {
let jsElement = document.createElement("script");
jsElement.type = "application/javascript";
jsElement.src = './js/eViewer7_browser.js';
jsElement.addEventListener('load', function () {
let eViewerObj = new eViewerApp();
var css = [{ href: './viewer/styles.css' },
{ href: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css',
integrity: 'sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=',
crossorigin: 'anonymous' }
];
var scripts = [
'./viewer/runtime.js',
'./viewer/polyfills.js',
'./viewer/scripts.js',
'./viewer/main.js',
'./js/events.js',
// './viewer/vendor.js' // only for non prod builds
];
var options = {
contextMenuOptions: {
overrideContextMenus: true,
location: [
"documentView",
"pageThumbnails",
"docThumbnails",
"toolbar",
"docTab",
],
},
};
eViewerObj
.loadViewer("viewer", scripts, css, "best-fit", options)
.then(() => {
eViewerObj.registerLicense(licenseKey);
setViewerOptions();
});
});
document.getElementsByTagName("head")[0].appendChild(jsElement);
}
function OnSubmitClick() {
if(eViewerObj === null) {
eViewerObj = new eViewerApp();
}
let myform = document.getElementById("uploadForm");
let docUrl = myform.elements["upload"].value;
let saveUrl = myform.elements["saveUrl"].value;
let serverUrl = myform.elements["serverUrl"].value;
let annotationUrl = myform.elements["annotationUrl"].value;
let userName = myform.elements["userName"].value;
let isEditMode = true;
let repoType = "filesystem";
let fileName = myform.elements["docName"].value;
let password = "";
let token = myform.elements["token"].value;
let options = {
type: 'GET',
headers: {Authorization: 'Bearer ' + token,
Accept: 'application/octet-stream.'},
savePayLoadType: "multipart/form-data",
};
let clientDocId = Math.floor(Math.random() * 100);
eViewerObj.setUserName(userName);
eViewerObj.setDocumentEndPointOptions(options, serverUrl, saveUrl);
let documentSrvc = eViewerObj.getDocumentService();
documentSrvc
.loadDocumentWithOptions(docUrl, annotationUrl, clientDocId, {
isEditMode: true,
repoType: "filesystem",
password: "",
landingPage: 1,
tabStyle: {
fileName: "some-document-description-OUTFOCUS",
},
focusTabStyle: {
fileName: "some-document-description-INFOCUS",
},
})
.then((response) => {
console.log("loadDocument");
});
}
function goToPage() {
if(eViewerObj === null) {
eViewerObj = new eViewerApp();
}
let myform = document.getElementById("goToPageForm");
let pagenumber = myform.elements["gotoPage"].value;
let documentSrvc = eViewerObj.getDocumentService();
documentSrvc.gotoPage(pagenumber.toString()).then((response) => {
console.log("goToPage: " + response);
});
}
function setViewerOptions() {
let myform = document.getElementById("uploadForm");
let userName = myform.elements["userName"].value;
if(eViewerObj === null) {
eViewerObj = new eViewerApp();
}
eViewerObj.setUserName(userName);
let viewerPrefSrvc = eViewerObj.getViewerPreferenceService();
viewerPrefSrvc.getUserPreferences().then((preferences) => {
preferences.panning = false;
viewerPrefSrvc.setUserPreferences(JSON.stringify(preferences.userPreferences), JSON.stringify(preferences.shortcutPreferences));
});
}
function SaveDocument() {
let Save = document.getElementById("Save");
let documentSrvc = eViewerObj.getDocumentService();
documentSrvc.saveDocument()?.then((response) => {
console.log("saveDocument: " + response);
});
}
</script>
<div id="root">
<h2>Upload</h2>
<form id="uploadForm">
<table class="table" style="table-layout:fixed">
<thead>
<tr>
<th>
<label for="upload">Document Url: </label>
<input
type="text"
id="upload"
name="upload"
placeholder="document Url"
required
/>
</th>
<th>
<label for="saveUrl">Save Endpoint Url: </label>
<input
type="text"
id="saveUrl"
name="saveUrl"
placeholder="Save Endpoint Url"
required
/>
</th>
<th>
<label for="upload">Document Name: </label>
<input
type="text"
id="docName"
name="docName"
placeholder="document name"
required
/>
</th>
<th>
<label for="serverUrl">Server Url: </label>
<input
type="text"
id="serverUrl"
name="serverUrl"
placeholder="server Url"
required
/>
</th>
<th>
<label for="annotationUrl">Annotation Url: </label>
<input
type="text"
id="annotationUrl"
name="annotationUrl"
placeholder="json annotation"
/>
</th>
<th>
<label for="userName">User Name: </label>
<input
type="text"
id="userName"
name="userName"
placeholder="userName"
value="john"
/>
</th>
</tr>
<tr>
<td>
<label for="token">Auth Token: </label>
<input
type="text"
id="token"
name="token"
placeholder="token goes here"
value=""
/>
</td>
<td>
<button type="button" onclick="OnSubmitClick()" style="margin-top:13%">Submit</button>
</td>
</tr>
</thead>
</table>
</form>
<h2>Page Navigation</h2>
<form id="goToPageForm">
<table class="table">
<thead>
<tr>
<th>
<label for="gotoPage">Go To Page: </label>
<input
type="number"
id="gotoPage"
name="gotoPage"
placeholder="page Index"
required
/>
<button type="button" onclick="goToPage()">
Go To Page
</button>
</th>
<th>
<h3>
Save Document: <button id="Save" type="button" onclick="SaveDocument()">
Save
</button>
</h3>
</th>
</tr>
</thead>
</table>
</form>
<div id="viewer"></div>
</div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script>
var global = global || window;
</script>
</body>
</html>