Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
Fixing callback on IE
  • Loading branch information
brynlewis committed Aug 30, 2016
1 parent 55ef903 commit 4377778
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 81 deletions.
3 changes: 1 addition & 2 deletions css/cda.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -226,4 +226,3 @@ tr.duplicate{
textarea{
border:1px solid #999;
}
}
43 changes: 32 additions & 11 deletions index.htm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
Expand All @@ -7,9 +7,14 @@

<title>HL7 C-CDA Viewer (Intelsoft)</title>

<script src="js/core.js"></script>
<script src="js/jquery-1.12.0.min.js"></script>
<!--
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>window.jQuery || document.write('&lt;script src="js/jquery-1.12.0.min.js">\x3C/script>')</script>
-->
<script src="js/core.js"></script>

<link rel="stylesheet" type="text/css" media="all" href="css/font-awesome.css" />
<!--<link rel="stylesheet" type="text/css" media="all" href="css/font-awesome.css" />-->
<link rel="stylesheet" type="text/css" media="all" href="css/cda.css" />
<link rel="stylesheet" type="text/css" media="all" href="css/pure-min.css" />

Expand All @@ -22,8 +27,6 @@
<link rel="stylesheet" href="css/marketing.css">
<!--<![endif]-->

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>window.jQuery || document.write('&lt;script src="js/jquery-1.12.0.min.js">\x3C/script>')</script>

<script src="js/packery.pkgd.min.js"></script>
<script src="js/draggabilly.pkgd.min.js"></script>
Expand All @@ -47,6 +50,7 @@

<div class="custom-wrapper pure-g home-menu pure-menu pure-menu-fixed" style="width:100%" id="men">
<div class="pure-u-1">

<span class="pure-button viewbtn" id="inputcdabtn" id_target="inputcda" style="float:right;display:block"><i class="fa fa-lg fa-file-code-o"></i> Input CDA Document</span>
<a href="home.htm" class="" style="float:left;font-weight:bold;font-size:1.75em;;padding-top:0.2em;padding-bottom:0.5em;text-decoration:none">HL7 C-CDA Viewer</a>
</div>
Expand All @@ -65,13 +69,29 @@
placeholder="Your C-CDA document goes here:
<ClinicalDocument xmlns=&quot;urn:hl7-org:v3&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:sdtc=&quot;urn:hl7-org:sdtc&quot; xmlns:cda=&quot;urn:hl7-org:v3&quot;>"
></textarea>
<p>Sample CDA documents</p>
<div style="width:35em;font-size:80%">
<span id="" style="width:100%;text-align:left" file="./samples/Final_Task_Force_Full_Sample_R1.1.xml" class="pure-button transform">Summary of Care (Final_Task_Force_Full_Sample_R1.1.xml) <i class="fa fa-angle-double-right"></i></span>
<span id="" style="width:100%;text-align:left" file="./samples/R2.xml" class="pure-button transform">Patient Chart Summary (C-CDA_R2-1_CCD.xml) <i class="fa fa-angle-double-right"></i></span>
<span id="" style="width:100%;text-align:left" file="./samples/C-CDA_R2_Care_Plan.xml" class="pure-button transform">Care Plan (C-CDA_R2_Care_Plan.xml) <i class="fa fa-angle-double-right"></i></span>
<span id="" style="width:100%;text-align:left" file="./samples/Sample-p2.xml" class="pure-button transform">Outpatient Summary (Sample-p2.xml) <i class="fa fa-angle-double-right"></i></span>
<p>Sample CDA documents are listed below.</p>
<div style="width:45em;font-size:90%">
<span style="width:75%;text-align:left" file="./samples/Final_Task_Force_Full_Sample_R1.1.xml" class="pure-button transform">
Summary of Care (Final_Task_Force_Full_Sample_R1.1.xml) <i class="fa fa-angle-double-right"></i>
</span>
<span onclick="loadtextarea('./samples/Final_Task_Force_Full_Sample_R1.1.xml')" class="pure-button">Show XML</span>

<span style="width:75%;text-align:left" file="./samples/R2.xml" class="pure-button transform">Patient Chart Summary (C-CDA_R2-1_CCD.xml) <i class="fa fa-angle-double-right"></i></span>
<span onclick="loadtextarea('./samples/R2.xml')" class="pure-button">Show XML</span>

<span style="width:75%;text-align:left" file="./samples/C-CDA_R2_Care_Plan.xml" class="pure-button transform">Care Plan (C-CDA_R2_Care_Plan.xml) <i class="fa fa-angle-double-right"></i></span>
<span onclick="loadtextarea('./samples/C-CDA_R2_Care_Plan.xml')" class="pure-button">Show XML</span>

<span style="width:75%;text-align:left" file="./samples/Sample-p1.xml" class="pure-button transform">Dismissal Summary (Sample-p1.xml) <i class="fa fa-angle-double-right"></i></span>
<span onclick="loadtextarea('./samples/Sample-p1.xml')" class="pure-button">Show XML</span>

<span style="width:75%;text-align:left" file="./samples/Sample-p2.xml" class="pure-button transform">Outpatient Summary (Sample-p2.xml) <i class="fa fa-angle-double-right"></i></span>
<span onclick="loadtextarea('./samples/Sample-p2.xml')" class="pure-button">Show XML</span>
</div>
<p>Click 'Show XML' to insert the XML into the box above, then click 'View' (above) to see this XML in the viewer.</p>
<p>Click each document to show the CDA document in the viewer.</p>
<p>After viewing, click 'Input CDA Document' (top right), to return to this input screen.</p>
<p>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.</p>
</div>
<div class=" cdaview" id="viewcda">
<p><p>
Expand All @@ -80,6 +100,7 @@
<a href="http://intelsoft.com.au" class="intelsoft" style="">
<i class="fa fa-rocket"></i> Made by Intelsoft
</a>
<span id="storagemsg"></span>
</div>

</div>
Expand Down
75 changes: 46 additions & 29 deletions js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -14,7 +15,6 @@ $(document).ready(function(){

})
function init(){

sectionorder=[];
$('li.toc[data-code]').each(function(){
sectionorder.push($(this).attr('data-code'))
Expand Down Expand Up @@ -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')
Expand All @@ -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;
Expand Down Expand Up @@ -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')
}


Expand Down Expand Up @@ -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()
}
}

99 changes: 60 additions & 39 deletions js/xslt/xslt.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Changes made 2016:
* Copyright (c) 2016 Bryn Lewis (<mailto:[email protected]>)
* Updates made to allow usage in Internet Explorer 11.
*
* Adapted to load C-CDA sections in viewer
*/

/**
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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');
Expand Down Expand Up @@ -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;
Expand All @@ -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();
//}
}

}
Expand All @@ -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;
Expand Down

0 comments on commit 4377778

Please sign in to comment.