forked from rherrick/XNATImageViewer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Demo.html
executable file
·214 lines (169 loc) · 6.5 KB
/
Demo.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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="Demo.css">
<link type="text/css" rel="stylesheet" href="src/main/scripts/viewer/nrg/css/nrg.css">
<link type="text/css" rel="stylesheet" href="src/main/scripts/viewer/xiv/css/xiv.css">
<!--
<link type="text/css" rel="stylesheet" href="src/main/scripts/viewer/css/viewer.min.css">
-->
<script src="src/main/scripts/viewer/closure-library/closure/goog/base.js"></script>
<script src="src/main/scripts/viewer/X/xtk-deps.js"></script>
<script src="src/main/scripts/viewer/_custom/X/xtk-custom-deps.js"></script>
<script src="src/main/scripts/viewer/jszip/jszip.js"></script>
<script src="src/main/scripts/viewer/nrg/nrg-deps.js"></script>
<script src="src/main/scripts/viewer/gxnat/gxnat-deps.js"></script>
<script src="src/main/scripts/viewer/xiv/xiv-deps.js"></script>
<script>
goog.require('goog.userAgent');
goog.require('goog.dom');
goog.require('xiv.start');
goog.require('xiv.ui.Modal');
goog.require('xiv.utils.ErrorCatcher');
goog.require('xiv.utils.ObjectAnalyzer');
</script>
</head>
<body>
<script>
//
// globals
//
XIV_STATE = 'demo';
function displayModalError() {
var noMobileDiv = goog.dom.createDom('div',
{'id': 'NoMobileDiv'});
goog.dom.classes.add(noMobileDiv, 'xiv-ui-nomobilemodal');
var noMobileContent = goog.dom.createDom('div',
{'id': 'NoMobileContent'});
goog.dom.classes.add(noMobileContent, 'xiv-ui-nomobilemodal-content');
noMobileContent.innerHTML =
'The XNATImageViewer is not yet <br> supported on mobile devices :(';
goog.dom.append(document.body, noMobileDiv);
goog.dom.append(noMobileDiv, noMobileContent);
noMobileDiv.onClick = function(){
if (XIV_STATE == 'demo'){
goog.dom.removeNode(noMobileDiv);
}
}
}
/**
* Main launch function for the XNAT Image Viewer.
* NOTES:
* - the 'serverRoot' property is a global defined by the VM if launched
* directly from an XNATUrl. Otherwise it's blank.
*
* @preserve Copyright 2014 Washington University
* @author sunilk@mokacreativellc.com (Sunil Kumar)
* @author herrickr@mir.wustl.edu (Rick Herrick)
*
* @param {!string} opt_dataPath The optional data path to begin the
* viewer from. Defaults to the Velocity generated URL
* (e.g. 'projects/$om.getProject()/subjects/$om.getSubjectId()/' +
* 'experiments/$om.getId()')
* @param {!string} opt_modalState The modal state to set the image viewer to.
* @param {!string} opt_serverRoot The optional server root.
*/
function launchXImgView(opt_dataPath, opt_modalState, opt_serverRoot) {
//window.console.log('xiv', xiv);
//window.console.log('compat', xiv.isCompatible);
//window.console.log('root', xiv.prototype.setServerRoot);
//window.console.log('states', xiv.ui.Modal);
//
// Detect Mobile display dialog
//
if(goog.userAgent.MOBILE) {
displayModalError()
return;
}
//-------------------
// We need to set the global serverRoot property if opt_serverRoot is
// argument is given.
//
// NOTE: 'serverRoot' is automatically provided in the live version (in the
// VM) but in the demo version, we have to provide this global variable.
//-------------------
if (opt_serverRoot){
serverRoot = opt_serverRoot;
}
//-------------------
// Verify compatibilities (browser, WebGL, etc.)
//-------------------
if (!xiv.utils.ErrorCatcher.isCompatible()){
return;
}
//-------------------
// Set the modalState argument ('windowed', 'popup', etc.)
//-------------------
var modalState = (opt_modalState != undefined && opt_modalState != null) ?
opt_modalState : 'windowed';
//-------------------
// Set the dataPath argument (i.e. where to query the data from).
//
// NOTE: If we're in popup mode, we take the data path from the URL of the
// page, which is fed in as a query string
//-------------------
var dataPath = '';
if (opt_modalState != undefined &&
opt_modalState === 'popup') {
dataPath = document.URL.split('?')[1];
}
else {
dataPath = (opt_dataPath != undefined && opt_dataPath != null) ?
opt_dataPath :
'projects/$om.getProject()/subjects/$om.getSubjectId()/' +
'experiments/$om.getId()';
}
//-------------------
// Set the rootUrl argument -- varies depending on modal state,
// hence why we differentiate between dataPath and rootUrl.
//-------------------
var rootUrl = (opt_modalState === 'popup') ? '' :
serverRoot;
//-------------------
// Create the viewer, passing in above arguments.
//-------------------
//window.console.log('modal state', modalState);
var XnatImageViewer = new xiv.start(XIV_STATE, modalState, dataPath, rootUrl);
XnatImageViewer.setModalType(xiv.ui.Modal);
//-------------------
// Track the serverRoot property within xiv.
//
// NOTE: We track this because once we enter 'xiv' world, the global
// property of 'serverRoot' could potentially be minified to something
// entirely different.
//-------------------
XnatImageViewer.setServerRoot(serverRoot);
//-------------------
// Launch the viewer!
//-------------------
XnatImageViewer.begin();
//-------------------
// Debugs, if needed...
//-------------------
//window.console.log('opt_dataPath', opt_dataPath);
//window.console.log('opt_modalState', opt_modalState);
//window.console.log('XImgView launch (serverRoot)', serverRoot);
//window.console.log('imagePath', imagePath);
};
//
// Special case for popup's that are refreshed
//
if (document.URL.indexOf('popup.html') > -1) {
launchXImgView('', 'popup', serverRoot);
}
//
// Launch viewer automatically if in demo mode
//
if (XIV_STATE == 'demo') {
launchXImgView('', '', 'src/main');
/**
* For google closure compiling
xiv.utils.ObjectAnalyzer.outputExportables({
'xiv.utils.ErrorCatcher': xiv.utils.ErrorCatcher,
'xiv.utils.ObjectAnalyzer': xiv.utils.ObjectAnalyzer,
});
*/
}
</script>
</body>
</html>