-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathapplauncher.js
89 lines (80 loc) · 2.69 KB
/
applauncher.js
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
/**
* Application launcher.
*/
// start app function
function startApp() {
// gui setup
dwv.gui.setup();
// main application
var myapp = new dwv.App();
// initialise the application
var options = {
"containerDivId": "dwv",
"fitToWindow": true,
"gui": ["tool", "load", "help", "undo", "version", "tags", "drawList"],
"loaders": ["File", "Url"],
"tools": ["Scroll", "WindowLevel", "ZoomAndPan", "Draw", "Livewire", "Filter", "Floodfill"],
"filters": ["Threshold", "Sharpen", "Sobel"],
"shapes": ["Arrow", "Ruler", "Protractor", "Rectangle", "Roi", "Ellipse", "FreeHand"],
"isMobile": false,
"helpResourcesPath": "resources/help"
};
if ( dwv.browser.hasInputDirectory() ) {
options.loaders.splice(1, 0, "Folder");
}
myapp.init(options);
// help
// TODO Seems accordion only works when at end...
$("#accordion").accordion({ collapsible: "true", active: "false", heightStyle: "content" });
}
// Image decoders (for web workers)
dwv.image.decoderScripts = {
"jpeg2000": "node_modules/dwv/decoders/pdfjs/decode-jpeg2000.js",
"jpeg-lossless": "node_modules/dwv/decoders/rii-mango/decode-jpegloss.js",
"jpeg-baseline": "node_modules/dwv/decoders/pdfjs/decode-jpegbaseline.js"
};
// status flags
var domContentLoaded = false;
var i18nInitialised = false;
// launch when both DOM and i18n are ready
function launchApp() {
if ( domContentLoaded && i18nInitialised ) {
startApp();
}
}
// i18n ready?
dwv.i18nOnInitialised( function () {
// call next once the overlays are loaded
var onLoaded = function (data) {
dwv.gui.info.overlayMaps = data;
i18nInitialised = true;
launchApp();
};
// load overlay map info
$.getJSON( dwv.i18nGetLocalePath("overlays.json"), onLoaded )
.fail( function () {
console.log("Using fallback overlays.");
$.getJSON( dwv.i18nGetFallbackLocalePath("overlays.json"), onLoaded );
});
});
// check browser support
dwv.browser.check();
// initialise i18n
dwv.i18nInitialise("auto", "node_modules/dwv");
// initialise service worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('./service-worker.js').then(function (registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function (err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
// DOM ready?
$(document).ready( function() {
domContentLoaded = true;
launchApp();
});