From c0e071095e73846b9d3b98bc5e9ae39237d4f59b Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 9 May 2018 15:44:19 +0000 Subject: [PATCH] ref 11746: NLP Hub with empty output https://support.d4science.org/issues/11746 Fixed error when algorithm result is undefined git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/nlphub@167382 82a268e6-3cf1-43bd-a215-b396298e98cf --- src/main/webapp/js/main.js | 703 +++++++++++++++++++------------------ 1 file changed, 368 insertions(+), 335 deletions(-) diff --git a/src/main/webapp/js/main.js b/src/main/webapp/js/main.js index 021f0bd..43b7569 100644 --- a/src/main/webapp/js/main.js +++ b/src/main/webapp/js/main.js @@ -30,7 +30,7 @@ $(document).ready(function() { }); checkInputLink = function() { - if(inputFile != "") { + if (inputFile != "") { showProgress(); $.ajax({ url : inputFile, @@ -38,172 +38,186 @@ checkInputLink = function() { async : true, success : function(data, stato) { freeText = data; - var uploaderUrl = appRoot + "/nlphub-uploader-servlet?getlang=on&freetext=" - + encodeURIComponent(freeText) + "&dataminer=" + encodeURIComponent(dataMiner); - - if(gCubeToken.length > 0) - uploaderUrl += "&gcube-token=" + gCubeToken; + var uploaderUrl = appRoot + + "/nlphub-uploader-servlet?getlang=on&freetext=" + + encodeURIComponent(freeText) + "&dataminer=" + + encodeURIComponent(dataMiner); + + if (gCubeToken.length > 0) + uploaderUrl += "&gcube-token=" + gCubeToken; $.ajax({ - url : uploaderUrl, - type : "POST", - async : true, - contentType : "text/plain; charset=utf-8", - success : function(data, stato) { - hideProgress(); - $("#input-textarea").val(freeText); - computedLanguage = data.language; - initApplication(); - }, - error : function(richiesta, stato, - errori) { - alert("Unexpected Error. Status: " - + richiesta.status); - hideProgress(); - textAreaEnable(true); - $("#file-info").empty(); - initApplication(); - } - }); + url : uploaderUrl, + type : "POST", + async : true, + contentType : "text/plain; charset=utf-8", + success : function(data, stato) { + hideProgress(); + $("#input-textarea").val(freeText); + computedLanguage = data.language; + initApplication(); + }, + error : function(richiesta, stato, errori) { + alert("Unexpected Error. Status: " + richiesta.status); + hideProgress(); + textAreaEnable(true); + $("#file-info").empty(); + initApplication(); + } + }); }, error : function(richiesta, stato, errori) { - alert("Unexpected error reading from link: '" + inputFile + "'.\nStatus: " + richiesta.status + " Error: " + errori + "\nClick OK to start application."); + alert("Unexpected error reading from link: '" + inputFile + + "'.\nStatus: " + richiesta.status + " Error: " + + errori + "\nClick OK to start application."); hideProgress(); initApplication(); } }); - } - else initApplication(); + } else + initApplication(); } initApplication = function() { - $.ajax({ - url : "https://data.d4science.org/bnp4UDNyb21lSURkQXdDUnlSS0JkVWgzWk1KMUxWVGZHbWJQNStIS0N6Yz0", - type : "GET", - async : true, - contentType : "text/plain; charset=utf-8", - success : function(data, stato) { - $("#ner-result-container").hide(); - var lineTokens = manageCsvData(data); - getAlgorithms(lineTokens); - buildLanguageSelection(); - buildLanguageList(); - buildAnnotations(); - resizeTable(); - resizeLogo(); - enableAjaxFileUpload(); - collapsibleHandler(); - - $("#logo-image").click(function() { - backHandler(); - }); - - $("#back-ner-ui-button").click(function() { - backHandler(); - }); + $ + .ajax({ + url : "https://data.d4science.org/bnp4UDNyb21lSURkQXdDUnlSS0JkVWgzWk1KMUxWVGZHbWJQNStIS0N6Yz0", + type : "GET", + async : true, + contentType : "text/plain; charset=utf-8", + success : function(data, stato) { + $("#ner-result-container").hide(); + var lineTokens = manageCsvData(data); + getAlgorithms(lineTokens); + buildLanguageSelection(); + buildLanguageList(); + buildAnnotations(); + resizeTable(); + resizeLogo(); + enableAjaxFileUpload(); + collapsibleHandler(); - disableExecuteButton(); - var uploaderUrl = appRoot + "/nlphub-uploader-servlet?dataminer=" + encodeURIComponent(dataMiner); - if(gCubeToken.length > 0) - uploaderUrl += "&gcube-token=" + gCubeToken; - - $("#upload-button") - .uploadFile( - { - url : uploaderUrl, - fileName : "mytxtfile", - maxFileCount : 100, - multiple : false, - maxFileSize : 1024 * 1000 * 1, - showFileCounter : false, - showCancel : true, - //allowedTypes: "txt,.txt", - dragDropStr : "", - extErrorStr : "Error. Text file only", - sizeErrorStr : "Error. Max size: 6 Mb", - onLoad : function(obj) { - txtFlag = true; - $("#file-info").remove(); - $("#reset-upload").remove(); - $("#fu-container") - .append( - "
"); - $("#right-child") - .append( - "
"); - $("#right-child") - .append( - "
Cancel
"); - $("#reset-upload").hide(); - $("#reset-upload").click(function() { - resetExecuteButton(); - $("#file-info").empty(); - $("#reset-upload").css( - "display", "none"); - textAreaEnable(true); - }); - savedAnnotations = ""; - setEventListeners(); - }, - onSelect : function(files) { - var fileName = files[0].name; - var extension = "" + fileName.substring(fileName.lastIndexOf(".")); - if(extension.toUpperCase() == ".TXT") { - showProgress(); - textAreaEnable(false); - $("#input-textarea").val(""); - } else { - txtFlag = false; - alert("The application supports text file only (.TXT)"); - } - publicLink = null; - textAreaEnable(false); - $("#input-textarea").val(""); - }, - onSubmit: function(files) { - var submitFlag = txtFlag; - txtFlag = true; - return submitFlag; - }, - onSuccess : function(files, data, xhr) { - hideProgress(); - checkLanguage(data.language); - selectAnnotationsByLanguage(); - $("#reset-upload").css("display", - "inline"); - $("#file-info").empty(); - $("#file-info") - .append( - "Uploaded: " - + files - + ""); - publicLink = data.message; - enableExecuteButton(); - if (publicLink == null) { - alert("Error uploading file."); - } - }, - onError : function(files, status, errMsg, - pd) { - hideProgress(); - textAreaEnable(true); - alert(errMsg); - } - }); - - if($("#input-textarea").val() != "") { - disableAjaxFileUpload(); - if(computedLanguage != "") { - checkLanguage(computedLanguage); - selectAnnotationsByLanguage(); - computedLanguage = ""; + $("#logo-image").click(function() { + backHandler(); + }); + + $("#back-ner-ui-button").click(function() { + backHandler(); + }); + + disableExecuteButton(); + var uploaderUrl = appRoot + + "/nlphub-uploader-servlet?dataminer=" + + encodeURIComponent(dataMiner); + if (gCubeToken.length > 0) + uploaderUrl += "&gcube-token=" + gCubeToken; + + $("#upload-button") + .uploadFile( + { + url : uploaderUrl, + fileName : "mytxtfile", + maxFileCount : 100, + multiple : false, + maxFileSize : 1024 * 1000 * 1, + showFileCounter : false, + showCancel : true, + // allowedTypes: "txt,.txt", + dragDropStr : "", + extErrorStr : "Error. Text file only", + sizeErrorStr : "Error. Max size: 6 Mb", + onLoad : function(obj) { + txtFlag = true; + $("#file-info").remove(); + $("#reset-upload").remove(); + $("#fu-container") + .append( + "
"); + $("#right-child") + .append( + "
"); + $("#right-child") + .append( + "
Cancel
"); + $("#reset-upload").hide(); + $("#reset-upload") + .click( + function() { + resetExecuteButton(); + $("#file-info") + .empty(); + $( + "#reset-upload") + .css( + "display", + "none"); + textAreaEnable(true); + }); + savedAnnotations = ""; + setEventListeners(); + }, + onSelect : function(files) { + var fileName = files[0].name; + var extension = "" + + fileName + .substring(fileName + .lastIndexOf(".")); + if (extension.toUpperCase() == ".TXT") { + showProgress(); + textAreaEnable(false); + $("#input-textarea").val(""); + } else { + txtFlag = false; + alert("The application supports text file only (.TXT)"); + } + publicLink = null; + textAreaEnable(false); + $("#input-textarea").val(""); + }, + onSubmit : function(files) { + var submitFlag = txtFlag; + txtFlag = true; + return submitFlag; + }, + onSuccess : function(files, data, xhr) { + hideProgress(); + checkLanguage(data.language); + selectAnnotationsByLanguage(); + $("#reset-upload").css("display", + "inline"); + $("#file-info").empty(); + $("#file-info") + .append( + "Uploaded: " + + files + + ""); + publicLink = data.message; + enableExecuteButton(); + if (publicLink == null) { + alert("Error uploading file."); + } + }, + onError : function(files, status, + errMsg, pd) { + hideProgress(); + textAreaEnable(true); + alert(errMsg); + } + }); + + if ($("#input-textarea").val() != "") { + disableAjaxFileUpload(); + if (computedLanguage != "") { + checkLanguage(computedLanguage); + selectAnnotationsByLanguage(); + computedLanguage = ""; + } + enableExecuteButton(); + } + }, + error : function(richiesta, stato, errori) { + alert("Unexpected Error. Status: " + richiesta.status); } - enableExecuteButton(); - } - }, - error : function(richiesta, stato, errori) { - alert("Unexpected Error. Status: " + richiesta.status); - } - }); + }); } /* @@ -211,29 +225,29 @@ initApplication = function() { */ setEventListeners = function() { $(".ajax-file-upload").attr("id", "ajax-file-upload-id"); - + $("#input-textarea").on("keyup", function() { enableDisableTextArea(); }); - + $("#input-textarea").change(function() { enableDisableTextArea(); }); - + window.addEventListener('contextmenu', function(e) { enableDisableTextArea(); - }, false); - + }, false); + $(".popup-text").click(function(e) { hidePopupText(); }); - + $("#execute-button") .click( function() { - if(!isEnabled()) + if (!isEnabled()) return; - + if ((publicLink == null) && ($("#input-textarea").val() == "")) { alert("You must upload a file or write some text in the text area before submit a request."); @@ -241,42 +255,44 @@ setEventListeners = function() { } disableExecuteButton(); - + showProgress(); // if some text has been written in the text area, then // a corresponding text file // must be written in the workspace and the public link // is set. if ($("#input-textarea").val().length > 0) { - //if(publicLink == null) { + // if(publicLink == null) { freeText = $("#input-textarea").val(); - var uploaderUrl = appRoot + "/nlphub-uploader-servlet?freetext=" - + encodeURIComponent(freeText) + "&dataminer=" + encodeURIComponent(dataMiner); - - if(gCubeToken.length > 0) + var uploaderUrl = appRoot + + "/nlphub-uploader-servlet?freetext=" + + encodeURIComponent(freeText) + + "&dataminer=" + + encodeURIComponent(dataMiner); + + if (gCubeToken.length > 0) uploaderUrl += "&gcube-token=" + gCubeToken; $.ajax({ - url : uploaderUrl, - type : "POST", - async : true, - contentType : "text/plain; charset=utf-8", - success : function(data, stato) { - publicLink = data.message; - if (publicLink == null) { - alert("Error uploading file."); - } - runAlgorithm(); - }, - error : function(richiesta, stato, - errori) { - alert("Unexpected Error. Status: " - + richiesta.status); - hideProgress(); - textAreaEnable(true); - $("#file-info").empty(); + url : uploaderUrl, + type : "POST", + async : true, + contentType : "text/plain; charset=utf-8", + success : function(data, stato) { + publicLink = data.message; + if (publicLink == null) { + alert("Error uploading file."); } - }); + runAlgorithm(); + }, + error : function(richiesta, stato, errori) { + alert("Unexpected Error. Status: " + + richiesta.status); + hideProgress(); + textAreaEnable(true); + $("#file-info").empty(); + } + }); } else { @@ -286,88 +302,94 @@ setEventListeners = function() { } collapsibleHandler = function() { -// $('.collapsible').collapsible(); - //$('.collapsible').collapsible({ -// onOpen: function(el) { -// if(el.index() == 0) -// $('.collapsible').collapsible('close', 1); -// else -// $('.collapsible').collapsible('close', 0); -// }, -// onClose: function(el) { -// if(el.index() == 0) -// $('.collapsible').collapsible('open', 1); -// else -// $('.collapsible').collapsible('open', 0); -// } -// }); + // $('.collapsible').collapsible(); + // $('.collapsible').collapsible({ + // onOpen: function(el) { + // if(el.index() == 0) + // $('.collapsible').collapsible('close', 1); + // else + // $('.collapsible').collapsible('close', 0); + // }, + // onClose: function(el) { + // if(el.index() == 0) + // $('.collapsible').collapsible('open', 1); + // else + // $('.collapsible').collapsible('open', 0); + // } + // }); } -enableAjaxFileUpload= function() { +enableAjaxFileUpload = function() { $(".ajax-file-upload").attr("enabled", "true"); $(".ajax-file-upload").css("background", pageGreen); try { - document.getElementById("ajax-file-upload-id").removeEventListener("click", listenAjaxFileUpload); - }catch(err) { + document.getElementById("ajax-file-upload-id").removeEventListener( + "click", listenAjaxFileUpload); + } catch (err) { console.log(err.message); } } -disableAjaxFileUpload= function() { +disableAjaxFileUpload = function() { $(".ajax-file-upload").attr("enabled", "false"); $(".ajax-file-upload").css("background", pageGray); try { - document.getElementById("ajax-file-upload-id").removeEventListener("click", listenAjaxFileUpload); - document.getElementById("ajax-file-upload-id").addEventListener("click", listenAjaxFileUpload); - }catch(err) { - document.getElementById("ajax-file-upload-id").addEventListener("click", listenAjaxFileUpload); + document.getElementById("ajax-file-upload-id").removeEventListener( + "click", listenAjaxFileUpload); + document.getElementById("ajax-file-upload-id").addEventListener( + "click", listenAjaxFileUpload); + } catch (err) { + document.getElementById("ajax-file-upload-id").addEventListener( + "click", listenAjaxFileUpload); } - + } listenAjaxFileUpload = function(event) { event.preventDefault(); } - backHandler = function() { - if($("#ner-ui").is(":visible")) + if ($("#ner-ui").is(":visible")) return; $("#ner-result-container").hide(); $(".popup-text").hide(); $("#ner-ui").show(); - if(publicLink != null) { + if (publicLink != null) { enableExecuteButton(); - if(document.getElementById("reset-upload") != null) { - if($("#reset-upload").is(":visible")) + if (document.getElementById("reset-upload") != null) { + if ($("#reset-upload").is(":visible")) textAreaEnable(false); } } } /* - * Utility function processing the language indication returned by the language recognition service + * Utility function processing the language indication returned by the language + * recognition service */ checkLanguage = function(lang) { - if(lang == 'unavailable') + if (lang == 'unavailable') return; var options = $("#language-select option"); - for(var i=0; i= 0) { var algAnnotations = algorithms[j].annotations.toLowerCase(); - for(k in list) { + for (k in list) { var a = list[k].toLowerCase(); - if(algAnnotations.indexOf(a) > -1) { + if (algAnnotations.indexOf(a) > -1) { algList += encodeURI(algorithms[j].id) + ","; break; } } - + } } if (algList.length == 0) { @@ -585,7 +607,7 @@ runAlgorithm = function() { parameters += "&algs=" + algList; var nlphubUrl = appRoot + "/nlphub-servlet?" + parameters; - if(gCubeToken.length > 0) + if (gCubeToken.length > 0) nlphubUrl += "&gcube-token=" + gCubeToken; $.ajax({ url : nlphubUrl, @@ -618,10 +640,10 @@ getOutputJson = function(message) { var tobemap = ""; for (var i = 0; i < message.length; i++) { var splitted = message[i].split(":::"); - if(splitted[1].toLowerCase().trim() == "error") { - alert("Some error occurrend running algorithm " + splitted[0] + ". Trying to get other results..."); - } - else { + if (splitted[1].toLowerCase().trim() == "error") { + alert("Some error occurrend running algorithm " + splitted[0] + + ". Trying to get other results..."); + } else { tobemap += message[i] + "|"; } } @@ -634,7 +656,7 @@ getOutputJson = function(message) { parameters += "&tobemap=" + encodeURI(tobemap); var mapperUrl = appRoot + "/nlphub-mapper-servlet?" + parameters; - if(gCubeToken.length > 0) + if (gCubeToken.length > 0) mapperUrl += "&gcube-token=" + gCubeToken; $.ajax({ @@ -655,14 +677,14 @@ getOutputJson = function(message) { hideProgress(); $("#reset-upload").hide(); savedAnnotations = ""; - //publicLink = null; + // publicLink = null; alert("Unexpected Error. Status: " + richiesta.status); } }); } /* - * Show the computation result + * Show the computation result */ showResult = function(data) { $("#ner-ui").hide(); @@ -705,7 +727,7 @@ buildAnnotationList = function(list) { } $("#result-params-div").append("
"); - + var firstRadio = true; for (var i = 0; i < annotations.length; i++) { var cb = ""; cb += "
"; $("#colored-annotations").append(cb); - + } - + $("#colored-annotations :radio").change(function() { if (this.checked) { - checkedAnnotation = this.getAttribute("named"); + checkedAnnotation = this.getAttribute("named"); filterAlgorithmsByAnnotation(checkedAnnotation); rewriteText("#" + this.value); } }); - + showAnnotationsList(); - + $("#colored-annotations :radio").change(); } /* @@ -752,55 +773,63 @@ showAnnotationsList = function() { $('.collapsible').collapsible('open', 1); } -/* +/* * build the list of check-box controls for algorithms */ buildAlgortihmList = function() { $("#algorithm-params-div").empty(); - + for (var i = 0; i < jsonContent.output.result.length; i++) { - var cb = "
"; - cb += "
"; - cb += "
" +findNameByAlgorithmId(jsonContent.output.result[i].algorithm) + "
"; - $("#algorithm-params-div").append(cb); - + if (jsonContent.output.result[i] === undefined) { + console.log("No result for " + i); + } else { + var cb = "
"; + cb += "
"; + cb += "
" + + findNameByAlgorithmId(jsonContent.output.result[i].algorithm) + + "
"; + $("#algorithm-params-div").append(cb); + } } - - $("#algorithm-params-div :checkbox").change(function () { - //buildCheckedAlgs(); + + $("#algorithm-params-div :checkbox").change(function() { + // buildCheckedAlgs(); rewriteText($("#colored-annotations :checked")[0].value); }); } getAlgInformation = function(alg) { var algId = ""; - for(var i in algorithms) { - if(algorithms[i].id.indexOf(alg) > 0) { + for ( var i in algorithms) { + if (algorithms[i].id.indexOf(alg) > 0) { algId = algorithms[i].id; break; } } - - if(algId == "") { + + if (algId == "") { alert("Invalid algorithm identifier."); return; } - - + var parameters = "getInfo=on"; parameters += "&dataminer=" + encodeURIComponent(dataMiner); parameters += "&algId=" + algId; var nlphubUrl = appRoot + "/nlphub-servlet?" + parameters; - if(gCubeToken.length > 0) + if (gCubeToken.length > 0) nlphubUrl += "&gcube-token=" + gCubeToken; $.ajax({ url : nlphubUrl, type : "GET", async : true, success : function(data, stato) { - //alert(data.message); + // alert(data.message); showPopupText(data.message); }, error : function(richiesta, stato, errori) { @@ -809,7 +838,6 @@ getAlgInformation = function(alg) { }); } - showPopupText = function(text) { $(".popup-text-content").empty(); $(".popup-text-content").append("

