comparison js/core.js @ 2646:dc08127a5084

#9: Use DOMParser to conver HTML string to DOM for injection
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 19 Jan 2017 15:49:33 +0000
parents 130ae66c3b25
children 83ae42eab960
comparison
equal deleted inserted replaced
2645:130ae66c3b25 2646:dc08127a5084
633 }; 633 };
634 634
635 this.postNode = function () { 635 this.postNode = function () {
636 // This will take the node from the popupOptions and display it 636 // This will take the node from the popupOptions and display it
637 var node = this.popupOptions[this.currentIndex], 637 var node = this.popupOptions[this.currentIndex],
638 converter = new showdown.Converter(); 638 converter = new showdown.Converter(),
639 p = new DOMParser();
639 this.popupResponse.innerHTML = ""; 640 this.popupResponse.innerHTML = "";
640 this.popupTitle = converter.makeHtml(node.specification.statement); 641 this.popupTitle = p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").getElementsByTagName("body")[0].firstElementChild;
641 if (node.specification.type == 'question') { 642 if (node.specification.type == 'question') {
642 var textArea = document.createElement('textarea'); 643 var textArea = document.createElement('textarea');
643 switch (node.specification.boxsize) { 644 switch (node.specification.boxsize) {
644 case 'small': 645 case 'small':
645 textArea.cols = "20"; 646 textArea.cols = "20";