From 43777787fd36d295cc698bc737f49058c58fffee Mon Sep 17 00:00:00 2001 From: brynlewis Date: Tue, 30 Aug 2016 14:09:52 +1000 Subject: [PATCH] 1 Fixing callback on IE --- css/cda.css | 3 +- index.htm | 43 +++++++++++++++------ js/core.js | 75 ++++++++++++++++++++++--------------- js/xslt/xslt.js | 99 ++++++++++++++++++++++++++++++------------------- 4 files changed, 139 insertions(+), 81 deletions(-) diff --git a/css/cda.css b/css/cda.css index 931472c..cdde93b 100644 --- a/css/cda.css +++ b/css/cda.css @@ -21,7 +21,7 @@ table{ } div{ - font-family: "Open Sans",Arial, "Trebuchet MS"; + font-family: Segoe UI,"Open Sans",Arial, "Trebuchet MS"; } a { color: #003366; @@ -226,4 +226,3 @@ tr.duplicate{ textarea{ border:1px solid #999; } -} \ No newline at end of file diff --git a/index.htm b/index.htm index e591114..a67bb1a 100644 --- a/index.htm +++ b/index.htm @@ -1,4 +1,4 @@ - + @@ -7,9 +7,14 @@ HL7 C-CDA Viewer (Intelsoft) - + + + - + @@ -22,8 +27,6 @@ - - @@ -47,6 +50,7 @@
+ Input CDA Document HL7 C-CDA Viewer
@@ -65,13 +69,29 @@ placeholder="Your C-CDA document goes here: " > -

Sample CDA documents

-
- Summary of Care (Final_Task_Force_Full_Sample_R1.1.xml) - Patient Chart Summary (C-CDA_R2-1_CCD.xml) - Care Plan (C-CDA_R2_Care_Plan.xml) - Outpatient Summary (Sample-p2.xml) +

Sample CDA documents are listed below.

+
+ + Summary of Care (Final_Task_Force_Full_Sample_R1.1.xml) + + Show XML + + Patient Chart Summary (C-CDA_R2-1_CCD.xml) + Show XML + + Care Plan (C-CDA_R2_Care_Plan.xml) + Show XML + + Dismissal Summary (Sample-p1.xml) + Show XML + + Outpatient Summary (Sample-p2.xml) + Show XML
+

Click 'Show XML' to insert the XML into the box above, then click 'View' (above) to see this XML in the viewer.

+

Click each document to show the CDA document in the viewer.

+

After viewing, click 'Input CDA Document' (top right), to return to this input screen.

+

Note that performance has not been optimised for viewing from a web server, as it was not a condition of the challenge. Local deployments of the fileset will perform more responsive rendering.

@@ -80,6 +100,7 @@ Made by Intelsoft +

diff --git a/js/core.js b/js/core.js index e532d21..c6b4f5e 100644 --- a/js/core.js +++ b/js/core.js @@ -2,6 +2,7 @@ var cdaxml=''; var hidden=new Array(); var firstsection=new Array(); var sectionorder=[]; +var collapseall; //localStorage.setItem("hidden", hidden); $(document).ready(function(){ @@ -14,7 +15,6 @@ $(document).ready(function(){ }) function init(){ - sectionorder=[]; $('li.toc[data-code]').each(function(){ sectionorder.push($(this).attr('data-code')) @@ -228,12 +228,12 @@ function init(){ //jquery $('#viewcda').xslt(cdaxml, './cda.xsl'); new Transformation().setXml(cdaxml).setXslt('cda.xsl').transform("viewcda"); - $('#inputcda').hide(function(){ - $('#viewcda').show(function(){ - init() - $('#inputcdabtn').show() - }) - }) + //$('#inputcda').hide(function(){ + //$('#viewcda').show(function(){ + //init() + //$('#inputcdabtn').show() + //}) + //}) }) $('i.delete').click(function(){ var section=$(this).closest('div.section') @@ -250,28 +250,27 @@ function init(){ }) - collapseall=localStorage.collapseall - //alert(collapseall) - if((collapseall==undefined)||(collapseall=='false')){ - $('div.sectiontext').show(function(){ - //adjustWidth($(this).parent().parent()) - }) - $('.hideshow').find('i').addClass('fa-compress').removeClass('fa-expand') - $('.minimise').addClass('fa-compress').removeClass('fa-expand') - } - else{ - $('div.sectiontext').hide(function(){ - //alert('asdf') - adjustWidth($(this).parent().parent()) - }) - $('.hideshow').find('i').addClass('fa-expand').removeClass('fa-compress') - - //$('.minimise').toggleClass('fa-compress fa-expand') - } - //$('.hideshow').find('i').toggleClass('fa-compress fa-expand') - //$('.minimise').toggleClass('fa-compress fa-expand') - if(typeof(Storage) !== "undefined") { + if((typeof(Storage) !== "undefined")&&(localStorage!=undefined)) { + collapseall=localStorage.collapseall + //alert(collapseall) + if((collapseall==undefined)||(collapseall=='false')){ + $('div.sectiontext').show(function(){ + //adjustWidth($(this).parent().parent()) + }) + $('.hideshow').find('i').addClass('fa-compress').removeClass('fa-expand') + $('.minimise').addClass('fa-compress').removeClass('fa-expand') + } + else{ + $('div.sectiontext').hide(function(){ + //alert('asdf') + adjustWidth($(this).parent().parent()) + }) + $('.hideshow').find('i').addClass('fa-expand').removeClass('fa-compress') + + //$('.minimise').toggleClass('fa-compress fa-expand') + } + if(typeof(localStorage.hidden)!='undefined'){ hidden=localStorage.hidden.split(',') var ihid=0; @@ -311,7 +310,7 @@ function init(){ var d=new Date(); localStorage.setItem("lastaccess", d.getDate()+" "+d.getMonth()+" "+d.getFullYear()); } else { - alert('Your browser does not have localStorage - your preferences will not be saved') + $('#storagemsg').text('Your browser does not have localStorage - your preferences will not be saved') } @@ -412,3 +411,21 @@ function comparer(index) { } } function getCellValue(row, index){ return $(row).children('td').eq(index).html() } + +var xmload; +function loadtextarea(fname){ + xmload = new XMLHttpRequest(); + xmload.onreadystatechange = loaded; + try{ + xmload.open("GET", fname,true); + } + catch(e){alert(e)} + xmload.send(null); +} +var loaded = function() { + if (xmload.readyState == 4) { + $('#cdaxml').val(xmload.responseText) + //$('#transform').get(0).click() + } +} + \ No newline at end of file diff --git a/js/xslt/xslt.js b/js/xslt/xslt.js index 7bd39ba..e55400d 100644 --- a/js/xslt/xslt.js +++ b/js/xslt/xslt.js @@ -28,7 +28,7 @@ * Changes made 2016: * Copyright (c) 2016 Bryn Lewis () * Updates made to allow usage in Internet Explorer 11. - * + * Adapted to load C-CDA sections in viewer */ /** @@ -51,7 +51,14 @@ function Transformation() { var xsltDoc; - var callback = function() {}; + var callback = function() { + $('#inputcda').hide(function(){ + $('#viewcda').show(function(){ + init() + $('#inputcdabtn').show() + }) + }) + }; /** * Sort of like a fix for Opera who doesn't always get readyStates right. @@ -156,7 +163,7 @@ function Transformation() { * * @param target the ID of an element */ - this.transform = function(target) { + this.transform = function(target,postTransform) { if (!browserSupportsXSLT()) { alert('This browser does not support XSLT in javascript, so we cannot continue, sorry.') return; @@ -176,21 +183,26 @@ function Transformation() { if (isIE) { var change = function() { - var c = 4; // 'complete'; - if (xm.readyState == c && xs.readyState == c) { - window.setTimeout(function() { + //var c = 4; // 'complete'; + //if (xm.readyState == c && xs.readyState == c) { + //window.setTimeout(function() { var source = new ActiveXObject("Msxml2.DOMDocument.3.0"); source.async = false; - source.load(xml); + if(str.test(xml)) + source.loadXML(xml) + else + source.load(xml) var stylesheet = new ActiveXObject("Msxml2.DOMDocument.3.0"); stylesheet.async = false stylesheet.load("cda.xsl"); - callback(t); + //callback(t); document.getElementById(target).innerHTML = source.transformNode(stylesheet) //document.all[target].innerHTML = xmlDoc.transformNode(xs.responseXML); - }, 50); - } + callback(t); + + //}, 50); + //} }; /* var xm = document.createElement('xml'); @@ -220,15 +232,19 @@ function Transformation() { resultDoc = document.implementation.createDocument("", "", null); processor.transformDocument(xm.responseXML, xs.responseXML, resultDoc, null); var out = new XMLSerializer().serializeToString(resultDoc); - callback(t); + //callback(t); document.getElementById(target).innerHTML = out; + callback(t); } else { processor.importStylesheet(xs.responseXML); resultDoc = processor.transformToFragment(xm.responseXML, document); - callback(t); + //callback(t); document.getElementById(target).innerHTML = ''; document.getElementById(target).appendChild(resultDoc); + //callback(t); + callback() + //init(); } transformed = true; @@ -237,35 +253,40 @@ function Transformation() { } - if (str.test(xml)) { - xm.responseXML = new DOMParser().parseFromString(xml, "text/xml"); - if($(xm.responseXML.documentElement).text().indexOf('XML Parsing Error')>-1){ - alert($(xm.responseXML.documentElement).text()) - } - if($(xm.responseXML.documentElement).text().indexOf('This page contains the following errors:')>-1){ - alert($(xm.responseXML.documentElement).text()) - } + if (isIE) { + change() } - else { - xm = new XMLHttpRequest(); - xm.onreadystatechange = change; - try{ - xm.open("GET", xml,true); + else{ + if (str.test(xml)) { + xm.responseXML = new DOMParser().parseFromString(xml, "text/xml"); + if($(xm.responseXML.documentElement).text().indexOf('XML Parsing Error')>-1){ + alert($(xm.responseXML.documentElement).text()) + } + if($(xm.responseXML.documentElement).text().indexOf('This page contains the following errors:')>-1){ + alert($(xm.responseXML.documentElement).text()) + } + } + else { + xm = new XMLHttpRequest(); + xm.onreadystatechange = change; + try{ + xm.open("GET", xml,true); + } + catch(e){alert(e)} + xm.send(null); } - catch(e){alert(e)} - xm.send(null); - } - if (str.test(xslt)) { - xs.responseXML = new DOMParser().parseFromString(xslt, "text/xml"); - change(); - } - else { - xs = new XMLHttpRequest(); - xs.onreadystatechange = change; - xs.open("GET", xslt); - xs.send(null); - //change(); + //if (str.test(xslt)) { + // xs.responseXML = new DOMParser().parseFromString(xslt, "text/xml"); + // change(); + //} + //else { + xs = new XMLHttpRequest(); + xs.onreadystatechange = change; + xs.open("GET", xslt); + xs.send(null); + //change(); + //} } } @@ -279,7 +300,7 @@ function Transformation() { * @type boolean */ function browserSupportsXSLT() { - var support = false; + var support = true; //if (document.recalc) { // IE 5+ if (isIE) { // IE 5+ support = true;