# HG changeset patch
# User Sebastien Jodogne <s.jodogne@gmail.com>
# Date 1520933078 -3600
# Node ID 3e45f3752074b5db305ae36c828b6ad4e7c58e37
# Parent  59c6ea40fe4f435d3f55d9f19609845fd758194f
Fix download of DICOM instance from the toolbox

diff -r 59c6ea40fe4f -r 3e45f3752074 NEWS
--- a/NEWS	Fri Jan 05 16:39:45 2018 +0100
+++ b/NEWS	Tue Mar 13 10:24:38 2018 +0100
@@ -1,6 +1,7 @@
 Pending changes in the mainline
 ===============================
 
+* Fix download of DICOM instance from the toolbox
 * Fix for Osimis issue WVB-319: Some images are not loading in US_MF
 * Support of rendering RGB48 lookup tables (palette), if Orthanc SDK >= 1.3.1
 * Support of OpenBSD
diff -r 59c6ea40fe4f -r 3e45f3752074 WebApplication/viewer.js
--- a/WebApplication/viewer.js	Fri Jan 05 16:39:45 2018 +0100
+++ b/WebApplication/viewer.js	Tue Mar 13 10:24:38 2018 +0100
@@ -161,7 +161,15 @@
     iframe.style.display = 'none';
     document.body.appendChild(iframe);
   }
-  iframe.src = '../../instances/' + instance + '/file';
+
+  var id = instance;
+  var pos = instance.indexOf('_');
+  if (pos != -1) {
+    // Remove the frame index (after the underscore)
+    id = id.substring(0, pos);
+  }
+
+  iframe.src = '../../instances/' + id + '/file';
 }