Mercurial > hg > orthanc
annotate OrthancExplorer/explorer.js @ 109:8c0a5666b05f
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Oct 2012 11:50:44 +0200 |
parents | a7bffca29031 |
children | 11e48e70c039 |
rev | line source |
---|---|
0 | 1 // http://stackoverflow.com/questions/1663741/is-there-a-good-jquery-drag-and-drop-file-upload-plugin |
2 | |
3 | |
4 // Forbid the access to IE | |
5 if ($.browser.msie) | |
6 { | |
7 alert("Please use Mozilla Firefox or Google Chrome. Microsoft Internet Explorer is not supported."); | |
8 } | |
9 | |
10 // http://jquerymobile.com/demos/1.1.0/docs/api/globalconfig.html | |
11 //$.mobile.ajaxEnabled = false; | |
12 //$.mobile.page.prototype.options.addBackBtn = true; | |
13 //$.mobile.defaultPageTransition = 'slide'; | |
14 | |
15 // http://stackoverflow.com/a/4673436 | |
16 String.prototype.format = function() { | |
17 var args = arguments; | |
18 return this.replace(/{(\d+)}/g, function(match, number) { | |
19 /*return typeof args[number] != 'undefined' | |
20 ? args[number] | |
21 : match;*/ | |
22 | |
23 return args[number]; | |
24 }); | |
25 }; | |
26 | |
27 | |
28 $(document).ready(function() { | |
29 var $tree = $('#dicom-tree'); | |
30 $tree.tree({ | |
31 autoEscape: false | |
32 }); | |
33 | |
34 $('#dicom-tree').bind( | |
35 'tree.click', | |
36 function(event) { | |
37 if (event.node.is_open) | |
38 $tree.tree('closeNode', event.node, true); | |
39 else | |
40 $tree.tree('openNode', event.node, true); | |
41 } | |
42 ); | |
43 }); | |
44 | |
45 | |
46 function SplitLongUid(s) | |
47 { | |
48 return '<span>' + s.substr(0, s.length / 2) + '</span> <span>' + s.substr(s.length / 2, s.length - s.length / 2) + '</span>'; | |
49 } | |
50 | |
51 | |
52 function ParseDicomDate(s) | |
53 { | |
54 y = parseInt(s.substr(0, 4), 10); | |
55 m = parseInt(s.substr(4, 2), 10) - 1; | |
56 d = parseInt(s.substr(6, 2), 10); | |
57 | |
58 if (y == null || m == null || d == null || | |
59 !isFinite(y) || !isFinite(m) || !isFinite(d)) | |
60 { | |
61 return null; | |
62 } | |
63 | |
64 if (y < 1900 || y > 2100 || | |
65 m < 0 || m >= 12 || | |
66 d <= 0 || d >= 32) | |
67 { | |
68 return null; | |
69 } | |
70 | |
71 return new Date(y, m, d); | |
72 } | |
73 | |
74 | |
75 function FormatDicomDate(s) | |
76 { | |
77 if (s == undefined) | |
78 return "No date"; | |
79 | |
80 var d = ParseDicomDate(s); | |
81 if (d == null) | |
82 return '?'; | |
83 else | |
84 return d.toString('dddd, MMMM d, yyyy'); | |
85 } | |
86 | |
87 | |
80 | 88 function Sort(arr, fieldExtractor, isInteger, reverse) |
0 | 89 { |
33 | 90 var defaultValue; |
91 if (isInteger) | |
92 defaultValue = 0; | |
93 else | |
94 defaultValue = ''; | |
95 | |
0 | 96 arr.sort(function(a, b) { |
80 | 97 var ta = fieldExtractor(a); |
98 var tb = fieldExtractor(b); | |
0 | 99 var order; |
100 | |
33 | 101 if (ta == undefined) |
102 ta = defaultValue; | |
103 | |
104 if (tb == undefined) | |
105 tb = defaultValue; | |
106 | |
0 | 107 if (isInteger) |
108 { | |
109 ta = parseInt(ta, 10); | |
110 tb = parseInt(tb, 10); | |
111 order = ta - tb; | |
112 } | |
113 else | |
114 { | |
115 if (ta < tb) | |
116 order = -1; | |
117 else if (ta > tb) | |
118 order = 1; | |
119 else | |
120 order = 0; | |
121 } | |
122 | |
123 if (reverse) | |
124 return -order; | |
125 else | |
126 return order; | |
127 }); | |
128 } | |
129 | |
130 | |
80 | 131 function SortOnDicomTag(arr, tag, isInteger, reverse) |
132 { | |
133 return Sort(arr, function(a) { | |
134 return a.MainDicomTags[tag]; | |
135 }, isInteger, reverse); | |
136 } | |
137 | |
138 | |
0 | 139 |
140 function GetSingleResource(type, uuid, callback) | |
141 { | |
142 var resource = null; | |
143 $.ajax({ | |
83 | 144 url: '../' + type + '/' + uuid, |
0 | 145 dataType: 'json', |
146 async: false, | |
147 success: function(s) { | |
148 callback(s); | |
149 } | |
150 }); | |
151 } | |
152 | |
153 | |
154 function GetMultipleResources(type, uuids, callback) | |
155 { | |
156 if (uuids == null) | |
157 { | |
158 $.ajax({ | |
83 | 159 url: '../' + type, |
0 | 160 dataType: 'json', |
161 async: false, | |
162 success: function(s) { | |
163 uuids = s; | |
164 } | |
165 }); | |
166 } | |
167 | |
168 var resources = []; | |
169 var ajaxRequests = uuids.map(function(uuid) { | |
170 return $.ajax({ | |
83 | 171 url: '../' + type + '/' + uuid, |
0 | 172 dataType: 'json', |
173 async: true, | |
174 success: function(s) { | |
175 resources.push(s); | |
176 } | |
177 }); | |
178 }); | |
179 | |
180 // Wait for all the AJAX requests to end | |
181 $.when.apply($, ajaxRequests).then(function() { | |
182 callback(resources); | |
183 }); | |
184 } | |
185 | |
186 | |
187 | |
188 function CompleteFormatting(s, link, isReverse) | |
189 { | |
190 if (link != null) | |
191 { | |
192 s = 'href="' + link + '">' + s + '</a>'; | |
193 | |
194 if (isReverse) | |
195 s = 'data-direction="reverse" '+ s; | |
196 | |
197 s = '<a ' + s; | |
198 } | |
199 | |
200 if (isReverse) | |
201 return '<li data-icon="back">' + s + '</li>'; | |
202 else | |
203 return '<li>' + s + '</li>'; | |
204 } | |
205 | |
206 | |
38 | 207 function FormatMainDicomTags(tags, tagsToIgnore) |
208 { | |
209 var s = ''; | |
210 | |
211 for (var i in tags) | |
212 { | |
213 if (tagsToIgnore.indexOf(i) == -1) | |
214 { | |
215 var v = tags[i]; | |
216 | |
40 | 217 if (i == "PatientBirthDate" || |
218 i == "StudyDate" || | |
219 i == "SeriesDate") | |
38 | 220 { |
221 v = FormatDicomDate(v); | |
222 } | |
40 | 223 else if (i == "DicomStudyInstanceUID" || |
224 i == "DicomSeriesInstanceUID") | |
38 | 225 { |
226 v = SplitLongUid(v); | |
227 } | |
228 | |
229 | |
230 s += ('<p>{0}: <strong>{1}</strong></p>').format(i, v); | |
231 } | |
232 } | |
233 | |
234 return s; | |
235 } | |
236 | |
0 | 237 |
238 function FormatPatient(patient, link, isReverse) | |
239 { | |
40 | 240 var s = ('<h3>{0}</h3>{1}' + |
241 '<span class="ui-li-count">{2}</span>' | |
0 | 242 ).format |
38 | 243 (patient.MainDicomTags.PatientName, |
40 | 244 FormatMainDicomTags(patient.MainDicomTags, [ |
245 "PatientName", | |
246 "OtherPatientIDs" | |
247 ]), | |
0 | 248 patient.Studies.length |
249 ); | |
250 | |
251 return CompleteFormatting(s, link, isReverse); | |
252 } | |
253 | |
254 | |
255 | |
256 function FormatStudy(study, link, isReverse) | |
257 { | |
40 | 258 var s = ('<h3>{0}</h3>{1}' + |
0 | 259 '<span class="ui-li-count">{2}</span>' |
260 ).format | |
261 (study.MainDicomTags.StudyDescription, | |
40 | 262 FormatMainDicomTags(study.MainDicomTags, [ |
263 "StudyDescription", | |
264 "StudyTime" | |
265 ]), | |
0 | 266 study.Series.length |
267 ); | |
268 | |
269 return CompleteFormatting(s, link, isReverse); | |
270 } | |
271 | |
272 | |
273 | |
274 function FormatSeries(series, link, isReverse) | |
275 { | |
80 | 276 var c; |
82 | 277 if (series.ExpectedNumberOfInstances == null || |
278 series.Instances.length == series.ExpectedNumberOfInstances) | |
80 | 279 { |
82 | 280 c = series.Instances.length; |
80 | 281 } |
282 else | |
283 { | |
284 c = series.Instances.length + '/' + series.ExpectedNumberOfInstances; | |
285 } | |
286 | |
287 var s = ('<h3>{0}</h3>' + | |
288 '<p><em>Status: <strong>{1}</strong></em></p>{2}' + | |
289 '<span class="ui-li-count">{3}</span>').format | |
0 | 290 (series.MainDicomTags.SeriesDescription, |
80 | 291 series.Status, |
40 | 292 FormatMainDicomTags(series.MainDicomTags, [ |
293 "SeriesDescription", | |
294 "SeriesTime", | |
41
c1097a676eca
better naming for preview images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
295 "Manufacturer", |
c1097a676eca
better naming for preview images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
296 "ImagesInAcquisition", |
40 | 297 "SeriesDate" |
298 ]), | |
80 | 299 c |
0 | 300 ); |
301 | |
302 return CompleteFormatting(s, link, isReverse); | |
303 } | |
304 | |
305 | |
306 function FormatInstance(instance, link, isReverse) | |
307 { | |
40 | 308 var s = ('<h3>Instance {0}</h3>{1}').format |
80 | 309 (instance.IndexInSeries, |
40 | 310 FormatMainDicomTags(instance.MainDicomTags, [ |
311 "AcquisitionNumber", | |
312 "InstanceNumber", | |
313 "InstanceCreationDate", | |
314 "InstanceCreationTime" | |
315 ]) | |
0 | 316 ); |
317 | |
318 return CompleteFormatting(s, link, isReverse); | |
319 } | |
320 | |
321 | |
322 | |
323 | |
324 $('#find-patients').live('pagebeforeshow', function() { | |
325 GetMultipleResources('patients', null, function(patients) { | |
326 var target = $('#all-patients'); | |
327 $('li', target).remove(); | |
328 | |
329 SortOnDicomTag(patients, 'PatientName', false, false); | |
330 | |
331 for (var i = 0; i < patients.length; i++) { | |
332 var p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID); | |
333 target.append(p); | |
334 } | |
335 | |
336 target.listview('refresh'); | |
337 }); | |
338 }); | |
339 | |
340 | |
341 | |
342 $('#patient').live('pagebeforeshow', function() { | |
343 if ($.mobile.pageData) { | |
344 GetSingleResource('patients', $.mobile.pageData.uuid, function(patient) { | |
345 GetMultipleResources('studies', patient.Studies, function(studies) { | |
346 SortOnDicomTag(studies, 'StudyDate', false, true); | |
347 | |
348 $('#patient-info li').remove(); | |
349 $('#patient-info') | |
350 .append('<li data-role="list-divider">Patient</li>') | |
351 .append(FormatPatient(patient)) | |
352 .listview('refresh'); | |
353 | |
354 var target = $('#list-studies'); | |
355 $('li', target).remove(); | |
356 | |
357 for (var i = 0; i < studies.length; i++) { | |
358 if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate) | |
359 { | |
360 target.append('<li data-role="list-divider">{0}</li>'.format | |
361 (FormatDicomDate(studies[i].MainDicomTags.StudyDate))); | |
362 } | |
363 | |
364 target.append(FormatStudy(studies[i], '#study?uuid=' + studies[i].ID)); | |
365 } | |
366 | |
367 target.listview('refresh'); | |
368 }); | |
369 }); | |
370 } | |
371 }); | |
372 | |
373 | |
374 $('#study').live('pagebeforeshow', function() { | |
375 if ($.mobile.pageData) { | |
376 GetSingleResource('studies', $.mobile.pageData.uuid, function(study) { | |
377 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
378 GetMultipleResources('series', study.Series, function(series) { | |
379 SortOnDicomTag(series, 'SeriesDate', false, true); | |
380 | |
381 $('#study-info li').remove(); | |
382 $('#study-info') | |
383 .append('<li data-role="list-divider">Patient</li>') | |
384 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
385 .append('<li data-role="list-divider">Study</li>') | |
386 .append(FormatStudy(study)) | |
387 .listview('refresh'); | |
388 | |
389 var target = $('#list-series'); | |
390 $('li', target).remove(); | |
391 for (var i = 0; i < series.length; i++) { | |
392 if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate) | |
393 { | |
394 target.append('<li data-role="list-divider">{0}</li>'.format | |
395 (FormatDicomDate(series[i].MainDicomTags.SeriesDate))); | |
396 } | |
397 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); | |
398 } | |
399 target.listview('refresh'); | |
400 }); | |
401 }); | |
402 }); | |
403 } | |
404 }); | |
405 | |
406 | |
407 $('#series').live('pagebeforeshow', function() { | |
408 if ($.mobile.pageData) { | |
409 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { | |
410 GetSingleResource('studies', series.ParentStudy, function(study) { | |
411 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
412 GetMultipleResources('instances', series.Instances, function(instances) { | |
80 | 413 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
0 | 414 |
415 $('#series-info li').remove(); | |
416 $('#series-info') | |
417 .append('<li data-role="list-divider">Patient</li>') | |
418 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
419 .append('<li data-role="list-divider">Study</li>') | |
420 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) | |
421 .append('<li data-role="list-divider">Series</li>') | |
422 .append(FormatSeries(series)) | |
423 .listview('refresh'); | |
424 | |
425 var target = $('#list-instances'); | |
426 $('li', target).remove(); | |
427 for (var i = 0; i < instances.length; i++) { | |
428 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); | |
429 } | |
430 target.listview('refresh'); | |
431 }); | |
432 }); | |
433 }); | |
434 }); | |
435 } | |
436 }); | |
437 | |
438 | |
439 | |
440 function ConvertForTree(dicom) | |
441 { | |
442 var result = []; | |
443 | |
444 for (var i in dicom) { | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
445 if (dicom[i] != null) { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
446 var label = i + '<span class="tag-name"> (<i>' + dicom[i]["Name"] + '</i>)</span>: '; |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
447 |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
448 if (dicom[i]["Type"] == 'String') |
0 | 449 { |
450 result.push({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
451 label: label + '<strong>' + dicom[i]["Value"] + '</strong>', |
0 | 452 children: [] |
453 }); | |
454 } | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
455 else if (dicom[i]["Type"] == 'TooLong') |
0 | 456 { |
457 result.push({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
458 label: label + '<i>Too long</i>', |
0 | 459 children: [] |
460 }); | |
461 } | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
462 else if (dicom[i]["Type"] == 'Null') |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
463 { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
464 result.push({ |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
465 label: label + '<i>Null</i>', |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
466 children: [] |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
467 }); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
468 } |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
469 else if (dicom[i]["Type"] == 'Sequence') |
0 | 470 { |
471 var c = []; | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
472 for (var j = 0; j < dicom[i]["Value"].length; j++) { |
0 | 473 c.push({ |
474 label: 'Item ' + j, | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
475 children: ConvertForTree(dicom[i]["Value"][j]) |
0 | 476 }); |
477 } | |
478 | |
479 result.push({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
480 label: label + '[]', |
0 | 481 children: c |
482 }); | |
483 } | |
484 } | |
485 } | |
486 | |
487 return result; | |
488 } | |
489 | |
490 | |
491 $('#instance').live('pagebeforeshow', function() { | |
492 if ($.mobile.pageData) { | |
493 GetSingleResource('instances', $.mobile.pageData.uuid, function(instance) { | |
494 GetSingleResource('series', instance.ParentSeries, function(series) { | |
495 GetSingleResource('studies', series.ParentStudy, function(study) { | |
496 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
497 | |
498 $('#instance-info li').remove(); | |
499 $('#instance-info') | |
500 .append('<li data-role="list-divider">Patient</li>') | |
501 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
502 .append('<li data-role="list-divider">Study</li>') | |
503 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) | |
504 .append('<li data-role="list-divider">Series</li>') | |
505 .append(FormatSeries(series, '#series?uuid=' + series.ID, true)) | |
506 .append('<li data-role="list-divider">Instance</li>') | |
507 .append(FormatInstance(instance)) | |
508 .listview('refresh'); | |
509 | |
510 $.ajax({ | |
83 | 511 url: '../instances/' + instance.ID + '/tags', |
0 | 512 dataType: 'json', |
513 success: function(s) { | |
514 $('#dicom-tree').tree('loadData', ConvertForTree(s)); | |
515 } | |
516 }); | |
517 | |
518 }); | |
519 }); | |
520 }); | |
521 }); | |
522 } | |
523 }); | |
524 | |
525 | |
526 | |
527 function DeleteResource(path) | |
528 { | |
529 $.ajax({ | |
530 url: path, | |
531 type: 'DELETE', | |
532 dataType: 'json', | |
533 async: false, | |
534 success: function(s) { | |
535 var ancestor = s.RemainingAncestor; | |
536 if (ancestor == null) | |
537 $.mobile.changePage('#find-patients'); | |
538 else | |
539 $.mobile.changePage('#' + ancestor.Type + '?uuid=' + ancestor.ID); | |
540 } | |
541 }); | |
542 } | |
543 | |
544 | |
545 | |
546 function OpenDeleteResourceDialog(path, title) | |
547 { | |
548 $(document).simpledialog2({ | |
549 // http://dev.jtsage.com/jQM-SimpleDialog/demos2/ | |
550 // http://dev.jtsage.com/jQM-SimpleDialog/demos2/options.html | |
551 mode: 'button', | |
552 animate: false, | |
553 headerText: title, | |
554 headerClose: true, | |
555 width: '500px', | |
556 buttons : { | |
557 'OK': { | |
558 click: function () { | |
559 DeleteResource(path); | |
560 }, | |
561 icon: "delete", | |
562 theme: "c" | |
563 }, | |
564 'Cancel': { | |
565 click: function () { | |
566 } | |
567 } | |
568 } | |
569 }); | |
570 } | |
571 | |
572 | |
573 | |
574 $('#instance-delete').live('click', function() { | |
83 | 575 OpenDeleteResourceDialog('../instances/' + $.mobile.pageData.uuid, |
0 | 576 'Delete this instance?'); |
577 }); | |
578 | |
579 $('#study-delete').live('click', function() { | |
83 | 580 OpenDeleteResourceDialog('../studies/' + $.mobile.pageData.uuid, |
0 | 581 'Delete this study?'); |
582 }); | |
583 | |
584 $('#series-delete').live('click', function() { | |
83 | 585 OpenDeleteResourceDialog('../series/' + $.mobile.pageData.uuid, |
0 | 586 'Delete this series?'); |
587 }); | |
588 | |
589 $('#patient-delete').live('click', function() { | |
83 | 590 OpenDeleteResourceDialog('../patients/' + $.mobile.pageData.uuid, |
0 | 591 'Delete this patient?'); |
592 }); | |
593 | |
594 | |
595 $('#instance-download-dicom').live('click', function(e) { | |
596 // http://stackoverflow.com/a/1296101 | |
597 e.preventDefault(); //stop the browser from following | |
83 | 598 window.location.href = '../instances/' + $.mobile.pageData.uuid + '/file'; |
0 | 599 }); |
600 | |
601 $('#instance-download-json').live('click', function(e) { | |
602 // http://stackoverflow.com/a/1296101 | |
603 e.preventDefault(); //stop the browser from following | |
83 | 604 window.location.href = '../instances/' + $.mobile.pageData.uuid + '/tags'; |
0 | 605 }); |
606 | |
607 | |
608 $('#instance-preview').live('click', function(e) { | |
54
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
609 if ($.mobile.pageData) { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
610 GetSingleResource('instances', $.mobile.pageData.uuid + '/frames', function(frames) { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
611 if (frames.length == 1) |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
612 { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
613 // Viewing a single-frame image |
83 | 614 jQuery.slimbox('../instances/' + $.mobile.pageData.uuid + '/preview', '', { |
54
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
615 overlayFadeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
616 resizeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
617 imageFadeDuration : 1 |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
618 }); |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
619 } |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
620 else |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
621 { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
622 // Viewing a multi-frame image |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
623 |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
624 var images = []; |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
625 for (var i = 0; i < frames.length; i++) { |
83 | 626 images.push([ '../instances/' + $.mobile.pageData.uuid + '/frames/' + i + '/preview' ]); |
54
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
627 } |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
628 |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
629 jQuery.slimbox(images, 0, { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
630 overlayFadeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
631 resizeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
632 imageFadeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
633 loop : true |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
634 }); |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
635 } |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
636 }); |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
637 |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
638 } |
0 | 639 }); |
640 | |
641 $('#series-preview').live('click', function(e) { | |
642 if ($.mobile.pageData) { | |
643 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { | |
644 GetMultipleResources('instances', series.Instances, function(instances) { | |
80 | 645 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
0 | 646 |
647 var images = []; | |
648 for (var i = 0; i < instances.length; i++) { | |
83 | 649 images.push([ '../instances/' + instances[i].ID + '/preview', |
0 | 650 '{0}/{1}'.format(i + 1, instances.length) ]) |
651 } | |
652 | |
653 jQuery.slimbox(images, 0, { | |
654 overlayFadeDuration : 1, | |
655 resizeDuration : 1, | |
656 imageFadeDuration : 1, | |
657 loop : true | |
658 }); | |
659 }) | |
660 }); | |
661 } | |
662 }); | |
663 | |
664 | |
665 | |
666 | |
667 | |
668 | |
669 function ChooseDicomModality(callback) | |
670 { | |
671 $.ajax({ | |
83 | 672 url: '../modalities', |
0 | 673 type: 'GET', |
674 dataType: 'json', | |
675 async: false, | |
676 success: function(modalities) { | |
677 var clickedModality = ''; | |
678 var items = $('<ul>') | |
679 .attr('data-role', 'listview'); | |
680 | |
681 for (var i = 0; i < modalities.length; i++) { | |
682 var modality = modalities[i]; | |
683 var item = $('<li>') | |
684 .html('<a href="#" rel="close">' + modality + '</a>') | |
685 .attr('modality', modality) | |
686 .click(function() { | |
687 clickedModality = $(this).attr('modality'); | |
688 }); | |
689 items.append(item); | |
690 } | |
691 | |
692 $('#dialog').simpledialog2({ | |
693 mode: 'blank', | |
694 animate: false, | |
695 headerText: 'DICOM modality', | |
696 headerClose: true, | |
697 width: '100%', | |
698 blankContent: items, | |
699 callbackClose: function() { | |
700 var timer; | |
701 function WaitForDialogToClose() { | |
702 if (!$('#dialog').is(':visible')) { | |
703 clearInterval(timer); | |
704 callback(clickedModality); | |
705 } | |
706 } | |
707 timer = setInterval(WaitForDialogToClose, 100); | |
708 } | |
709 }); | |
710 } | |
711 }); | |
712 } | |
713 | |
714 | |
715 $('#instance-store,#series-store').live('click', function(e) { | |
716 ChooseDicomModality(function(modality) { | |
717 if (modality != '') { | |
718 $.ajax({ | |
83 | 719 url: '../modalities/' + modality + '/store', |
0 | 720 type: 'POST', |
721 dataType: 'text', | |
722 data: $.mobile.pageData.uuid, | |
723 async: true, // Necessary to block UI | |
724 beforeSend: function() { | |
725 $.blockUI({ message: $('#loading') }); | |
726 }, | |
727 complete: function(s) { | |
728 $.unblockUI(); | |
729 }, | |
730 success: function(s) { | |
731 console.log('done !'); | |
732 }, | |
733 error: function() { | |
734 alert('Error during C-Store'); | |
735 } | |
736 }); | |
737 | |
738 } | |
739 }); | |
740 }); | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
741 |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
742 |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
743 $('#show-tag-name').live('change', function(e) { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
744 var checked = e.currentTarget.checked; |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
745 if (checked) |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
746 $('.tag-name').show(); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
747 else |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
748 $('.tag-name').hide(); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
749 }); |