" + text + "

"); @@ -825,15 +853,15 @@ hidePopupText = function() { * Utility function */ findNameByAlgorithmId = function(id) { - for(i in algorithms) { - if(algorithms[i].id.substr(algorithms[i].id.lastIndexOf(".")+1) == id) + for (i in algorithms) { + if (algorithms[i].id.substr(algorithms[i].id.lastIndexOf(".") + 1) == id) return algorithms[i].name; } return id; } /* - * Utility function + * Utility function */ countSubstringOccurrencies = function(string, substring) { var occurrencies = 0; @@ -849,7 +877,6 @@ countSubstringOccurrencies = function(string, substring) { return occurrencies; } - /* * Utility */ @@ -857,39 +884,43 @@ countSubstringOccurrencies = function(string, substring) { enhanceColor = function(color) { var c = eval("0x" + color); var hi = Math.round(c / 16); - if(hi < 15) { + if (hi < 15) { hi += Math.round((15 - hi) / 1.5); } - if(hi > 15) hi = 15; - return '' + hexLetters[hi] + hexLetters[c%16]; + if (hi > 15) + hi = 15; + return '' + hexLetters[hi] + hexLetters[c % 16]; } /* - * Write the html paragraph

containing the text highlighted on annotation value + * Write the html paragraph

