changeset 3103:81b58b549845

back to using 'var' instead of 'let' since let is not supported by many old browsers. All variables declaration have been moved to the top of the function to better show that their scope is the function
author Alain Mazy <alain@mazy.be>
date Thu, 10 Jan 2019 10:51:36 +0100
parents 9b18c8d4d459
children b311cff247ca
files OrthancExplorer/explorer.js OrthancExplorer/file-upload.js OrthancExplorer/query-retrieve.js
diffstat 3 files changed, 192 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancExplorer/explorer.js	Thu Jan 10 10:10:26 2019 +0100
+++ b/OrthancExplorer/explorer.js	Thu Jan 10 10:51:36 2019 +0100
@@ -27,10 +27,12 @@
 
 function ChangePage(page, options)
 {
-  let first = true;
+  var first = true;
+  var value;
+
   if (options) {
-    for (let key in options) {
-      let value = options[key];
+    for (var key in options) {
+      value = options[key];
       if (first) {
         page += '?';
         first = false;
@@ -63,7 +65,7 @@
 
 
 $(document).ready(function() {
-  let $tree = $('#dicom-tree');
+  var $tree = $('#dicom-tree');
   $tree.tree({
     autoEscape: false
   });
@@ -124,7 +126,7 @@
   if (s == undefined)
     return "No date";
 
-  let d = ParseDicomDate(s);
+  var d = ParseDicomDate(s);
   if (d == null)
     return '?';
   else
@@ -134,16 +136,16 @@
 
 function Sort(arr, fieldExtractor, isInteger, reverse)
 {
-  let defaultValue;
+  var defaultValue;
   if (isInteger)
     defaultValue = 0;
   else
     defaultValue = '';
 
   arr.sort(function(a, b) {
-    let ta = fieldExtractor(a);
-    let tb = fieldExtractor(b);
-    let order;
+    var ta = fieldExtractor(a);
+    var tb = fieldExtractor(b);
+    var order;
 
     if (ta == undefined)
       ta = defaultValue;
@@ -226,11 +228,13 @@
 
 function FormatMainDicomTags(target, tags, tagsToIgnore)
 {
-  for (let i in tags)
+  var v;
+  
+  for (var i in tags)
   {
     if (tagsToIgnore.indexOf(i) == -1)
     {
-      let v = tags[i];
+      v = tags[i];
 
       if (i == "PatientBirthDate" ||
           i == "StudyDate" ||
@@ -254,7 +258,7 @@
 
 function FormatPatient(patient, link, isReverse)
 {
-  let node = $('<div>').append($('<h3>').text(patient.MainDicomTags.PatientName));
+  var node = $('<div>').append($('<h3>').text(patient.MainDicomTags.PatientName));
 
   FormatMainDicomTags(node, patient.MainDicomTags, [ 
     "PatientName"
@@ -268,7 +272,8 @@
 
 function FormatStudy(study, link, isReverse, includePatient)
 {
-  let label;
+  var label;
+  var node;
 
   if (includePatient) {
     label = study.Label;
@@ -276,7 +281,7 @@
     label = study.MainDicomTags.StudyDescription;
   }
 
-  let node = $('<div>').append($('<h3>').text(label));
+  node = $('<div>').append($('<h3>').text(label));
 
   if (includePatient) {
     FormatMainDicomTags(node, study.PatientMainDicomTags, [ 
@@ -296,7 +301,9 @@
 
 function FormatSeries(series, link, isReverse)
 {
-  let c;
+  var c;
+  var node;
+
   if (series.ExpectedNumberOfInstances == null ||
       series.Instances.length == series.ExpectedNumberOfInstances)
   {
@@ -307,7 +314,7 @@
     c = series.Instances.length + '/' + series.ExpectedNumberOfInstances;
   }
   
-  let node = $('<div>')
+  node = $('<div>')
       .append($('<h3>').text(series.MainDicomTags.SeriesDescription))
       .append($('<p>').append($('<em>')
                            .text('Status: ')
@@ -328,7 +335,7 @@
 
 function FormatInstance(instance, link, isReverse)
 {
-  let node = $('<div>').append($('<h3>').text('Instance: ' + instance.IndexInSeries));
+  var node = $('<div>').append($('<h3>').text('Instance: ' + instance.IndexInSeries));
 
   FormatMainDicomTags(node, instance.MainDicomTags, [
     "AcquisitionNumber", 
@@ -364,7 +371,7 @@
 
 $('#lookup').live('pagebeforeshow', function() {
   // NB: "GenerateDicomDate()" is defined in "query-retrieve.js"
-  let target = $('#lookup-study-date');
+  var target = $('#lookup-study-date');
   $('option', target).remove();
   target.append($('<option>').attr('value', '*').text('Any date'));
   target.append($('<option>').attr('value', GenerateDicomDate(0)).text('Today'));
@@ -380,9 +387,11 @@
 
 
 $('#lookup-submit').live('click', function() {
+  var lookup;
+
   $('#lookup-result').hide();
 
-  let lookup = {
+  lookup = {
     'Level' : 'Study',
     'Expand' : true,
     'Limit' : LIMIT_RESOURCES + 1,
@@ -432,12 +441,14 @@
 
 $('#find-patients').live('pagebeforeshow', function() {
   GetResource('/patients?expand&since=0&limit=' + (LIMIT_RESOURCES + 1), function(patients) {
-    let target = $('#all-patients');
+    var target = $('#all-patients');
+    var count, showAlert, p;
+
+
     $('li', target).remove();
     
     SortOnDicomTag(patients, 'PatientName', false, false);
 
-    let count, showAlert;
     if (patients.length <= LIMIT_RESOURCES) {
       count = patients.length;
       showAlert = false;
@@ -447,8 +458,8 @@
       showAlert = true;
     }
 
-    for (let i = 0; i < count; i++) {
-      let p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID);
+    for (var i = 0; i < count; i++) {
+      p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID);
       target.append(p);
     }
 
@@ -467,14 +478,17 @@
 
 function FormatListOfStudies(targetId, alertId, countId, studies)
 {
-  let target = $(targetId);
+  var target = $(targetId);
+  var patient, study, s;
+  var count, showAlert;
+
   $('li', target).remove();
 
-  for (let i = 0; i < studies.length; i++) {
-    let patient = studies[i].PatientMainDicomTags.PatientName;
-    let study = studies[i].MainDicomTags.StudyDescription;
+  for (var i = 0; i < studies.length; i++) {
+    patient = studies[i].PatientMainDicomTags.PatientName;
+    study = studies[i].MainDicomTags.StudyDescription;
 
-    let s;
+    s = "";
     if (typeof patient === 'string') {
       s = patient;
     }
@@ -492,8 +506,6 @@
 
   Sort(studies, function(a) { return a.Label }, false, false);
 
-
-  let count, showAlert;
   if (studies.length <= LIMIT_RESOURCES) {
     count = studies.length;
     showAlert = false;
@@ -503,9 +515,9 @@
     showAlert = true;
   }
 
-  for (let i = 0; i < count; i++) {
-    let p = FormatStudy(studies[i], '#study?uuid=' + studies[i].ID, false, true);
-    target.append(p);
+  for (var i = 0; i < count; i++) {
+    s = FormatStudy(studies[i], '#study?uuid=' + studies[i].ID, false, true);
+    target.append(s);
   }
 
   target.listview('refresh');
@@ -546,8 +558,10 @@
 
 function RefreshPatient()
 {
+  var pageData, target, v;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
     GetResource('/patients/' + pageData.uuid, function(patient) {
       GetResource('/patients/' + pageData.uuid + '/studies', function(studies) {
@@ -559,10 +573,10 @@
           .append(FormatPatient(patient))
           .listview('refresh');
 
-        let target = $('#list-studies');
+        target = $('#list-studies');
         $('li', target).remove();
         
-        for (let i = 0; i < studies.length; i++) {
+        for (var i = 0; i < studies.length; i++) {
           if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate)
           {
             target.append($('<li>')
@@ -586,7 +600,7 @@
           async: false,
           cache: false,
           success: function (s) {
-            let v = (s == '1') ? 'on' : 'off';
+            v = (s == '1') ? 'on' : 'off';
             $('#protection').val(v).slider('refresh');
           }
         });
@@ -601,8 +615,10 @@
 
 function RefreshStudy()
 {
+  var pageData, target;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
     GetResource('/studies/' + pageData.uuid, function(study) {
       GetResource('/patients/' + study.ParentPatient, function(patient) {
@@ -621,9 +637,9 @@
           SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', 'AnonymizedFrom');
           SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', 'ModifiedFrom');
 
-          let target = $('#list-series');
+          target = $('#list-series');
           $('li', target).remove();
-          for (let i = 0; i < series.length; i++) {
+          for (var i = 0; i < series.length; i++) {
             if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate)
             {
               target.append($('<li>')
@@ -646,8 +662,10 @@
 
 function RefreshSeries() 
 {
+  var pageData, target;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
     GetResource('/series/' + pageData.uuid, function(series) {
       GetResource('/studies/' + series.ParentStudy, function(study) {
@@ -671,9 +689,9 @@
             SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', 'AnonymizedFrom');
             SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', 'ModifiedFrom');
 
-            let target = $('#list-instances');
+            target = $('#list-instances');
             $('li', target).remove();
-            for (let i = 0; i < instances.length; i++) {
+            for (var i = 0; i < instances.length; i++) {
               target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID));
             }
             target.listview('refresh');
@@ -690,7 +708,7 @@
 
 function EscapeHtml(value)
 {
-  let ENTITY_MAP = {
+  var ENTITY_MAP = {
     '&': '&amp;',
     '<': '&lt;',
     '>': '&gt;',
@@ -709,11 +727,12 @@
 
 function ConvertForTree(dicom)
 {
-  let result = [];
+  var result = [];
+  var label, c;
 
-  for (let i in dicom) {
+  for (var i in dicom) {
     if (dicom[i] != null) {
-      let label = (i + '<span class="tag-name"> (<i>' +
+      label = (i + '<span class="tag-name"> (<i>' +
                    EscapeHtml(dicom[i]["Name"]) +
                    '</i>)</span>: ');
 
@@ -740,8 +759,8 @@
       }
       else if (dicom[i]["Type"] == 'Sequence')
       {
-        let c = [];
-        for (let j = 0; j < dicom[i]["Value"].length; j++) {
+        c = [];
+        for (var j = 0; j < dicom[i]["Value"].length; j++) {
           c.push({
             label: 'Item ' + j,
             children: ConvertForTree(dicom[i]["Value"][j])
@@ -762,8 +781,10 @@
 
 function RefreshInstance()
 {
+  var pageData;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
     GetResource('/instances/' + pageData.uuid, function(instance) {
       GetResource('/series/' + instance.ParentSeries, function(series) {
@@ -837,7 +858,7 @@
     dataType: 'json',
     async: false,
     success: function(s) {
-      let ancestor = s.RemainingAncestor;
+      var ancestor = s.RemainingAncestor;
       if (ancestor == null)
         $.mobile.changePage('#lookup');
       else
@@ -912,10 +933,12 @@
 
 
 $('#instance-preview').live('click', function(e) {
+  var pageData, pdf, images;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
-    let pdf = '../instances/' + pageData.uuid + '/pdf';
+    pdf = '../instances/' + pageData.uuid + '/pdf';
     $.ajax({
       url: pdf,
       cache: false,
@@ -937,8 +960,8 @@
           {
             // Viewing a multi-frame image
 
-            let images = [];
-            for (let i = 0; i < frames.length; i++) {
+            images = [];
+            for (var i = 0; i < frames.length; i++) {
               images.push([ '../instances/' + pageData.uuid + '/frames/' + i + '/preview' ]);
             }
 
@@ -958,15 +981,17 @@
 
 
 $('#series-preview').live('click', function(e) {
+  var pageData, images;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
     GetResource('/series/' + pageData.uuid, function(series) {
       GetResource('/series/' + pageData.uuid + '/instances', function(instances) {
         Sort(instances, function(x) { return x.IndexInSeries; }, true, false);
 
-        let images = [];
-        for (let i = 0; i < instances.length; i++) {
+        images = [];
+        for (var i = 0; i < instances.length; i++) {
           images.push([ '../instances/' + instances[i].ID + '/preview',
                         (i + 1).toString() + '/' + instances.length.toString() ])
         }
@@ -988,9 +1013,9 @@
 
 function ChooseDicomModality(callback)
 {
-  let clickedModality = '';
-  let clickedPeer = '';
-  let items = $('<ul>')
+  var clickedModality = '';
+  var clickedPeer = '';
+  var items = $('<ul>')
     .attr('data-divider-theme', 'd')
     .attr('data-role', 'listview');
 
@@ -1002,13 +1027,15 @@
     async: false,
     cache: false,
     success: function(modalities) {
+      var name, item;
+      
       if (modalities.length > 0)
       {
         items.append('<li data-role="list-divider">DICOM modalities</li>');
 
-        for (let i = 0; i < modalities.length; i++) {
-          let name = modalities[i];
-          let item = $('<li>')
+        for (var i = 0; i < modalities.length; i++) {
+          name = modalities[i];
+          item = $('<li>')
             .html('<a href="#" rel="close">' + name + '</a>')
             .attr('name', name)
             .click(function() { 
@@ -1026,13 +1053,15 @@
         async: false,
         cache: false,
         success: function(peers) {
+          var name, item;
+
           if (peers.length > 0)
           {
             items.append('<li data-role="list-divider">Orthanc peers</li>');
 
-            for (let i = 0; i < peers.length; i++) {
-              let name = peers[i];
-              let item = $('<li>')
+            for (var i = 0; i < peers.length; i++) {
+              name = peers[i];
+              item = $('<li>')
                 .html('<a href="#" rel="close">' + name + '</a>')
                 .attr('name', name)
                 .click(function() { 
@@ -1052,7 +1081,7 @@
             width: '100%',
             blankContent: items,
             callbackClose: function() {
-              let timer;
+              var timer;
               function WaitForDialogToClose() {
                 if (!$('#dialog').is(':visible')) {
                   clearInterval(timer);
@@ -1071,10 +1100,8 @@
 
 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) {
   ChooseDicomModality(function(modality, peer) {
-    let pageData = DeepCopy($.mobile.pageData);
-
-    let url;
-    let loading;
+    var pageData = DeepCopy($.mobile.pageData);
+    var url, loading;
 
     if (modality != '')
     {
@@ -1113,7 +1140,7 @@
 
 
 $('#show-tag-name').live('change', function(e) {
-  let checked = e.currentTarget.checked;
+  var checked = e.currentTarget.checked;
   if (checked)
     $('.tag-name').show();
   else
@@ -1155,7 +1182,7 @@
 
 
 $('#protection').live('change', function(e) {
-  let isProtected = e.target.value == "on";
+  var isProtected = e.target.value == "on";
   $.ajax({
     url: '../patients/' + $.mobile.pageData.uuid + '/protected',
     type: 'PUT',
@@ -1233,7 +1260,7 @@
     async: false,
     cache: false,
     success: function(plugins) {
-      let target = $('#all-plugins');
+      var target = $('#all-plugins');
       $('li', target).remove();
 
       plugins.map(function(id) {
@@ -1243,8 +1270,8 @@
           async: false,
           cache: false,
           success: function(plugin) {
-            let li = $('<li>');
-            let item = li;
+            var li = $('<li>');
+            var item = li;
 
             if ('RootUri' in plugin)
             {
@@ -1272,12 +1299,12 @@
 
 function ParseJobTime(s)
 {
-  let t = (s.substr(0, 4) + '-' +
+  var t = (s.substr(0, 4) + '-' +
            s.substr(4, 2) + '-' +
            s.substr(6, 5) + ':' +
            s.substr(11, 2) + ':' +
            s.substr(13));
-  let utc = new Date(t);
+  var utc = new Date(t);
 
   // Convert from UTC to local time
   return new Date(utc.getTime() - utc.getTimezoneOffset() * 60000);
@@ -1311,18 +1338,20 @@
     async: false,
     cache: false,
     success: function(jobs) {
-      let target = $('#all-jobs');
+      var target = $('#all-jobs');
+      var running, pending, inactive;
+
       $('li', target).remove();
 
-      let running = $('<li>')
+      running = $('<li>')
           .attr('data-role', 'list-divider')
           .text('Currently running');
 
-      let pending = $('<li>')
+      pending = $('<li>')
           .attr('data-role', 'list-divider')
           .text('Pending jobs');
 
-      let inactive = $('<li>')
+      inactive = $('<li>')
           .attr('data-role', 'list-divider')
           .text('Inactive jobs');
 
@@ -1331,8 +1360,9 @@
       target.append(inactive);
 
       jobs.map(function(job) {
-        let li = $('<li>');
-        let item = $('<a>');
+        var li = $('<li>');
+        var item = $('<a>');
+        
         li.append(item);
         item.attr('href', '#job?uuid=' + job.ID);
         item.append($('<h1>').text(job.Type));
@@ -1368,8 +1398,10 @@
 
 
 $('#job').live('pagebeforeshow', function() {
+  var pageData, target;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
     $.ajax({
       url: '../jobs/' + pageData.uuid,
@@ -1377,7 +1409,9 @@
       async: false,
       cache: false,
       success: function(job) {
-        let target = $('#job-info');
+        var block, value;
+        
+        target = $('#job-info');
         $('li', target).remove();
 
         target.append($('<li>')
@@ -1385,8 +1419,8 @@
                       .text('General information about the job'));
 
         {                       
-          let block = $('<li>');
-          for (let i in job) {
+          block = $('<li>');
+          for (var i in job) {
             if (i == 'CreationTime' ||
                 i == 'CompletionTime' ||
                 i == 'EstimatedTimeOfArrival') {
@@ -1406,10 +1440,10 @@
                       .text('Detailed information'));
 
         {
-          let block = $('<li>');
+          block = $('<li>');
 
-          for (let item in job.Content) {
-            let value = job.Content[item];
+          for (var item in job.Content) {
+            var value = job.Content[item];
             if (typeof value !== 'string') {
               value = JSON.stringify(value);
             }
--- a/OrthancExplorer/file-upload.js	Thu Jan 10 10:10:26 2019 +0100
+++ b/OrthancExplorer/file-upload.js	Thu Jan 10 10:51:36 2019 +0100
@@ -32,7 +32,7 @@
     .bind('fileuploadsend', function (e, data) {
       // Update the progress bar. Note: for some weird reason, the
       // "fileuploadprogressall" does not work under Firefox.
-      let progress = parseInt(currentUpload / totalUploads * 100, 10);
+      var progress = parseInt(currentUpload / totalUploads * 100, 10);
       currentUpload += 1;
       $('#progress .label').text('Uploading: ' + progress + '%');
       $('#progress .bar')
@@ -42,7 +42,7 @@
 });
 
 function appendFilesToUploadList(files) {
-  let target = $('#upload-list');
+  var target = $('#upload-list');
   $.each(files, function (index, file) {
     target.append('<li class="pending-file">' + file.name + '</li>');
   });
@@ -72,7 +72,7 @@
 
 
 $('#upload-button').live('click', function() {
-  let pu = pendingUploads;
+  var pu = pendingUploads;
   pendingUploads = [];
 
   $('.pending-file').remove();
@@ -87,7 +87,7 @@
     //$('#upload-abort').removeClass('ui-disabled');
   }
 
-  for (let i = 0; i < pu.length; i++) {
+  for (var i = 0; i < pu.length; i++) {
     pu[i].submit();
   }
 });
--- a/OrthancExplorer/query-retrieve.js	Thu Jan 10 10:10:26 2019 +0100
+++ b/OrthancExplorer/query-retrieve.js	Thu Jan 10 10:51:36 2019 +0100
@@ -1,53 +1,57 @@
 function JavascriptDateToDicom(date)
 {
-  let s = date.toISOString();
+  var s = date.toISOString();
   return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
 }
 
 function GenerateDicomDate(days)
 {
-  let today = new Date();
-  let other = new Date(today);
+  var today = new Date();
+  var other = new Date(today);
   other.setDate(today.getDate() + days);
   return JavascriptDateToDicom(other);
 }
 
 
 $('#query-retrieve').live('pagebeforeshow', function() {
+  var targetDate;
+
   $.ajax({
     url: '../modalities',
     dataType: 'json',
     async: false,
     cache: false,
     success: function(modalities) {
-      let target = $('#qr-server');
-      $('option', target).remove();
+      var targetServer = $('#qr-server');
+      var option;
 
-      for (let i = 0; i < modalities.length; i++) {
-        let option = $('<option>').text(modalities[i]);
-        target.append(option);
+      $('option', targetServer).remove();
+
+      for (var i = 0; i < modalities.length; i++) {
+        option = $('<option>').text(modalities[i]);
+        targetServer.append(option);
       }
 
-      target.selectmenu('refresh');
+      targetServer.selectmenu('refresh');
     }
   });
 
-  let target = $('#qr-date');
-  $('option', target).remove();
-  target.append($('<option>').attr('value', '*').text('Any date'));
-  target.append($('<option>').attr('value', GenerateDicomDate(0)).text('Today'));
-  target.append($('<option>').attr('value', GenerateDicomDate(-1)).text('Yesterday'));
-  target.append($('<option>').attr('value', GenerateDicomDate(-7) + '-').text('Last 7 days'));
-  target.append($('<option>').attr('value', GenerateDicomDate(-31) + '-').text('Last 31 days'));
-  target.append($('<option>').attr('value', GenerateDicomDate(-31 * 3) + '-').text('Last 3 months'));
-  target.append($('<option>').attr('value', GenerateDicomDate(-365) + '-').text('Last year'));
-  target.selectmenu('refresh');
+  targetDate = $('#qr-date');
+  $('option', targetDate).remove();
+  targetDate.append($('<option>').attr('value', '*').text('Any date'));
+  targetDate.append($('<option>').attr('value', GenerateDicomDate(0)).text('Today'));
+  targetDate.append($('<option>').attr('value', GenerateDicomDate(-1)).text('Yesterday'));
+  targetDate.append($('<option>').attr('value', GenerateDicomDate(-7) + '-').text('Last 7 days'));
+  targetDate.append($('<option>').attr('value', GenerateDicomDate(-31) + '-').text('Last 31 days'));
+  targetDate.append($('<option>').attr('value', GenerateDicomDate(-31 * 3) + '-').text('Last 3 months'));
+  targetDate.append($('<option>').attr('value', GenerateDicomDate(-365) + '-').text('Last year'));
+  targetDate.selectmenu('refresh');
 });
 
 
 $('#qr-echo').live('click', function() {
-  let server = $('#qr-server').val();
-  let message = 'Error: The C-Echo has failed!';
+  var server = $('#qr-server').val();
+  var message = 'Error: The C-Echo has failed!';
 
   $.ajax({
     url: '../modalities/' + server + '/echo',
@@ -75,7 +79,9 @@
 
 
 $('#qr-submit').live('click', function() {
-  let query = {
+  var query, server, modalities, field;
+
+  query = {
     'Level' : 'Study',
     'Query' : {
       'AccessionNumber' : '*',
@@ -88,12 +94,13 @@
     }
   };
 
-  let field = $('#qr-fields input:checked').val();
+  modalities = '';
+
+  field = $('#qr-fields input:checked').val();
   query['Query'][field] = $('#qr-value').val().toUpperCase();
 
-  let modalities = '';
   $('#qr-modalities input:checked').each(function() {
-    let s = $(this).attr('name');
+    var s = $(this).attr('name');
     if (modalities == '')
       modalities = s;
     else
@@ -105,7 +112,7 @@
   }
 
 
-  let server = $('#qr-server').val();
+  server = $('#qr-server').val();
   $.ajax({
     url: '../modalities/' + server + '/query',
     type: 'POST', 
@@ -129,28 +136,30 @@
 
 
 $('#query-retrieve-2').live('pagebeforeshow', function() {
+  var pageData, uri;
+  
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
-    let uri = '../queries/' + pageData.uuid + '/answers';
+    uri = '../queries/' + pageData.uuid + '/answers';
 
     $.ajax({
       url: uri,
       dataType: 'json',
       async: false,
       success: function(answers) {
-        let target = $('#query-retrieve-2 ul');
+        var target = $('#query-retrieve-2 ul');
         $('li', target).remove();
 
-        for (let i = 0; i < answers.length; i++) {
+        for (var i = 0; i < answers.length; i++) {
           $.ajax({
             url: uri + '/' + answers[i] + '/content?simplify',
             dataType: 'json',
             async: false,
             success: function(study) {
-              let series = '#query-retrieve-3?server=' + pageData.server + '&uuid=' + study['StudyInstanceUID'];
+              var series = '#query-retrieve-3?server=' + pageData.server + '&uuid=' + study['StudyInstanceUID'];
 
-              let content = ($('<div>')
+              var content = ($('<div>')
                              .append($('<h3>').text(study['PatientID'] + ' - ' + study['PatientName']))
                              .append($('<p>').text('Accession number: ')
                                      .append($('<b>').text(study['AccessionNumber'])))
@@ -163,10 +172,10 @@
                              .append($('<p>').text('Study date: ')
                                      .append($('<b>').text(FormatDicomDate(study['StudyDate'])))));
 
-              let info = $('<a>').attr('href', series).html(content);
+              var info = $('<a>').attr('href', series).html(content);
               
-              let answerId = answers[i];
-              let retrieve = $('<a>').text('Retrieve all study').click(function() {
+              var answerId = answers[i];
+              var retrieve = $('<a>').text('Retrieve all study').click(function() {
                 ChangePage('query-retrieve-4', {
                   'query' : pageData.uuid,
                   'answer' : answerId,
@@ -187,10 +196,12 @@
 
 
 $('#query-retrieve-3').live('pagebeforeshow', function() {
+  var pageData, query;
+
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
+    pageData = DeepCopy($.mobile.pageData);
 
-    let query = {
+    query = {
       'Level' : 'Series',
       'Query' : {
         'Modality' : '*',
@@ -211,8 +222,8 @@
         alert('Error during query (C-Find)');
       },
       success: function(answer) {
-        let queryUuid = answer['ID'];
-        let uri = '../queries/' + answer['ID'] + '/answers';
+        var queryUuid = answer['ID'];
+        var uri = '../queries/' + answer['ID'] + '/answers';
 
         $.ajax({
           url: uri,
@@ -220,25 +231,25 @@
           async: false,
           success: function(answers) {
             
-            let target = $('#query-retrieve-3 ul');
+            var target = $('#query-retrieve-3 ul');
             $('li', target).remove();
 
-            for (let i = 0; i < answers.length; i++) {
+            for (var i = 0; i < answers.length; i++) {
               $.ajax({
                 url: uri + '/' + answers[i] + '/content?simplify',
                 dataType: 'json',
                 async: false,
                 success: function(series) {
-                  let content = ($('<div>')
+                  var content = ($('<div>')
                                  .append($('<h3>').text(series['SeriesDescription']))
                                  .append($('<p>').text('Modality: ')
                                          .append($('<b>').text(series['Modality'])))
                                  .append($('<p>').text('ProtocolName: ')
                                          .append($('<b>').text(series['ProtocolName']))));
 
-                  let info = $('<a>').html(content);
+                  var info = $('<a>').html(content);
 
-                  let answerId = answers[i];
+                  var answerId = answers[i];
                   info.click(function() {
                     ChangePage('query-retrieve-4', {
                       'query' : queryUuid,
@@ -264,9 +275,11 @@
 
 
 $('#query-retrieve-4').live('pagebeforeshow', function() {
+  var pageData, uri;
+  
   if ($.mobile.pageData) {
-    let pageData = DeepCopy($.mobile.pageData);
-    let uri = '../queries/' + pageData.query + '/answers/' + pageData.answer + '/retrieve';
+    var pageData = DeepCopy($.mobile.pageData);
+    var uri = '../queries/' + pageData.query + '/answers/' + pageData.answer + '/retrieve';
 
     $.ajax({
       url: '../system',
@@ -277,9 +290,11 @@
         $('#retrieve-target').val(system['DicomAet']);
 
         $('#retrieve-form').submit(function(event) {
+          var aet;
+
           event.preventDefault();
 
-          let aet = $('#retrieve-target').val();
+          aet = $('#retrieve-target').val();
           if (aet.length == 0) {
             aet = system['DicomAet'];
           }