forked from IHTSDO/sct-browser-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser.html
264 lines (250 loc) · 13.1 KB
/
browser.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>IHTSDO SNOMED CT Browser - beta</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="IHTSDO SNOMED CT Browser">
<meta name="author" content="IHTSDO">
<link rel="icon" type="image/png" href="favicon.ico">
<script src="external-libs/jquery-2.1.0.min.js" type="text/javascript"></script>
<script src="external-libs/jquery-ui-1.10.4.custom.min.js" type="text/javascript"></script>
<script src="external-libs/jquery.svg.js" type="text/javascript"></script>
<script src="external-libs/jquery.splitter-0.14.0.js" type="text/javascript"></script>
<script src="external-libs/base64.js" type="text/javascript"></script>
<script src="snomed-interaction-components/js/svgdiagrammingv2.js" type="text/javascript"></script>
<script src="snomed-interaction-components/js/drawConceptDiagram.js" type="text/javascript"></script>
<script src="snomed-interaction-components/js/searchPlugin.js" type="text/javascript"></script>
<script src="snomed-interaction-components/js/taxonomyPlugin.js" type="text/javascript"></script>
<script src="snomed-interaction-components/js/conceptDetailsPlugin.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/jquery.splitter.css">
<link rel="stylesheet" href="css/jquery-ui-1.10.4.custom.min.css">
<link rel="stylesheet" href="css/bootstrap.min.base.12.css">
<link rel="stylesheet" href="css/bootstrap-tour.css">
<script src="external-libs/bootstrap.min.js" type="text/javascript"></script>
<script src="external-libs/jquery.ui.touch-punch.min.js"></script>
<script src="external-libs/popover-extra-placements.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/popover-extra-placements.css">
<link rel="stylesheet" href="snomed-interaction-components/css/sct-widgets.css">
<link rel="stylesheet" href="snomed-interaction-components/css/sct-diagram.css">
<script src="external-libs/bootstrap-tour.min.js"></script>
<script src="external-libs/jquery.i18n.properties-min-1.0.9.js"></script>
<script src="external-libs/w2ui-1.3.2.min.js"></script>
<script src="external-libs/handlebars-v1.3.0.js"></script>
<link rel="stylesheet" href="css/w2ui-1.3.2.min.css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
var layoutDef = {};
var layoutActions = [];
var count = 0;
var pstyle = 'background-color: #F5F6F7; border: 1px solid #dfdfdf; padding: 1px;';
var options = {
serverUrl: "http://browser.ihtsdotools.org/api",
//serverUrl: "http://107.170.33.116:3000",
edition: "en-edition",
release: "v20140131",
showIds: false,
hideNotAcceptable: true,
displayInactiveDescriptions: false,
displaySynonyms: true,
selectedView: "inferred",
displayChildren: false,
langRefset: "900000000000509007",
closeButton: false,
collapseButton: false,
linkerButton: true,
subscribersMarker: true,
searchMode: "partialMatching",
searchLang: "english",
diagrammingMarkupEnabled: false,
statusSearchFilter: "activeOnly",
highlightByEffectiveTime: "false"
};
function start(actions) {
$('#layout').empty();
$('#layout').w2layout({
name: 'layout' + count,
panels: [
{ type: 'main', style: pstyle, content: 'main' }
]
});
w2ui['layout' + count].content('main','<div id="panel-'+(count+1)+'-toolbar"></div><div id="panel-'+(count+1)+'-content"></div>');
layoutDef['panel-'+(count+1)+'-content'] = {
id: 'panel-'+(count+1)+'-content',
parent: null,
components: []
}
setupDiv("panel-"+(count+1)+"-toolbar");
count = count + 1;
$('#print-layout-def').disableTextSelect();
$('#print-layout-def').click(function(event) {
$('#layout-textarea').val(JSON.stringify(layoutActions));
});
$('#read-layout-def').disableTextSelect();
$('#read-layout-def').click(function(event) {
var actions = JSON.parse($('#layout-textarea').val());
start(actions);
});
if (actions) {
count = count * 100;
executeActions(actions);
}
}
function executeActions(actions) {
$.each(actions, function(key, value) {
var nbr = value.divId.match(/-\d*-/);
console.log(nbr);
console.log(value.divId + " " + value.action + " " + value.subItem);
processAction(value.divId, value.action, value.subItem);
});
}
function splitHorizontal(divId) {
layoutDef[divId.replace("toolbar", "content")].components = ["split-horizontal"];
count = count + 1;
$("#" + divId).parent().w2layout({
name: 'layout-' + count,
panels: [
{ type: 'main', size: '50%', resizable: true, style: pstyle, content: 'main' },
{ type: 'preview', size: '50%', resizable: true, style: pstyle, content: 'preview' }
]
});
w2ui['layout-' + count].content('main','<div id="panel-'+(count+1)+'-toolbar"></div><div id="panel-'+(count+1)+'-content"></div>');
layoutDef['panel-'+(count+1)+'-content'] = {
id: 'panel-'+(count+1)+'-content',
parent: divId,
components: []
}
setupDiv("panel-"+(count+1)+"-toolbar");
w2ui['layout-' + count].content('preview','<div id="panel-'+(count+2)+'-toolbar"></div><div id="panel-'+(count+2)+'-content"></div>');
layoutDef['panel-'+(count+2)+'-content'] = {
id: 'panel-'+(count+2)+'-content',
parent: divId,
components: []
}
setupDiv("panel-"+(count+2)+"-toolbar");
count = count + 2;
}
function splitVertical(divId) {
layoutDef[divId.replace("toolbar", "content")].components = ["split-vertical"];
count = count + 1;
$("#" + divId).parent().w2layout({
name: 'layout-' + count,
panels: [
{ type: 'main', size: '50%', resizable: true, style: pstyle, content: 'main' },
{ type: 'right', size: '50%', resizable: true, style: pstyle, content: 'preview' }
]
});
w2ui['layout-' + count].content('main','<div id="panel-'+(count+1)+'-toolbar"></div><div id="panel-'+(count+1)+'-content"></div>');
layoutDef['panel-'+(count+1)+'-content'] = {
id: 'panel-'+(count+1)+'-content',
parent: divId,
components: []
}
setupDiv("panel-"+(count+1)+"-toolbar");
w2ui['layout-' + count].content('right','<div id="panel-'+(count+2)+'-toolbar"></div><div id="panel-'+(count+2)+'-content"></div>');
layoutDef['panel-'+(count+2)+'-content'] = {
id: 'panel-'+(count+2)+'-content',
parent: divId,
components: []
}
setupDiv("panel-"+(count+2)+"-toolbar");
count = count + 2;
}
function setupDiv(divId) {
$("#" + divId).empty();
$("#" + divId).w2toolbar({
name: 'toolbar-' + divId,
items: [
{ type: 'menu', id: 'add-menu', caption: 'Add component', icon: 'fa fa-plus', items: [
{ text: 'Concept details', id: 'add-cd', icon: 'fa fa-eye' },
{ text: 'Search', id: 'add-se', icon: 'fa fa-search' },
{ text: 'Taxonomy', id: 'add-tx', icon: 'fa fa-cubes' }
]},
{ type: 'button', id: 'h-split', caption: 'Split in rows', icon: 'fa fa-arrows-v', hint: 'Split panel horizontally' },
{ type: 'break', id: 'break0' },
{ type: 'button', id: 'v-split', caption: 'Split in columns', icon: 'fa fa-arrows-h', hint: 'Split panel vertically' },
{ type: 'break', id: 'break0' }
],
onClick: function (event) {
if (event.subItem) {
layoutActions.push({divId: divId, action: event.target, subItem: event.subItem.id});
processAction(divId, event.target, event.subItem.id);
} else {
layoutActions.push({divId: divId, action: event.target, subItem: null});
processAction(divId, event.target, null)
}
}
});
}
function processAction(divId, action, subItem) {
switch (action) {
case "h-split":
splitHorizontal(divId);
break;
case "v-split":
splitVertical(divId);
break;
case "add-menu":
if (subItem) {
switch (subItem) {
case "add-cd":
layoutDef[divId.replace("toolbar", "content")].components.push("Concept Details");
break;
case "add-se":
layoutDef[divId.replace("toolbar", "content")].components.push("Search");
break;
case "add-tx":
layoutDef[divId.replace("toolbar", "content")].components.push("Taxonomy");
break;
}
var tabsHtml = '<ul class="nav nav-tabs" role="tablist" id="'+ divId.replace("toolbar", "content") +'tab">';
$.each(layoutDef[divId.replace("toolbar", "content")].components, function( key, value ) {
tabsHtml = tabsHtml + ' <li><a href="#'+ divId.replace("toolbar", "content") + key + '" role="tab" data-toggle="tab">' + value + '</a></li>';
});
tabsHtml = tabsHtml + ' </ul>';
tabsHtml = tabsHtml + '<div class="tab-content">';
$.each(layoutDef[divId.replace("toolbar", "content")].components, function( key, value ) {
tabsHtml = tabsHtml + '<div class="tab-pane" id="'+ divId.replace("toolbar", "content") + key + '"></div>';
});
tabsHtml = tabsHtml + '</div>';
$('#' + divId.replace("toolbar", "content")).html(tabsHtml);
$('#'+ divId.replace("toolbar", "content") +'tab a:last').tab('show');
$.each(layoutDef[divId.replace("toolbar", "content")].components, function( key, value ) {
switch (value) {
case "Concept Details":
var cdPanel1 = new conceptDetails(document.getElementById(divId.replace("toolbar", "content") + key), 404684003, options);
cdPanel1.setupCanvas();
break;
case "Search":
new searchPanel(document.getElementById(divId.replace("toolbar", "content") + key), options);
break;
case "Taxonomy":
new taxonomyPanel(document.getElementById(divId.replace("toolbar", "content") + key), 138875005, options);
break;
}
});
}
break;
}
}
</script>
</head>
<body onLoad="start();">
<div id="top" style="position: absolute; top: 10px; left: 10px; bottom: 10px; right: 10px;">
<div class="row">
<div class="col-md-3">
<button type="button" class="btn btn-primary pull-right" id="print-layout-def">Print Layout Def</button>
</div>
<div class="col-md-6">
<textarea class="form-control" rows="3" id="layout-textarea"></textarea>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-primary" id="read-layout-def">Read Layout Def</button>
</div>
</div>
</div>
<div id="layout" style="position: absolute; top: 80px; left: 10px; bottom: 10px; right: 10px;"></div>
</body>
</html>