containing the text highlighted on annotation + * value */ rewriteText = function(color) { - if(color.startsWith("#")) + if (color.startsWith("#")) color = color.substring(1); - + $("#result-text-div").empty(); var complemetar = 0xFFFFFF - eval("0x" + color); var complement = complemetar.toString(16); - var R = enhanceColor(complement.substring(0,2)); - var G = enhanceColor(complement.substring(2,4)); + var R = enhanceColor(complement.substring(0, 2)); + var G = enhanceColor(complement.substring(2, 4)); var B = enhanceColor(complement.substring(4)); complement = "#" + R + G + B; showProgress(); $(".hidden-div").show(); window.setTimeout(function() { var indices = getIndices(); - $(".hidden-div").hide(); + $(".hidden-div").hide(); $("#result-header-right").empty(); - $("#result-header-right").append("" + checkedAnnotation + " occurs " + indices.length + " times."); + $("#result-header-right").append( + "" + checkedAnnotation + + " occurs " + indices.length + " times."); - if(indices.length != 0) { + if (indices.length != 0) { var indexedText = ""; - + if ((typeof (indices) == 'undefined') || (indices.length == 0)) { indexedText = resultText; indexedText = indexedText.replace(/\n/g, "
"); @@ -898,7 +929,7 @@ rewriteText = function(color) { $("#result-text-div").append("

" + indexedText + "

"); return; } - + var t = 0; var offset = 0; for (var i = 0; i < indices.length; i++) { @@ -906,7 +937,7 @@ rewriteText = function(color) { var start = index[0]; var end = index[1]; indexedText += resultText.substring(t, start); - + var colored = "" + resultText.substring(start, end) + ""; @@ -915,36 +946,37 @@ rewriteText = function(color) { } if (t < resultText.length) indexedText += resultText.substring(t); - + indexedText = indexedText.replace(/\n/g, "
"); $("#result-text-div").append("

" + indexedText + "

"); - } - else { + } else { $("#result-text-div").append("

" + resultText + "

"); } }, 50); } filterAlgorithmsByAnnotation = function() { - if($("#result-params-div input[type=radio]:checked").length < 1) + if ($("#result-params-div input[type=radio]:checked").length < 1) return; - var annotation = $("#result-params-div input[type=radio]:checked")[0].getAttribute("named"); + var annotation = $("#result-params-div input[type=radio]:checked")[0] + .getAttribute("named"); var algs = $("#algorithm-params-div input[type=checkbox]"); - for(var i=0; i< algs.length; i++) { - var named = $("#algorithm-params-div input[type=checkbox]")[i].getAttribute("named"); - var annList = algIndexedArray[named].annotations; - if(annList.indexOf(annotation) >= 0) { - $($("#algorithm-params-div input[type=checkbox]")[i]).prop("checked", true); - } - else { - $($("#algorithm-params-div input[type=checkbox]")[i]).prop("checked", false); + for (var i = 0; i < algs.length; i++) { + var named = $("#algorithm-params-div input[type=checkbox]")[i] + .getAttribute("named"); + var annList = algIndexedArray[named].annotations; + if (annList.indexOf(annotation) >= 0) { + $($("#algorithm-params-div input[type=checkbox]")[i]).prop( + "checked", true); + } else { + $($("#algorithm-params-div input[type=checkbox]")[i]).prop( + "checked", false); } } } - /* - * Find if the annotation is present in the json + * Find if the annotation is present in the json */ checkAnnotation = function(annotation) { for (var i = 0; i < jsonContent.output.result.length; i++) { @@ -952,7 +984,7 @@ checkAnnotation = function(annotation) { for (var j = 0; j < entities.length; j++) { a = entities[j][annotation]; if (typeof a != 'undefined') { - if(a.length > 0) + if (a.length > 0) return true; } } @@ -970,15 +1002,15 @@ getIndices = function() { for (var i = 0; i < jsonContent.output.result.length; i++) { // filter on algorithm var found = false; - for(var j=0; j "; - if((annotations[i].toLowerCase() == "keyword") || (annotations[i].toLowerCase() == "event")) { + if ((annotations[i].toLowerCase() == "keyword") + || (annotations[i].toLowerCase() == "event")) { annotationElement = " "; + + "\" value=\"" + annotations[i] + + "\"> "; } - + $("#" + rowId).append("" + annotationElement + ""); } } @@ -1098,7 +1131,7 @@ window.onresize = function(event) { $(".ajax-file-upload-abort").on("DOMAttrModified", function(event) { $(".ajax-file-upload-abort").css("display", "none"); if (event.attributeName == "display") { // which attribute you want to watch - // for changes + // for changes $(".ajax-file-upload-abort").css("display", "none"); } }); @@ -1111,13 +1144,12 @@ buildLanguageList = function() { var defaultLanguage = null; for (i in languages) { languages[i] = languages[i].trim(); - languages[i] = languages[i].replace(/\w\S*/g, - function(txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); - if(languages[i] == "English") + languages[i] = languages[i].replace(/\w\S*/g, function(txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); + if (languages[i] == "English") defaultLanguage = languages[i]; - + var opt = ""; if (i > 1) @@ -1125,14 +1157,14 @@ buildLanguageList = function() { + ""; $("#language-select").append(opt); } - - if(defaultLanguage != null) + + if (defaultLanguage != null) $("#language-select").val(defaultLanguage); - + $("#language-select").on("change", function() { selectAnnotationsByLanguage(); }); - + } /* @@ -1160,7 +1192,8 @@ randomRGB = function() { var color = ''; var couple = ''; for (var i = 0; i < 3; i++) { - couple = '' + hexLetters[Math.floor(Math.random() * 10)] + hexLetters[Math.floor(Math.random() * 16)]; + couple = '' + hexLetters[Math.floor(Math.random() * 10)] + + hexLetters[Math.floor(Math.random() * 16)]; color += couple; }