From db6fae4cf1cfe5e9b65f32840e7f4417039b0934 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Fri, 19 May 2017 16:35:10 +0200 Subject: [PATCH] unnecessary promise removed --- frontend-js/src/main/js/gui/Legend.js | 72 +++++++++++++-------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/frontend-js/src/main/js/gui/Legend.js b/frontend-js/src/main/js/gui/Legend.js index 8e9303a3cf..53d386109b 100644 --- a/frontend-js/src/main/js/gui/Legend.js +++ b/frontend-js/src/main/js/gui/Legend.js @@ -40,29 +40,31 @@ Legend.prototype._initializeGui = function() { type : "div", name : "slides", className : "carousel-inner", - role:"listbox", + role : "listbox", }); legendDiv.appendChild(slidesDiv); self.setControlElement(PanelControlElementType.LEGEND_SLIDES_DIV, slidesDiv); - var leftButton = Functions.createElement({ - type : "a", - className : "left carousel-control", - role:"button", - href:"#legend-div", - content: '<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="sr-only">Previous</span>', - }); - leftButton.setAttribute("data-slide", "prev" ); + var leftButton = Functions + .createElement({ + type : "a", + className : "left carousel-control", + role : "button", + href : "#legend-div", + content : '<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span><span class="sr-only">Previous</span>', + }); + leftButton.setAttribute("data-slide", "prev"); legendDiv.appendChild(leftButton); - var rightButton = Functions.createElement({ - type : "a", - className : "right carousel-control", - role:"button", - href:"#legend-div", - content: '<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="sr-only">Next</span>', - }); - rightButton.setAttribute("data-slide", "next" ); + var rightButton = Functions + .createElement({ + type : "a", + className : "right carousel-control", + role : "button", + href : "#legend-div", + content : '<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span><span class="sr-only">Next</span>', + }); + rightButton.setAttribute("data-slide", "next"); legendDiv.appendChild(rightButton); }; @@ -76,20 +78,19 @@ Legend.prototype.show = function() { function createLegendIndicator(file, index) { var result = document.createElement("li"); result.setAttribute("data-target", "legend"); - result.setAttribute("data-slide-to", ""+index); - if (index ===0) { - result.className="active"; + result.setAttribute("data-slide-to", "" + index); + if (index === 0) { + result.className = "active"; } return result; } - function createLegendSlide(file, index) { var result = document.createElement("div"); - if (index ===0) { - result.className="item active"; + if (index === 0) { + result.className = "item active"; } else { - result.className="item"; + result.className = "item"; } var img = document.createElement("img"); img.src = file; @@ -100,21 +101,16 @@ function createLegendSlide(file, index) { Legend.prototype.init = function() { var self = this; var element = self.getElement(); - return new Promise(function(resolve,reject){ - - var menu = self.getControlElement(PanelControlElementType.LEGEND_INDICATIORS_OL); - var slides = self.getControlElement(PanelControlElementType.LEGEND_SLIDES_DIV); - ServerConnector.getConfigurationParam(ConfigurationType.LEGEND_FILES).then(function(legendFiles){ - for (var i=0; i<legendFiles.length;i++) { - var legendFile = legendFiles[i]; - menu.appendChild(createLegendIndicator(legendFile, i)); - slides.appendChild(createLegendSlide(legendFile, i)); - } - $(element).carousel(); - resolve(); - }).catch(reject); + var menu = self.getControlElement(PanelControlElementType.LEGEND_INDICATIORS_OL); + var slides = self.getControlElement(PanelControlElementType.LEGEND_SLIDES_DIV); + return ServerConnector.getConfigurationParam(ConfigurationType.LEGEND_FILES).then(function(legendFiles) { + for (var i = 0; i < legendFiles.length; i++) { + var legendFile = legendFiles[i]; + menu.appendChild(createLegendIndicator(legendFile, i)); + slides.appendChild(createLegendSlide(legendFile, i)); + } + $(element).carousel(); }); }; - module.exports = Legend; -- GitLab