Mercurial > hg > orthanc
annotate OrthancExplorer/explorer.js @ 80:6212bf978584
status of series
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 Sep 2012 15:18:12 +0200 |
parents | 4bc019d2f969 |
children | 9eb40cad7935 |
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({ | |
144 url: '/' + type + '/' + uuid, | |
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({ | |
159 url: '/' + type, | |
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({ | |
171 url: '/' + type + '/' + uuid, | |
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; |
277 if (series.Instances.length == series.ExpectedNumberOfInstances) | |
278 { | |
279 c = series.ExpectedNumberOfInstances; | |
280 } | |
281 else | |
282 { | |
283 c = series.Instances.length + '/' + series.ExpectedNumberOfInstances; | |
284 } | |
285 | |
286 var s = ('<h3>{0}</h3>' + | |
287 '<p><em>Status: <strong>{1}</strong></em></p>{2}' + | |
288 '<span class="ui-li-count">{3}</span>').format | |
0 | 289 (series.MainDicomTags.SeriesDescription, |
80 | 290 series.Status, |
40 | 291 FormatMainDicomTags(series.MainDicomTags, [ |
292 "SeriesDescription", | |
293 "SeriesTime", | |
41
c1097a676eca
better naming for preview images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
294 "Manufacturer", |
c1097a676eca
better naming for preview images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
295 "ImagesInAcquisition", |
40 | 296 "SeriesDate" |
297 ]), | |
80 | 298 c |
0 | 299 ); |
300 | |
301 return CompleteFormatting(s, link, isReverse); | |
302 } | |
303 | |
304 | |
305 function FormatInstance(instance, link, isReverse) | |
306 { | |
40 | 307 var s = ('<h3>Instance {0}</h3>{1}').format |
80 | 308 (instance.IndexInSeries, |
40 | 309 FormatMainDicomTags(instance.MainDicomTags, [ |
310 "AcquisitionNumber", | |
311 "InstanceNumber", | |
312 "InstanceCreationDate", | |
313 "InstanceCreationTime" | |
314 ]) | |
0 | 315 ); |
316 | |
317 return CompleteFormatting(s, link, isReverse); | |
318 } | |
319 | |
320 | |
321 | |
322 | |
323 $('#find-patients').live('pagebeforeshow', function() { | |
324 GetMultipleResources('patients', null, function(patients) { | |
325 var target = $('#all-patients'); | |
326 $('li', target).remove(); | |
327 | |
328 SortOnDicomTag(patients, 'PatientName', false, false); | |
329 | |
330 for (var i = 0; i < patients.length; i++) { | |
331 var p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID); | |
332 target.append(p); | |
333 } | |
334 | |
335 target.listview('refresh'); | |
336 }); | |
337 }); | |
338 | |
339 | |
340 | |
341 $('#patient').live('pagebeforeshow', function() { | |
342 if ($.mobile.pageData) { | |
343 GetSingleResource('patients', $.mobile.pageData.uuid, function(patient) { | |
344 GetMultipleResources('studies', patient.Studies, function(studies) { | |
345 SortOnDicomTag(studies, 'StudyDate', false, true); | |
346 | |
347 $('#patient-info li').remove(); | |
348 $('#patient-info') | |
349 .append('<li data-role="list-divider">Patient</li>') | |
350 .append(FormatPatient(patient)) | |
351 .listview('refresh'); | |
352 | |
353 var target = $('#list-studies'); | |
354 $('li', target).remove(); | |
355 | |
356 for (var i = 0; i < studies.length; i++) { | |
357 if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate) | |
358 { | |
359 target.append('<li data-role="list-divider">{0}</li>'.format | |
360 (FormatDicomDate(studies[i].MainDicomTags.StudyDate))); | |
361 } | |
362 | |
363 target.append(FormatStudy(studies[i], '#study?uuid=' + studies[i].ID)); | |
364 } | |
365 | |
366 target.listview('refresh'); | |
367 }); | |
368 }); | |
369 } | |
370 }); | |
371 | |
372 | |
373 $('#study').live('pagebeforeshow', function() { | |
374 if ($.mobile.pageData) { | |
375 GetSingleResource('studies', $.mobile.pageData.uuid, function(study) { | |
376 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
377 GetMultipleResources('series', study.Series, function(series) { | |
378 SortOnDicomTag(series, 'SeriesDate', false, true); | |
379 | |
380 $('#study-info li').remove(); | |
381 $('#study-info') | |
382 .append('<li data-role="list-divider">Patient</li>') | |
383 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
384 .append('<li data-role="list-divider">Study</li>') | |
385 .append(FormatStudy(study)) | |
386 .listview('refresh'); | |
387 | |
388 var target = $('#list-series'); | |
389 $('li', target).remove(); | |
390 for (var i = 0; i < series.length; i++) { | |
391 if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate) | |
392 { | |
393 target.append('<li data-role="list-divider">{0}</li>'.format | |
394 (FormatDicomDate(series[i].MainDicomTags.SeriesDate))); | |
395 } | |
396 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); | |
397 } | |
398 target.listview('refresh'); | |
399 }); | |
400 }); | |
401 }); | |
402 } | |
403 }); | |
404 | |
405 | |
406 $('#series').live('pagebeforeshow', function() { | |
407 if ($.mobile.pageData) { | |
408 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { | |
409 GetSingleResource('studies', series.ParentStudy, function(study) { | |
410 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
411 GetMultipleResources('instances', series.Instances, function(instances) { | |
80 | 412 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
0 | 413 |
414 $('#series-info li').remove(); | |
415 $('#series-info') | |
416 .append('<li data-role="list-divider">Patient</li>') | |
417 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
418 .append('<li data-role="list-divider">Study</li>') | |
419 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) | |
420 .append('<li data-role="list-divider">Series</li>') | |
421 .append(FormatSeries(series)) | |
422 .listview('refresh'); | |
423 | |
424 var target = $('#list-instances'); | |
425 $('li', target).remove(); | |
426 for (var i = 0; i < instances.length; i++) { | |
427 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); | |
428 } | |
429 target.listview('refresh'); | |
430 }); | |
431 }); | |
432 }); | |
433 }); | |
434 } | |
435 }); | |
436 | |
437 | |
438 | |
439 function ConvertForTree(dicom) | |
440 { | |
441 var result = []; | |
442 | |
443 for (var i in dicom) { | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
444 if (dicom[i] != null) { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
445 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
|
446 |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
447 if (dicom[i]["Type"] == 'String') |
0 | 448 { |
449 result.push({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
450 label: label + '<strong>' + dicom[i]["Value"] + '</strong>', |
0 | 451 children: [] |
452 }); | |
453 } | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
454 else if (dicom[i]["Type"] == 'TooLong') |
0 | 455 { |
456 result.push({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
457 label: label + '<i>Too long</i>', |
0 | 458 children: [] |
459 }); | |
460 } | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
461 else if (dicom[i]["Type"] == 'Null') |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
462 { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
463 result.push({ |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
464 label: label + '<i>Null</i>', |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
465 children: [] |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
466 }); |
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 else if (dicom[i]["Type"] == 'Sequence') |
0 | 469 { |
470 var c = []; | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
471 for (var j = 0; j < dicom[i]["Value"].length; j++) { |
0 | 472 c.push({ |
473 label: 'Item ' + j, | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
474 children: ConvertForTree(dicom[i]["Value"][j]) |
0 | 475 }); |
476 } | |
477 | |
478 result.push({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
479 label: label + '[]', |
0 | 480 children: c |
481 }); | |
482 } | |
483 } | |
484 } | |
485 | |
486 return result; | |
487 } | |
488 | |
489 | |
490 $('#instance').live('pagebeforeshow', function() { | |
491 if ($.mobile.pageData) { | |
492 GetSingleResource('instances', $.mobile.pageData.uuid, function(instance) { | |
493 GetSingleResource('series', instance.ParentSeries, function(series) { | |
494 GetSingleResource('studies', series.ParentStudy, function(study) { | |
495 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
496 | |
497 $('#instance-info li').remove(); | |
498 $('#instance-info') | |
499 .append('<li data-role="list-divider">Patient</li>') | |
500 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
501 .append('<li data-role="list-divider">Study</li>') | |
502 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) | |
503 .append('<li data-role="list-divider">Series</li>') | |
504 .append(FormatSeries(series, '#series?uuid=' + series.ID, true)) | |
505 .append('<li data-role="list-divider">Instance</li>') | |
506 .append(FormatInstance(instance)) | |
507 .listview('refresh'); | |
508 | |
509 $.ajax({ | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
510 url: '/instances/' + instance.ID + '/tags', |
0 | 511 dataType: 'json', |
512 success: function(s) { | |
513 $('#dicom-tree').tree('loadData', ConvertForTree(s)); | |
514 } | |
515 }); | |
516 | |
517 }); | |
518 }); | |
519 }); | |
520 }); | |
521 } | |
522 }); | |
523 | |
524 | |
525 | |
526 function DeleteResource(path) | |
527 { | |
528 $.ajax({ | |
529 url: path, | |
530 type: 'DELETE', | |
531 dataType: 'json', | |
532 async: false, | |
533 success: function(s) { | |
534 var ancestor = s.RemainingAncestor; | |
535 if (ancestor == null) | |
536 $.mobile.changePage('#find-patients'); | |
537 else | |
538 $.mobile.changePage('#' + ancestor.Type + '?uuid=' + ancestor.ID); | |
539 } | |
540 }); | |
541 } | |
542 | |
543 | |
544 | |
545 function OpenDeleteResourceDialog(path, title) | |
546 { | |
547 $(document).simpledialog2({ | |
548 // http://dev.jtsage.com/jQM-SimpleDialog/demos2/ | |
549 // http://dev.jtsage.com/jQM-SimpleDialog/demos2/options.html | |
550 mode: 'button', | |
551 animate: false, | |
552 headerText: title, | |
553 headerClose: true, | |
554 width: '500px', | |
555 buttons : { | |
556 'OK': { | |
557 click: function () { | |
558 DeleteResource(path); | |
559 }, | |
560 icon: "delete", | |
561 theme: "c" | |
562 }, | |
563 'Cancel': { | |
564 click: function () { | |
565 } | |
566 } | |
567 } | |
568 }); | |
569 } | |
570 | |
571 | |
572 | |
573 $('#instance-delete').live('click', function() { | |
574 OpenDeleteResourceDialog('/instances/' + $.mobile.pageData.uuid, | |
575 'Delete this instance?'); | |
576 }); | |
577 | |
578 $('#study-delete').live('click', function() { | |
579 OpenDeleteResourceDialog('/studies/' + $.mobile.pageData.uuid, | |
580 'Delete this study?'); | |
581 }); | |
582 | |
583 $('#series-delete').live('click', function() { | |
584 OpenDeleteResourceDialog('/series/' + $.mobile.pageData.uuid, | |
585 'Delete this series?'); | |
586 }); | |
587 | |
588 $('#patient-delete').live('click', function() { | |
589 OpenDeleteResourceDialog('/patients/' + $.mobile.pageData.uuid, | |
590 'Delete this patient?'); | |
591 }); | |
592 | |
593 | |
594 $('#instance-download-dicom').live('click', function(e) { | |
595 // http://stackoverflow.com/a/1296101 | |
596 e.preventDefault(); //stop the browser from following | |
597 window.location.href = '/instances/' + $.mobile.pageData.uuid + '/file'; | |
598 }); | |
599 | |
600 $('#instance-download-json').live('click', function(e) { | |
601 // http://stackoverflow.com/a/1296101 | |
602 e.preventDefault(); //stop the browser from following | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
603 window.location.href = '/instances/' + $.mobile.pageData.uuid + '/tags'; |
0 | 604 }); |
605 | |
606 | |
607 $('#instance-preview').live('click', function(e) { | |
54
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
608 if ($.mobile.pageData) { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
609 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
|
610 if (frames.length == 1) |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
611 { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
612 // Viewing a single-frame image |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
613 jQuery.slimbox('/instances/' + $.mobile.pageData.uuid + '/preview', '', { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
614 overlayFadeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
615 resizeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
616 imageFadeDuration : 1 |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
617 }); |
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 else |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
620 { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
621 // Viewing a multi-frame image |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
622 |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
623 var images = []; |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
624 for (var i = 0; i < frames.length; i++) { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
625 images.push([ '/instances/' + $.mobile.pageData.uuid + '/frames/' + i + '/preview' ]); |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
626 } |
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 jQuery.slimbox(images, 0, { |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
629 overlayFadeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
630 resizeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
631 imageFadeDuration : 1, |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
632 loop : true |
42a449dac415
multi-frame images in the explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
633 }); |
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 } |
0 | 638 }); |
639 | |
640 $('#series-preview').live('click', function(e) { | |
641 if ($.mobile.pageData) { | |
642 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { | |
643 GetMultipleResources('instances', series.Instances, function(instances) { | |
80 | 644 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
0 | 645 |
646 var images = []; | |
647 for (var i = 0; i < instances.length; i++) { | |
41
c1097a676eca
better naming for preview images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
40
diff
changeset
|
648 images.push([ '/instances/' + instances[i].ID + '/preview', |
0 | 649 '{0}/{1}'.format(i + 1, instances.length) ]) |
650 } | |
651 | |
652 jQuery.slimbox(images, 0, { | |
653 overlayFadeDuration : 1, | |
654 resizeDuration : 1, | |
655 imageFadeDuration : 1, | |
656 loop : true | |
657 }); | |
658 }) | |
659 }); | |
660 } | |
661 }); | |
662 | |
663 | |
664 | |
665 | |
666 | |
667 | |
668 function ChooseDicomModality(callback) | |
669 { | |
670 $.ajax({ | |
671 url: '/modalities', | |
672 type: 'GET', | |
673 dataType: 'json', | |
674 async: false, | |
675 success: function(modalities) { | |
676 var clickedModality = ''; | |
677 var items = $('<ul>') | |
678 .attr('data-role', 'listview'); | |
679 | |
680 for (var i = 0; i < modalities.length; i++) { | |
681 var modality = modalities[i]; | |
682 var item = $('<li>') | |
683 .html('<a href="#" rel="close">' + modality + '</a>') | |
684 .attr('modality', modality) | |
685 .click(function() { | |
686 clickedModality = $(this).attr('modality'); | |
687 }); | |
688 items.append(item); | |
689 } | |
690 | |
691 $('#dialog').simpledialog2({ | |
692 mode: 'blank', | |
693 animate: false, | |
694 headerText: 'DICOM modality', | |
695 headerClose: true, | |
696 width: '100%', | |
697 blankContent: items, | |
698 callbackClose: function() { | |
699 var timer; | |
700 function WaitForDialogToClose() { | |
701 if (!$('#dialog').is(':visible')) { | |
702 clearInterval(timer); | |
703 callback(clickedModality); | |
704 } | |
705 } | |
706 timer = setInterval(WaitForDialogToClose, 100); | |
707 } | |
708 }); | |
709 } | |
710 }); | |
711 } | |
712 | |
713 | |
714 $('#instance-store,#series-store').live('click', function(e) { | |
715 ChooseDicomModality(function(modality) { | |
716 if (modality != '') { | |
717 $.ajax({ | |
718 url: '/modalities/' + modality + '/store', | |
719 type: 'POST', | |
720 dataType: 'text', | |
721 data: $.mobile.pageData.uuid, | |
722 async: true, // Necessary to block UI | |
723 beforeSend: function() { | |
724 $.blockUI({ message: $('#loading') }); | |
725 }, | |
726 complete: function(s) { | |
727 $.unblockUI(); | |
728 }, | |
729 success: function(s) { | |
730 console.log('done !'); | |
731 }, | |
732 error: function() { | |
733 alert('Error during C-Store'); | |
734 } | |
735 }); | |
736 | |
737 } | |
738 }); | |
739 }); | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
740 |
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 $('#show-tag-name').live('change', function(e) { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
743 var checked = e.currentTarget.checked; |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
744 if (checked) |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
745 $('.tag-name').show(); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
746 else |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
747 $('.tag-name').hide(); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
748 }); |