Commit c749ce4e authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'replaceInnerHTML' into 'dev'

Replace innerHTML to a more efficient solution

See merge request !7
parents 00f223f0 edfe7532
......@@ -113,8 +113,8 @@ Builder.prototype = {
build_settings: function () {
var self = this;
var normalize_list = document.getElementById("normalize_list");
normalize_list.innerHTML="";
normalize_list.removeAllChildren();
var input = document.createElement("input");
input.type = "radio";
input.value= -1;
......@@ -182,7 +182,7 @@ Builder.prototype = {
editTagName: function (tagID, elem) {
var self = this;
var divParent = elem.parentNode;
divParent.innerHTML = "";
divParent.removeAllChildren();
var input = this.setupInput("new_tag_name", "", "text", this.m.tag[tagID].name);
input.style.width = "100px";
......@@ -233,7 +233,7 @@ Builder.prototype = {
//TODO rename
build_edit: function (input, id, elem, callback) {
var divParent = elem.parentNode;
divParent.innerHTML = "";
divParent.removeAllChildren();
divParent.appendChild(input);
divParent.onclick = "";
......@@ -305,8 +305,8 @@ Builder.prototype = {
// var listGermline = document.getElementById("germline_list")
//reset
listTag.innerHTML = "";
// listGermline.innerHTML = "";
listTag.removeAllChildren();
// listGermline.removeAllChildren();
//init tag list
for (var i = 0; i < this.m.tag.length; i++) {
......@@ -437,7 +437,7 @@ Builder.prototype = {
var self = this
try {
var parent = document.getElementById("info")
parent.innerHTML = "";
parent.removeAllChildren();
var patient_info = typeof this.m.info != 'undefined' ? this.m.info : "";
var div_patient_info = this.create_generic_info_container(
......@@ -633,7 +633,7 @@ Builder.prototype = {
build_top_container: function () {
var self = this;
var parent = document.getElementById("top_info");
parent.innerHTML = "";
parent.removeAllChildren();
parent.appendChild(document.createTextNode(this.m.getPrintableAnalysisName()));
var selector = document.createElement('div');
......
......@@ -299,7 +299,7 @@ Com.prototype = {
popupHTML: function (domElement) {
this.popup_container.style.display = "block";
this.popup_container.lastElementChild
.innerHTML = "";
.removeAllChildren();
this.popup_container.lastElementChild
.appendChild(domElement);
$(this.popup_container).find('button').focus();
......@@ -311,7 +311,7 @@ Com.prototype = {
closePopupMsg: function () {
this.popup_container.style.display = "none";
this.popup_container.lastElementChild
.innerHTML = "";
.removeAllChildren();
},
/**
......@@ -328,7 +328,7 @@ Com.prototype = {
* */
closeDataBox: function() {
this.div_dataBox.style.display = "none";
this.div_dataBox.lastElementChild.innerHTML = "";
this.div_dataBox.lastElementChild.removeAllChildren();
}
}
......@@ -100,7 +100,7 @@ function imgtPost(data, system) {
imgtInput["l01p01c04"] = "TR";
}
var form = document.getElementById("form");
form.innerHTML = "";
form.removeAllChildren();
form.target = "_blank";
form.action = "http://www.imgt.org/IMGT_vquest/vquest";
form.method = "POST";
......@@ -140,7 +140,7 @@ function imgtPostForSegmenter(data, system, segmenter, override_imgt_options) {
//update imgt button according to request processing
if (typeof imgt4segButton != "undefined"){
imgt4segButton.innerHTML = '';
imgt4segButton.removeAllChildren();
imgt4segButton.appendChild(icon('icon-spin4 animate-spin', 'Sequences sent to IMGT/V-QUEST'));
}
......@@ -169,7 +169,7 @@ function imgtPostForSegmenter(data, system, segmenter, override_imgt_options) {
imgtInput["l01p01c04"] = "TR";
}
var form = document.getElementById("form");
form.innerHTML = "";
form.removeAllChildren();
form.target = "";
//disabled due to security concerns
//form.action = "http://www.imgt.org/IMGT_vquest/vquest";
......@@ -233,7 +233,7 @@ function imgtPostForSegmenter(data, system, segmenter, override_imgt_options) {
});
var span = document.getElementById('highlightCheckboxes');
span.innerHTML = "";
span.removeAllChildren();
var input = document.createElement('input');
input.type = 'checkbox';
input.id = 'imgt_cdr3_input_check';
......@@ -329,7 +329,7 @@ function igBlastPost(data, system) {
var form = document.getElementById("form");
form.innerHTML = "";
form.removeAllChildren();
form.target = "_blank";
form.action = "https://www.ncbi.nlm.nih.gov/igblast/igblast.cgi";
form.method = "POST";
......@@ -359,7 +359,7 @@ function arrestPost(data, system) {
arrestInput["args"] = data;
var form = document.getElementById("form");
form.innerHTML = "";
form.removeAllChildren();
form.target = "_blank";
form.action = "http://tools.bat.infspire.org/cgi-bin/arrest/compile.junctions.online.pl";
form.method = "POST";
......@@ -402,7 +402,7 @@ function blastPost(data, system) {
blastInput["query_sequence"] = data;
var form = document.getElementById("form");
form.innerHTML = "";
form.removeAllChildren();
form.target = "_blank";
form.action = "http://www.ensembl.org/Multi/Tools/Blast?db=core";
form.method = "POST";
......
......@@ -848,7 +848,7 @@ Database.prototype = {
//efface et ferme la fenetre de dialogue avec le serveur
close: function () {
this.div.style.display = "none";
this.msg.innerHTML = "";
this.msg.removeAllChildren();
$('#menu-container').removeClass('disabledClass');
},
......
......@@ -120,8 +120,8 @@ Graph.prototype = {
build_graph : function () {
try {
document.getElementById(this.id)
.innerHTML = "";
.removeAllChildren();
this.mode = "curve";
var self = this;
......@@ -260,8 +260,8 @@ Graph.prototype = {
var self = this;
var list = document.getElementById("" + this.id + "_list")
list.innerHTML = ""
list.removeAllChildren();
for (var i=0; i<this.m.samples.number; i++){
if ( this.m.samples.order.indexOf(i) == -1){
$("<div/>", {
......
......@@ -142,7 +142,7 @@ List.prototype = {
this.index = []
var div_parent = document.getElementById(this.id);
div_parent.innerHTML = "";
div_parent.removeAllChildren();
var div_list_menu = this.build_list_menu()
......@@ -177,8 +177,8 @@ List.prototype = {
this.index_data = {}
var div_parent = document.getElementById(this.id_data);
div_parent.innerHTML = "";
div_parent.removeAllChildren();
var div_list_data = document.createElement('div');
div_list_data.id = "list_data";
for (var key in this.m.data_info) {
......@@ -372,7 +372,7 @@ List.prototype = {
div_elem: function (div_elem, cloneID) {
var self = this;
div_elem.innerHTML = '';
div_elem.removeAllChildren();
div_elem.onmouseover = function () {
self.m.focusIn(cloneID);
}
......@@ -484,7 +484,7 @@ List.prototype = {
//update cluster icon
var span_cluster = div_elem.getElementsByClassName("clusterBox")[0];
span_cluster.innerHTML="";
span_cluster.removeAllChildren();
if (this.m.clusters[cloneID].length > 1) {
if (clone.split) {
span_cluster.onclick = function () {
......@@ -518,7 +518,7 @@ List.prototype = {
div_cluster: function (div_cluster, cloneID) {
var self = this;
div_cluster.innerHTML = '';
div_cluster.removeAllChildren();
div_cluster.id = "cluster" + cloneID;
div_cluster.id2 = cloneID;
......@@ -606,7 +606,7 @@ List.prototype = {
}
var divParent = elem;
var old_event = divParent.onclick;
divParent.innerHTML = "";
divParent.removeAllChildren();
if (cloneID[0] == 's')
cloneID = cloneID.substr(3);
......@@ -654,8 +654,8 @@ List.prototype = {
var div = this.index[cloneID];
div.style.display = "block";
if (!this.m.clone(cloneID).isActive()) div.style.display = "none";
div.innerHTML = '';
div.removeAllChildren();
var div2 = document.createElement('div');
this.div_elem(div2, cloneID);
div.appendChild(div2);
......
......@@ -1736,7 +1736,7 @@ changeCloneNotation: function(cloneNotationType) {
$(".listSeq").find(".infoBox").removeClass("infoBox-open")
this.clone_info = -1;
this.infoBox.style.display = "none";
this.infoBox.lastElementChild.innerHTML = "";
this.infoBox.lastElementChild.removeAllChildren();
},
......@@ -1747,7 +1747,7 @@ changeCloneNotation: function(cloneNotationType) {
openTagSelector: function (cloneID, e) {
var self = this;
cloneID = typeof cloneID !== 'undefined' ? cloneID : this.cloneID;
this.tagSelectorList.innerHTML = "";
this.tagSelectorList.removeAllChildren();
this.cloneID=cloneID
......@@ -2124,7 +2124,7 @@ changeCloneNotation: function(cloneNotationType) {
resume: function(){
this.waiting_screen.style.display = "none";
this.waiting_msg.innerHTML= "";
this.waiting_msg.removeAllChildren();
if (typeof shortcut != 'undefined') shortcut.on = true;
},
......
......@@ -318,7 +318,7 @@ ScatterPlot.prototype = {
try {
document.getElementById(this.id)
.innerHTML = "";
.removeAllChildren();
this.initMenu();
this.initSVG();
......
......@@ -236,3 +236,20 @@ function sendErrorToDb(err, db) {
throw err;
}
}
/*
* Removes all children from the specified node.
* This function should be more efficient and faster than `innerHTML = ''`.
* @param {Node} node - the node to clean from its children.
*/
function remove_all_children(node)
{
while (node.lastChild) {
node.removeChild(node.lastChild);
}
}
// Add the clean_nodes function to the Node prototype
Node.prototype.removeAllChildren = function removeAllChildren() {
remove_all_children(this);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment