forked from MokaCreativeLLC/XNATImageViewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Demo-min.html
executable file
·167 lines (133 loc) · 4.81 KB
/
Demo-min.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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="Demo.css">
<!-- BEGIN /xnat-templates/screens/XIViewer.vm -->
<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">
<script>
window.console.log('using xiv-min.js')
</script>
<script src="src/main/scripts/viewer/jszip/jszip.min.js"></script>
<script src="src/main/scripts/viewer/xiv-min.js"></script>
</head>
<body>
<script>
//
// globals
//
XIV_STATE = 'demo';
/**
* 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 [email protected] (Sunil Kumar)
* @author [email protected] (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);
//-------------------
// 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>