comparison OrthancExplorer/explorer.js @ 3023:c9c2faf76bec

replaced 'var' by 'let' in Orthanc Explorer's JavaScript
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 17 Dec 2018 10:22:51 +0100
parents e0c620f964e5
children b89a4288d605
comparison
equal deleted inserted replaced
3021:2cbafb5d5a62 3023:c9c2faf76bec
25 } 25 }
26 26
27 27
28 function ChangePage(page, options) 28 function ChangePage(page, options)
29 { 29 {
30 var first = true; 30 let first = true;
31 if (options) { 31 if (options) {
32 for (var key in options) { 32 for (let key in options) {
33 var value = options[key]; 33 let value = options[key];
34 if (first) { 34 if (first) {
35 page += '?'; 35 page += '?';
36 first = false; 36 first = false;
37 } else { 37 } else {
38 page += '&'; 38 page += '&';
61 RefreshInstance(); 61 RefreshInstance();
62 } 62 }
63 63
64 64
65 $(document).ready(function() { 65 $(document).ready(function() {
66 var $tree = $('#dicom-tree'); 66 let $tree = $('#dicom-tree');
67 $tree.tree({ 67 $tree.tree({
68 autoEscape: false 68 autoEscape: false
69 }); 69 });
70 70
71 $('#dicom-tree').bind( 71 $('#dicom-tree').bind(
122 function FormatDicomDate(s) 122 function FormatDicomDate(s)
123 { 123 {
124 if (s == undefined) 124 if (s == undefined)
125 return "No date"; 125 return "No date";
126 126
127 var d = ParseDicomDate(s); 127 let d = ParseDicomDate(s);
128 if (d == null) 128 if (d == null)
129 return '?'; 129 return '?';
130 else 130 else
131 return d.toString('dddd, MMMM d, yyyy'); 131 return d.toString('dddd, MMMM d, yyyy');
132 } 132 }
133 133
134 134
135 function Sort(arr, fieldExtractor, isInteger, reverse) 135 function Sort(arr, fieldExtractor, isInteger, reverse)
136 { 136 {
137 var defaultValue; 137 let defaultValue;
138 if (isInteger) 138 if (isInteger)
139 defaultValue = 0; 139 defaultValue = 0;
140 else 140 else
141 defaultValue = ''; 141 defaultValue = '';
142 142
143 arr.sort(function(a, b) { 143 arr.sort(function(a, b) {
144 var ta = fieldExtractor(a); 144 let ta = fieldExtractor(a);
145 var tb = fieldExtractor(b); 145 let tb = fieldExtractor(b);
146 var order; 146 let order;
147 147
148 if (ta == undefined) 148 if (ta == undefined)
149 ta = defaultValue; 149 ta = defaultValue;
150 150
151 if (tb == undefined) 151 if (tb == undefined)
224 } 224 }
225 225
226 226
227 function FormatMainDicomTags(target, tags, tagsToIgnore) 227 function FormatMainDicomTags(target, tags, tagsToIgnore)
228 { 228 {
229 for (var i in tags) 229 for (let i in tags)
230 { 230 {
231 if (tagsToIgnore.indexOf(i) == -1) 231 if (tagsToIgnore.indexOf(i) == -1)
232 { 232 {
233 var v = tags[i]; 233 let v = tags[i];
234 234
235 if (i == "PatientBirthDate" || 235 if (i == "PatientBirthDate" ||
236 i == "StudyDate" || 236 i == "StudyDate" ||
237 i == "SeriesDate") 237 i == "SeriesDate")
238 { 238 {
252 } 252 }
253 253
254 254
255 function FormatPatient(patient, link, isReverse) 255 function FormatPatient(patient, link, isReverse)
256 { 256 {
257 var node = $('<div>').append($('<h3>').text(patient.MainDicomTags.PatientName)); 257 let node = $('<div>').append($('<h3>').text(patient.MainDicomTags.PatientName));
258 258
259 FormatMainDicomTags(node, patient.MainDicomTags, [ 259 FormatMainDicomTags(node, patient.MainDicomTags, [
260 "PatientName" 260 "PatientName"
261 // "OtherPatientIDs" 261 // "OtherPatientIDs"
262 ]); 262 ]);
266 266
267 267
268 268
269 function FormatStudy(study, link, isReverse, includePatient) 269 function FormatStudy(study, link, isReverse, includePatient)
270 { 270 {
271 var label; 271 let label;
272 272
273 if (includePatient) { 273 if (includePatient) {
274 label = study.Label; 274 label = study.Label;
275 } else { 275 } else {
276 label = study.MainDicomTags.StudyDescription; 276 label = study.MainDicomTags.StudyDescription;
277 } 277 }
278 278
279 var node = $('<div>').append($('<h3>').text(label)); 279 let node = $('<div>').append($('<h3>').text(label));
280 280
281 if (includePatient) { 281 if (includePatient) {
282 FormatMainDicomTags(node, study.PatientMainDicomTags, [ 282 FormatMainDicomTags(node, study.PatientMainDicomTags, [
283 'PatientName' 283 'PatientName'
284 ]); 284 ]);
294 294
295 295
296 296
297 function FormatSeries(series, link, isReverse) 297 function FormatSeries(series, link, isReverse)
298 { 298 {
299 var c; 299 let c;
300 if (series.ExpectedNumberOfInstances == null || 300 if (series.ExpectedNumberOfInstances == null ||
301 series.Instances.length == series.ExpectedNumberOfInstances) 301 series.Instances.length == series.ExpectedNumberOfInstances)
302 { 302 {
303 c = series.Instances.length; 303 c = series.Instances.length;
304 } 304 }
305 else 305 else
306 { 306 {
307 c = series.Instances.length + '/' + series.ExpectedNumberOfInstances; 307 c = series.Instances.length + '/' + series.ExpectedNumberOfInstances;
308 } 308 }
309 309
310 var node = $('<div>') 310 let node = $('<div>')
311 .append($('<h3>').text(series.MainDicomTags.SeriesDescription)) 311 .append($('<h3>').text(series.MainDicomTags.SeriesDescription))
312 .append($('<p>').append($('<em>') 312 .append($('<p>').append($('<em>')
313 .text('Status: ') 313 .text('Status: ')
314 .append($('<strong>').text(series.Status)))); 314 .append($('<strong>').text(series.Status))));
315 315
326 } 326 }
327 327
328 328
329 function FormatInstance(instance, link, isReverse) 329 function FormatInstance(instance, link, isReverse)
330 { 330 {
331 var node = $('<div>').append($('<h3>').text('Instance: ' + instance.IndexInSeries)); 331 let node = $('<div>').append($('<h3>').text('Instance: ' + instance.IndexInSeries));
332 332
333 FormatMainDicomTags(node, instance.MainDicomTags, [ 333 FormatMainDicomTags(node, instance.MainDicomTags, [
334 "AcquisitionNumber", 334 "AcquisitionNumber",
335 "InstanceNumber", 335 "InstanceNumber",
336 "InstanceCreationDate", 336 "InstanceCreationDate",
362 362
363 363
364 364
365 $('#lookup').live('pagebeforeshow', function() { 365 $('#lookup').live('pagebeforeshow', function() {
366 // NB: "GenerateDicomDate()" is defined in "query-retrieve.js" 366 // NB: "GenerateDicomDate()" is defined in "query-retrieve.js"
367 var target = $('#lookup-study-date'); 367 let target = $('#lookup-study-date');
368 $('option', target).remove(); 368 $('option', target).remove();
369 target.append($('<option>').attr('value', '*').text('Any date')); 369 target.append($('<option>').attr('value', '*').text('Any date'));
370 target.append($('<option>').attr('value', GenerateDicomDate(0)).text('Today')); 370 target.append($('<option>').attr('value', GenerateDicomDate(0)).text('Today'));
371 target.append($('<option>').attr('value', GenerateDicomDate(-1)).text('Yesterday')); 371 target.append($('<option>').attr('value', GenerateDicomDate(-1)).text('Yesterday'));
372 target.append($('<option>').attr('value', GenerateDicomDate(-7) + '-').text('Last 7 days')); 372 target.append($('<option>').attr('value', GenerateDicomDate(-7) + '-').text('Last 7 days'));
380 380
381 381
382 $('#lookup-submit').live('click', function() { 382 $('#lookup-submit').live('click', function() {
383 $('#lookup-result').hide(); 383 $('#lookup-result').hide();
384 384
385 var lookup = { 385 let lookup = {
386 'Level' : 'Study', 386 'Level' : 'Study',
387 'Expand' : true, 387 'Expand' : true,
388 'Limit' : LIMIT_RESOURCES + 1, 388 'Limit' : LIMIT_RESOURCES + 1,
389 'Query' : { 389 'Query' : {
390 'StudyDate' : $('#lookup-study-date').val() 390 'StudyDate' : $('#lookup-study-date').val()
430 }); 430 });
431 431
432 432
433 $('#find-patients').live('pagebeforeshow', function() { 433 $('#find-patients').live('pagebeforeshow', function() {
434 GetResource('/patients?expand&since=0&limit=' + (LIMIT_RESOURCES + 1), function(patients) { 434 GetResource('/patients?expand&since=0&limit=' + (LIMIT_RESOURCES + 1), function(patients) {
435 var target = $('#all-patients'); 435 let target = $('#all-patients');
436 $('li', target).remove(); 436 $('li', target).remove();
437 437
438 SortOnDicomTag(patients, 'PatientName', false, false); 438 SortOnDicomTag(patients, 'PatientName', false, false);
439 439
440 var count, showAlert; 440 let count, showAlert;
441 if (patients.length <= LIMIT_RESOURCES) { 441 if (patients.length <= LIMIT_RESOURCES) {
442 count = patients.length; 442 count = patients.length;
443 showAlert = false; 443 showAlert = false;
444 } 444 }
445 else { 445 else {
446 count = LIMIT_RESOURCES; 446 count = LIMIT_RESOURCES;
447 showAlert = true; 447 showAlert = true;
448 } 448 }
449 449
450 for (var i = 0; i < count; i++) { 450 for (let i = 0; i < count; i++) {
451 var p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID); 451 let p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID);
452 target.append(p); 452 target.append(p);
453 } 453 }
454 454
455 target.listview('refresh'); 455 target.listview('refresh');
456 456
465 465
466 466
467 467
468 function FormatListOfStudies(targetId, alertId, countId, studies) 468 function FormatListOfStudies(targetId, alertId, countId, studies)
469 { 469 {
470 var target = $(targetId); 470 let target = $(targetId);
471 $('li', target).remove(); 471 $('li', target).remove();
472 472
473 for (var i = 0; i < studies.length; i++) { 473 for (let i = 0; i < studies.length; i++) {
474 var patient = studies[i].PatientMainDicomTags.PatientName; 474 let patient = studies[i].PatientMainDicomTags.PatientName;
475 var study = studies[i].MainDicomTags.StudyDescription; 475 let study = studies[i].MainDicomTags.StudyDescription;
476 476
477 var s; 477 let s;
478 if (typeof patient === 'string') { 478 if (typeof patient === 'string') {
479 s = patient; 479 s = patient;
480 } 480 }
481 481
482 if (typeof study === 'string') { 482 if (typeof study === 'string') {
491 } 491 }
492 492
493 Sort(studies, function(a) { return a.Label }, false, false); 493 Sort(studies, function(a) { return a.Label }, false, false);
494 494
495 495
496 var count, showAlert; 496 let count, showAlert;
497 if (studies.length <= LIMIT_RESOURCES) { 497 if (studies.length <= LIMIT_RESOURCES) {
498 count = studies.length; 498 count = studies.length;
499 showAlert = false; 499 showAlert = false;
500 } 500 }
501 else { 501 else {
502 count = LIMIT_RESOURCES; 502 count = LIMIT_RESOURCES;
503 showAlert = true; 503 showAlert = true;
504 } 504 }
505 505
506 for (var i = 0; i < count; i++) { 506 for (let i = 0; i < count; i++) {
507 var p = FormatStudy(studies[i], '#study?uuid=' + studies[i].ID, false, true); 507 let p = FormatStudy(studies[i], '#study?uuid=' + studies[i].ID, false, true);
508 target.append(p); 508 target.append(p);
509 } 509 }
510 510
511 target.listview('refresh'); 511 target.listview('refresh');
512 512
545 545
546 546
547 function RefreshPatient() 547 function RefreshPatient()
548 { 548 {
549 if ($.mobile.pageData) { 549 if ($.mobile.pageData) {
550 var pageData = DeepCopy($.mobile.pageData); 550 let pageData = DeepCopy($.mobile.pageData);
551 551
552 GetResource('/patients/' + pageData.uuid, function(patient) { 552 GetResource('/patients/' + pageData.uuid, function(patient) {
553 GetResource('/patients/' + pageData.uuid + '/studies', function(studies) { 553 GetResource('/patients/' + pageData.uuid + '/studies', function(studies) {
554 SortOnDicomTag(studies, 'StudyDate', false, true); 554 SortOnDicomTag(studies, 'StudyDate', false, true);
555 555
557 $('#patient-info') 557 $('#patient-info')
558 .append('<li data-role="list-divider">Patient</li>') 558 .append('<li data-role="list-divider">Patient</li>')
559 .append(FormatPatient(patient)) 559 .append(FormatPatient(patient))
560 .listview('refresh'); 560 .listview('refresh');
561 561
562 var target = $('#list-studies'); 562 let target = $('#list-studies');
563 $('li', target).remove(); 563 $('li', target).remove();
564 564
565 for (var i = 0; i < studies.length; i++) { 565 for (let i = 0; i < studies.length; i++) {
566 if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate) 566 if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate)
567 { 567 {
568 target.append($('<li>') 568 target.append($('<li>')
569 .attr('data-role', 'list-divider') 569 .attr('data-role', 'list-divider')
570 .text(FormatDicomDate(studies[i].MainDicomTags.StudyDate))); 570 .text(FormatDicomDate(studies[i].MainDicomTags.StudyDate)));
584 type: 'GET', 584 type: 'GET',
585 dataType: 'text', 585 dataType: 'text',
586 async: false, 586 async: false,
587 cache: false, 587 cache: false,
588 success: function (s) { 588 success: function (s) {
589 var v = (s == '1') ? 'on' : 'off'; 589 let v = (s == '1') ? 'on' : 'off';
590 $('#protection').val(v).slider('refresh'); 590 $('#protection').val(v).slider('refresh');
591 } 591 }
592 }); 592 });
593 593
594 currentPage = 'patient'; 594 currentPage = 'patient';
600 600
601 601
602 function RefreshStudy() 602 function RefreshStudy()
603 { 603 {
604 if ($.mobile.pageData) { 604 if ($.mobile.pageData) {
605 var pageData = DeepCopy($.mobile.pageData); 605 let pageData = DeepCopy($.mobile.pageData);
606 606
607 GetResource('/studies/' + pageData.uuid, function(study) { 607 GetResource('/studies/' + pageData.uuid, function(study) {
608 GetResource('/patients/' + study.ParentPatient, function(patient) { 608 GetResource('/patients/' + study.ParentPatient, function(patient) {
609 GetResource('/studies/' + pageData.uuid + '/series', function(series) { 609 GetResource('/studies/' + pageData.uuid + '/series', function(series) {
610 SortOnDicomTag(series, 'SeriesDate', false, true); 610 SortOnDicomTag(series, 'SeriesDate', false, true);
619 .listview('refresh'); 619 .listview('refresh');
620 620
621 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', 'AnonymizedFrom'); 621 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', 'AnonymizedFrom');
622 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', 'ModifiedFrom'); 622 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', 'ModifiedFrom');
623 623
624 var target = $('#list-series'); 624 let target = $('#list-series');
625 $('li', target).remove(); 625 $('li', target).remove();
626 for (var i = 0; i < series.length; i++) { 626 for (let i = 0; i < series.length; i++) {
627 if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate) 627 if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate)
628 { 628 {
629 target.append($('<li>') 629 target.append($('<li>')
630 .attr('data-role', 'list-divider') 630 .attr('data-role', 'list-divider')
631 .text(FormatDicomDate(series[i].MainDicomTags.SeriesDate))); 631 .text(FormatDicomDate(series[i].MainDicomTags.SeriesDate)));
645 645
646 646
647 function RefreshSeries() 647 function RefreshSeries()
648 { 648 {
649 if ($.mobile.pageData) { 649 if ($.mobile.pageData) {
650 var pageData = DeepCopy($.mobile.pageData); 650 let pageData = DeepCopy($.mobile.pageData);
651 651
652 GetResource('/series/' + pageData.uuid, function(series) { 652 GetResource('/series/' + pageData.uuid, function(series) {
653 GetResource('/studies/' + series.ParentStudy, function(study) { 653 GetResource('/studies/' + series.ParentStudy, function(study) {
654 GetResource('/patients/' + study.ParentPatient, function(patient) { 654 GetResource('/patients/' + study.ParentPatient, function(patient) {
655 GetResource('/series/' + pageData.uuid + '/instances', function(instances) { 655 GetResource('/series/' + pageData.uuid + '/instances', function(instances) {
669 .listview('refresh'); 669 .listview('refresh');
670 670
671 SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', 'AnonymizedFrom'); 671 SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', 'AnonymizedFrom');
672 SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', 'ModifiedFrom'); 672 SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', 'ModifiedFrom');
673 673
674 var target = $('#list-instances'); 674 let target = $('#list-instances');
675 $('li', target).remove(); 675 $('li', target).remove();
676 for (var i = 0; i < instances.length; i++) { 676 for (let i = 0; i < instances.length; i++) {
677 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); 677 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID));
678 } 678 }
679 target.listview('refresh'); 679 target.listview('refresh');
680 680
681 currentPage = 'series'; 681 currentPage = 'series';
688 } 688 }
689 689
690 690
691 function EscapeHtml(value) 691 function EscapeHtml(value)
692 { 692 {
693 var ENTITY_MAP = { 693 let ENTITY_MAP = {
694 '&': '&amp;', 694 '&': '&amp;',
695 '<': '&lt;', 695 '<': '&lt;',
696 '>': '&gt;', 696 '>': '&gt;',
697 '"': '&quot;', 697 '"': '&quot;',
698 "'": '&#39;', 698 "'": '&#39;',
707 } 707 }
708 708
709 709
710 function ConvertForTree(dicom) 710 function ConvertForTree(dicom)
711 { 711 {
712 var result = []; 712 let result = [];
713 713
714 for (var i in dicom) { 714 for (let i in dicom) {
715 if (dicom[i] != null) { 715 if (dicom[i] != null) {
716 var label = (i + '<span class="tag-name"> (<i>' + 716 let label = (i + '<span class="tag-name"> (<i>' +
717 EscapeHtml(dicom[i]["Name"]) + 717 EscapeHtml(dicom[i]["Name"]) +
718 '</i>)</span>: '); 718 '</i>)</span>: ');
719 719
720 if (dicom[i]["Type"] == 'String') 720 if (dicom[i]["Type"] == 'String')
721 { 721 {
738 children: [] 738 children: []
739 }); 739 });
740 } 740 }
741 else if (dicom[i]["Type"] == 'Sequence') 741 else if (dicom[i]["Type"] == 'Sequence')
742 { 742 {
743 var c = []; 743 let c = [];
744 for (var j = 0; j < dicom[i]["Value"].length; j++) { 744 for (let j = 0; j < dicom[i]["Value"].length; j++) {
745 c.push({ 745 c.push({
746 label: 'Item ' + j, 746 label: 'Item ' + j,
747 children: ConvertForTree(dicom[i]["Value"][j]) 747 children: ConvertForTree(dicom[i]["Value"][j])
748 }); 748 });
749 } 749 }
761 761
762 762
763 function RefreshInstance() 763 function RefreshInstance()
764 { 764 {
765 if ($.mobile.pageData) { 765 if ($.mobile.pageData) {
766 var pageData = DeepCopy($.mobile.pageData); 766 let pageData = DeepCopy($.mobile.pageData);
767 767
768 GetResource('/instances/' + pageData.uuid, function(instance) { 768 GetResource('/instances/' + pageData.uuid, function(instance) {
769 GetResource('/series/' + instance.ParentSeries, function(series) { 769 GetResource('/series/' + instance.ParentSeries, function(series) {
770 GetResource('/studies/' + series.ParentStudy, function(study) { 770 GetResource('/studies/' + series.ParentStudy, function(study) {
771 GetResource('/patients/' + study.ParentPatient, function(patient) { 771 GetResource('/patients/' + study.ParentPatient, function(patient) {
835 url: path, 835 url: path,
836 type: 'DELETE', 836 type: 'DELETE',
837 dataType: 'json', 837 dataType: 'json',
838 async: false, 838 async: false,
839 success: function(s) { 839 success: function(s) {
840 var ancestor = s.RemainingAncestor; 840 let ancestor = s.RemainingAncestor;
841 if (ancestor == null) 841 if (ancestor == null)
842 $.mobile.changePage('#lookup'); 842 $.mobile.changePage('#lookup');
843 else 843 else
844 $.mobile.changePage('#' + ancestor.Type.toLowerCase() + '?uuid=' + ancestor.ID); 844 $.mobile.changePage('#' + ancestor.Type.toLowerCase() + '?uuid=' + ancestor.ID);
845 } 845 }
911 911
912 912
913 913
914 $('#instance-preview').live('click', function(e) { 914 $('#instance-preview').live('click', function(e) {
915 if ($.mobile.pageData) { 915 if ($.mobile.pageData) {
916 var pageData = DeepCopy($.mobile.pageData); 916 let pageData = DeepCopy($.mobile.pageData);
917 917
918 var pdf = '../instances/' + pageData.uuid + '/pdf'; 918 let pdf = '../instances/' + pageData.uuid + '/pdf';
919 $.ajax({ 919 $.ajax({
920 url: pdf, 920 url: pdf,
921 cache: false, 921 cache: false,
922 success: function(s) { 922 success: function(s) {
923 window.location.assign(pdf); 923 window.location.assign(pdf);
935 } 935 }
936 else 936 else
937 { 937 {
938 // Viewing a multi-frame image 938 // Viewing a multi-frame image
939 939
940 var images = []; 940 let images = [];
941 for (var i = 0; i < frames.length; i++) { 941 for (let i = 0; i < frames.length; i++) {
942 images.push([ '../instances/' + pageData.uuid + '/frames/' + i + '/preview' ]); 942 images.push([ '../instances/' + pageData.uuid + '/frames/' + i + '/preview' ]);
943 } 943 }
944 944
945 jQuery.slimbox(images, 0, { 945 jQuery.slimbox(images, 0, {
946 overlayFadeDuration : 1, 946 overlayFadeDuration : 1,
957 957
958 958
959 959
960 $('#series-preview').live('click', function(e) { 960 $('#series-preview').live('click', function(e) {
961 if ($.mobile.pageData) { 961 if ($.mobile.pageData) {
962 var pageData = DeepCopy($.mobile.pageData); 962 let pageData = DeepCopy($.mobile.pageData);
963 963
964 GetResource('/series/' + pageData.uuid, function(series) { 964 GetResource('/series/' + pageData.uuid, function(series) {
965 GetResource('/series/' + pageData.uuid + '/instances', function(instances) { 965 GetResource('/series/' + pageData.uuid + '/instances', function(instances) {
966 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); 966 Sort(instances, function(x) { return x.IndexInSeries; }, true, false);
967 967
968 var images = []; 968 let images = [];
969 for (var i = 0; i < instances.length; i++) { 969 for (let i = 0; i < instances.length; i++) {
970 images.push([ '../instances/' + instances[i].ID + '/preview', 970 images.push([ '../instances/' + instances[i].ID + '/preview',
971 (i + 1).toString() + '/' + instances.length.toString() ]) 971 (i + 1).toString() + '/' + instances.length.toString() ])
972 } 972 }
973 973
974 jQuery.slimbox(images, 0, { 974 jQuery.slimbox(images, 0, {
986 986
987 987
988 988
989 function ChooseDicomModality(callback) 989 function ChooseDicomModality(callback)
990 { 990 {
991 var clickedModality = ''; 991 let clickedModality = '';
992 var clickedPeer = ''; 992 let clickedPeer = '';
993 var items = $('<ul>') 993 let items = $('<ul>')
994 .attr('data-divider-theme', 'd') 994 .attr('data-divider-theme', 'd')
995 .attr('data-role', 'listview'); 995 .attr('data-role', 'listview');
996 996
997 // Retrieve the list of the known DICOM modalities 997 // Retrieve the list of the known DICOM modalities
998 $.ajax({ 998 $.ajax({
1004 success: function(modalities) { 1004 success: function(modalities) {
1005 if (modalities.length > 0) 1005 if (modalities.length > 0)
1006 { 1006 {
1007 items.append('<li data-role="list-divider">DICOM modalities</li>'); 1007 items.append('<li data-role="list-divider">DICOM modalities</li>');
1008 1008
1009 for (var i = 0; i < modalities.length; i++) { 1009 for (let i = 0; i < modalities.length; i++) {
1010 var name = modalities[i]; 1010 let name = modalities[i];
1011 var item = $('<li>') 1011 let item = $('<li>')
1012 .html('<a href="#" rel="close">' + name + '</a>') 1012 .html('<a href="#" rel="close">' + name + '</a>')
1013 .attr('name', name) 1013 .attr('name', name)
1014 .click(function() { 1014 .click(function() {
1015 clickedModality = $(this).attr('name'); 1015 clickedModality = $(this).attr('name');
1016 }); 1016 });
1028 success: function(peers) { 1028 success: function(peers) {
1029 if (peers.length > 0) 1029 if (peers.length > 0)
1030 { 1030 {
1031 items.append('<li data-role="list-divider">Orthanc peers</li>'); 1031 items.append('<li data-role="list-divider">Orthanc peers</li>');
1032 1032
1033 for (var i = 0; i < peers.length; i++) { 1033 for (let i = 0; i < peers.length; i++) {
1034 var name = peers[i]; 1034 let name = peers[i];
1035 var item = $('<li>') 1035 let item = $('<li>')
1036 .html('<a href="#" rel="close">' + name + '</a>') 1036 .html('<a href="#" rel="close">' + name + '</a>')
1037 .attr('name', name) 1037 .attr('name', name)
1038 .click(function() { 1038 .click(function() {
1039 clickedPeer = $(this).attr('name'); 1039 clickedPeer = $(this).attr('name');
1040 }); 1040 });
1050 headerClose: true, 1050 headerClose: true,
1051 forceInput: false, 1051 forceInput: false,
1052 width: '100%', 1052 width: '100%',
1053 blankContent: items, 1053 blankContent: items,
1054 callbackClose: function() { 1054 callbackClose: function() {
1055 var timer; 1055 let timer;
1056 function WaitForDialogToClose() { 1056 function WaitForDialogToClose() {
1057 if (!$('#dialog').is(':visible')) { 1057 if (!$('#dialog').is(':visible')) {
1058 clearInterval(timer); 1058 clearInterval(timer);
1059 callback(clickedModality, clickedPeer); 1059 callback(clickedModality, clickedPeer);
1060 } 1060 }
1069 } 1069 }
1070 1070
1071 1071
1072 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) { 1072 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) {
1073 ChooseDicomModality(function(modality, peer) { 1073 ChooseDicomModality(function(modality, peer) {
1074 var pageData = DeepCopy($.mobile.pageData); 1074 let pageData = DeepCopy($.mobile.pageData);
1075 1075
1076 var url; 1076 let url;
1077 var loading; 1077 let loading;
1078 1078
1079 if (modality != '') 1079 if (modality != '')
1080 { 1080 {
1081 url = '../modalities/' + modality + '/store'; 1081 url = '../modalities/' + modality + '/store';
1082 loading = '#dicom-store'; 1082 loading = '#dicom-store';
1111 }); 1111 });
1112 }); 1112 });
1113 1113
1114 1114
1115 $('#show-tag-name').live('change', function(e) { 1115 $('#show-tag-name').live('change', function(e) {
1116 var checked = e.currentTarget.checked; 1116 let checked = e.currentTarget.checked;
1117 if (checked) 1117 if (checked)
1118 $('.tag-name').show(); 1118 $('.tag-name').show();
1119 else 1119 else
1120 $('.tag-name').hide(); 1120 $('.tag-name').hide();
1121 }); 1121 });
1153 }); 1153 });
1154 1154
1155 1155
1156 1156
1157 $('#protection').live('change', function(e) { 1157 $('#protection').live('change', function(e) {
1158 var isProtected = e.target.value == "on"; 1158 let isProtected = e.target.value == "on";
1159 $.ajax({ 1159 $.ajax({
1160 url: '../patients/' + $.mobile.pageData.uuid + '/protected', 1160 url: '../patients/' + $.mobile.pageData.uuid + '/protected',
1161 type: 'PUT', 1161 type: 'PUT',
1162 dataType: 'text', 1162 dataType: 'text',
1163 data: isProtected ? '1' : '0', 1163 data: isProtected ? '1' : '0',
1231 url: '../plugins', 1231 url: '../plugins',
1232 dataType: 'json', 1232 dataType: 'json',
1233 async: false, 1233 async: false,
1234 cache: false, 1234 cache: false,
1235 success: function(plugins) { 1235 success: function(plugins) {
1236 var target = $('#all-plugins'); 1236 let target = $('#all-plugins');
1237 $('li', target).remove(); 1237 $('li', target).remove();
1238 1238
1239 plugins.map(function(id) { 1239 plugins.map(function(id) {
1240 return $.ajax({ 1240 return $.ajax({
1241 url: '../plugins/' + id, 1241 url: '../plugins/' + id,
1242 dataType: 'json', 1242 dataType: 'json',
1243 async: false, 1243 async: false,
1244 cache: false, 1244 cache: false,
1245 success: function(plugin) { 1245 success: function(plugin) {
1246 var li = $('<li>'); 1246 let li = $('<li>');
1247 var item = li; 1247 let item = li;
1248 1248
1249 if ('RootUri' in plugin) 1249 if ('RootUri' in plugin)
1250 { 1250 {
1251 item = $('<a>'); 1251 item = $('<a>');
1252 li.append(item); 1252 li.append(item);
1270 1270
1271 1271
1272 1272
1273 function ParseJobTime(s) 1273 function ParseJobTime(s)
1274 { 1274 {
1275 var t = (s.substr(0, 4) + '-' + 1275 let t = (s.substr(0, 4) + '-' +
1276 s.substr(4, 2) + '-' + 1276 s.substr(4, 2) + '-' +
1277 s.substr(6, 5) + ':' + 1277 s.substr(6, 5) + ':' +
1278 s.substr(11, 2) + ':' + 1278 s.substr(11, 2) + ':' +
1279 s.substr(13)); 1279 s.substr(13));
1280 var utc = new Date(t); 1280 let utc = new Date(t);
1281 1281
1282 // Convert from UTC to local time 1282 // Convert from UTC to local time
1283 return new Date(utc.getTime() - utc.getTimezoneOffset() * 60000); 1283 return new Date(utc.getTime() - utc.getTimezoneOffset() * 60000);
1284 } 1284 }
1285 1285
1309 url: '../jobs?expand', 1309 url: '../jobs?expand',
1310 dataType: 'json', 1310 dataType: 'json',
1311 async: false, 1311 async: false,
1312 cache: false, 1312 cache: false,
1313 success: function(jobs) { 1313 success: function(jobs) {
1314 var target = $('#all-jobs'); 1314 let target = $('#all-jobs');
1315 $('li', target).remove(); 1315 $('li', target).remove();
1316 1316
1317 var running = $('<li>') 1317 let running = $('<li>')
1318 .attr('data-role', 'list-divider') 1318 .attr('data-role', 'list-divider')
1319 .text('Currently running'); 1319 .text('Currently running');
1320 1320
1321 var pending = $('<li>') 1321 let pending = $('<li>')
1322 .attr('data-role', 'list-divider') 1322 .attr('data-role', 'list-divider')
1323 .text('Pending jobs'); 1323 .text('Pending jobs');
1324 1324
1325 var inactive = $('<li>') 1325 let inactive = $('<li>')
1326 .attr('data-role', 'list-divider') 1326 .attr('data-role', 'list-divider')
1327 .text('Inactive jobs'); 1327 .text('Inactive jobs');
1328 1328
1329 target.append(running); 1329 target.append(running);
1330 target.append(pending); 1330 target.append(pending);
1331 target.append(inactive); 1331 target.append(inactive);
1332 1332
1333 jobs.map(function(job) { 1333 jobs.map(function(job) {
1334 var li = $('<li>'); 1334 let li = $('<li>');
1335 var item = $('<a>'); 1335 let item = $('<a>');
1336 li.append(item); 1336 li.append(item);
1337 item.attr('href', '#job?uuid=' + job.ID); 1337 item.attr('href', '#job?uuid=' + job.ID);
1338 item.append($('<h1>').text(job.Type)); 1338 item.append($('<h1>').text(job.Type));
1339 item.append($('<span>').addClass('ui-li-count').text(job.State)); 1339 item.append($('<span>').addClass('ui-li-count').text(job.State));
1340 AddJobField(item, 'ID: ', job.ID); 1340 AddJobField(item, 'ID: ', job.ID);
1367 }); 1367 });
1368 1368
1369 1369
1370 $('#job').live('pagebeforeshow', function() { 1370 $('#job').live('pagebeforeshow', function() {
1371 if ($.mobile.pageData) { 1371 if ($.mobile.pageData) {
1372 var pageData = DeepCopy($.mobile.pageData); 1372 let pageData = DeepCopy($.mobile.pageData);
1373 1373
1374 $.ajax({ 1374 $.ajax({
1375 url: '../jobs/' + pageData.uuid, 1375 url: '../jobs/' + pageData.uuid,
1376 dataType: 'json', 1376 dataType: 'json',
1377 async: false, 1377 async: false,
1378 cache: false, 1378 cache: false,
1379 success: function(job) { 1379 success: function(job) {
1380 var target = $('#job-info'); 1380 let target = $('#job-info');
1381 $('li', target).remove(); 1381 $('li', target).remove();
1382 1382
1383 target.append($('<li>') 1383 target.append($('<li>')
1384 .attr('data-role', 'list-divider') 1384 .attr('data-role', 'list-divider')
1385 .text('General information about the job')); 1385 .text('General information about the job'));
1386 1386
1387 var block = $('<li>'); 1387 let block = $('<li>');
1388 for (var i in job) { 1388 for (let i in job) {
1389 if (i == 'CreationTime' || 1389 if (i == 'CreationTime' ||
1390 i == 'CompletionTime' || 1390 i == 'CompletionTime' ||
1391 i == 'EstimatedTimeOfArrival') { 1391 i == 'EstimatedTimeOfArrival') {
1392 AddJobDateField(block, i + ': ', job[i]); 1392 AddJobDateField(block, i + ': ', job[i]);
1393 } else if (i != 'InternalContent' && 1393 } else if (i != 'InternalContent' &&
1401 1401
1402 target.append($('<li>') 1402 target.append($('<li>')
1403 .attr('data-role', 'list-divider') 1403 .attr('data-role', 'list-divider')
1404 .text('Detailed information')); 1404 .text('Detailed information'));
1405 1405
1406 var block = $('<li>'); 1406 let block = $('<li>');
1407 1407
1408 for (var item in job.Content) { 1408 for (let item in job.Content) {
1409 var value = job.Content[item]; 1409 let value = job.Content[item];
1410 if (typeof value !== 'string') { 1410 if (typeof value !== 'string') {
1411 value = JSON.stringify(value); 1411 value = JSON.stringify(value);
1412 } 1412 }
1413 1413
1414 AddJobField(block, item + ': ', value); 1414 AddJobField(block, item + ': ', value);