From b413833ca195329d0666c6b0ee6ba96f7839f4f7 Mon Sep 17 00:00:00 2001 From: Stefano Mazzocchi Date: Fri, 7 Oct 2011 23:44:11 +0000 Subject: [PATCH] fixing a bunch of jslint issues git-svn-id: http://google-refine.googlecode.com/svn/trunk@2303 7d457c2a-affb-35e4-300a-418c747d4874 --- build.xml | 2 +- .../dialogs/custom-tabular-exporter-dialog.js | 8 +- .../dialogs/expression-preview-dialog.js | 3 +- .../dialogs/templating-exporter-dialog.js | 4 +- .../modules/core/scripts/facets/list-facet.js | 4 +- .../core/scripts/facets/timerange-facet.js | 2 +- main/webapp/modules/core/scripts/index.js | 6 +- .../core/scripts/index/create-project-ui.js | 4 +- .../controller.js | 2 +- .../file-selection-panel.js | 4 +- .../core/scripts/index/open-project-ui.js | 14 +- .../parser-interfaces/excel-parser-ui.js | 10 +- .../fixed-width-parser-ui.js | 23 ++-- .../index/parser-interfaces/json-parser-ui.js | 14 +- .../parser-interfaces/line-based-parser-ui.js | 19 ++- .../rdf-triples-parser-ui.js | 6 +- .../separator-based-parser-ui.js | 18 ++- .../index/parser-interfaces/xml-parser-ui.js | 8 +- .../modules/core/scripts/preferences.js | 120 +++++++++--------- main/webapp/modules/core/scripts/project.js | 6 +- .../core/scripts/project/browsing-engine.js | 2 +- .../core/scripts/project/extension-bar.js | 2 +- .../core/scripts/project/history-panel.js | 2 +- .../core/scripts/project/process-panel.js | 2 +- .../reconciliation/standard-service-panel.js | 2 +- main/webapp/modules/core/scripts/util/dom.js | 2 +- .../modules/core/scripts/util/encoding.js | 2 +- main/webapp/modules/core/scripts/util/misc.js | 2 +- main/webapp/modules/core/scripts/util/url.js | 3 +- .../views/data-table/column-header-ui.js | 10 +- .../views/data-table/data-table-view.js | 10 +- .../views/data-table/menu-edit-cells.js | 4 +- .../views/data-table/menu-edit-column.js | 25 ++-- .../views/data-table/menu-reconcile.js | 6 +- 34 files changed, 175 insertions(+), 176 deletions(-) diff --git a/build.xml b/build.xml index 64db491de..9c94decab 100644 --- a/build.xml +++ b/build.xml @@ -436,7 +436,7 @@ /> - + diff --git a/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js index 13ba4af17..47c448b25 100644 --- a/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/custom-tabular-exporter-dialog.js @@ -45,7 +45,7 @@ function CustomTabularExporterDialog(options) { this._columnOptionMap = {}; this._createDialog(options); -}; +} CustomTabularExporterDialog.formats = { 'csv': { @@ -77,7 +77,7 @@ CustomTabularExporterDialog.prototype._createDialog = function(options) { this._elmts = DOM.bind(this._dialog); this._level = DialogSystem.showDialog(this._dialog); - if (CustomTabularExporterDialog.uploadTargets.length == 0) { + if (CustomTabularExporterDialog.uploadTargets.length === 0) { this._elmts.uploadTabHeader.remove(); this._elmts.uploadTabBody.remove(); } @@ -208,7 +208,7 @@ CustomTabularExporterDialog.prototype._configureUIFromOptionCode = function(opti this._elmts.outputColumnHeadersCheckbox.attr('checked', (options.outputColumnHeaders) ? 'checked' : ''); this._elmts.outputBlankRowsCheckbox.attr('checked', (options.outputBlankRows) ? 'checked' : ''); - if (options.columns != null) { + if (options.columns !== null) { var self = this; this._elmts.columnList.find('.custom-tabular-exporter-dialog-column input[type="checkbox"]').attr('checked', ''); $.each(options.columns, function() { @@ -371,7 +371,7 @@ CustomTabularExporterDialog.prototype._getOptionCode = function() { }; CustomTabularExporterDialog.prototype._upload = function() { - var id = this._dialog.find('input[name="custom-tabular-exporter-upload-format"]:checked').val() + var id = this._dialog.find('input[name="custom-tabular-exporter-upload-format"]:checked').val(); for (var i = 0; i < CustomTabularExporterDialog.uploadTargets.length; i++) { var target = CustomTabularExporterDialog.uploadTargets[i]; if (id == target.id) { diff --git a/main/webapp/modules/core/scripts/dialogs/expression-preview-dialog.js b/main/webapp/modules/core/scripts/dialogs/expression-preview-dialog.js index 5a1287d9f..51516249a 100644 --- a/main/webapp/modules/core/scripts/dialogs/expression-preview-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/expression-preview-dialog.js @@ -373,7 +373,8 @@ ExpressionPreviewDialog.Widget.prototype._renderStarredExpressions = function(da var entry = data.expressions[i]; renderEntry(entry); } -} +}; + ExpressionPreviewDialog.Widget.prototype._scheduleUpdate = function() { if (this._timerID !== null) { window.clearTimeout(this._timerID); diff --git a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js index 6a0c21430..1727bdbbc 100644 --- a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js @@ -63,7 +63,7 @@ TemplatingExporterDialog.prototype._getSavedTemplate = function(f) { "/command/core/get-preference?" + $.param({ project: theProject.id, name: "exporters.templating.template" }), null, function(data) { - if (data.value != null) { + if (data.value !== null) { f(JSON.parse(data.value)); } else { f(null); @@ -147,7 +147,7 @@ TemplatingExporterDialog.prototype._export = function() { .attr("name", name) .attr("value", value) .appendTo(form); - } + }; appendField("engine", JSON.stringify(ui.browsingEngine.getJSON())); appendField("project", theProject.id); diff --git a/main/webapp/modules/core/scripts/facets/list-facet.js b/main/webapp/modules/core/scripts/facets/list-facet.js index b9c285a81..61b0e1f0f 100644 --- a/main/webapp/modules/core/scripts/facets/list-facet.js +++ b/main/webapp/modules/core/scripts/facets/list-facet.js @@ -491,7 +491,7 @@ ListFacet.prototype._getMetaExpression = function() { JSON.stringify(this._config.expression), JSON.stringify(this._config.columnName) ].join(', ') + ')'; -} +}; ListFacet.prototype._doEdit = function() { new ClusteringDialog(this._config.columnName, this._config.expression); @@ -697,7 +697,7 @@ ListFacet.prototype._setChoiceCountLimit = function(choiceCount) { var limit = Math.ceil(choiceCount / 1000) * 1000; var s = window.prompt('Set the maximum number of choices shown in each text facet (too many will slow down the application)', limit); if (s) { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { var self = this; diff --git a/main/webapp/modules/core/scripts/facets/timerange-facet.js b/main/webapp/modules/core/scripts/facets/timerange-facet.js index e59706ca1..07fcbbe49 100644 --- a/main/webapp/modules/core/scripts/facets/timerange-facet.js +++ b/main/webapp/modules/core/scripts/facets/timerange-facet.js @@ -274,7 +274,7 @@ TimeRangeFacet.prototype.steps = [ 1000*31556952, // year (average Gregorian year) 1000*31556952*10, // decade 1000*31556952*100, // century - 1000*31556952*1000, // millennium + 1000*31556952*1000 // millennium ]; TimeRangeFacet.prototype._setRangeIndicators = function() { diff --git a/main/webapp/modules/core/scripts/index.js b/main/webapp/modules/core/scripts/index.js index ca0d5f0ad..7a407943e 100644 --- a/main/webapp/modules/core/scripts/index.js +++ b/main/webapp/modules/core/scripts/index.js @@ -45,7 +45,7 @@ Refine.selectActionArea = function(id) { var actionArea = Refine.actionAreas[i]; if (id == actionArea.id) { actionArea.tabElmt.addClass('selected'); - actionArea.bodyElmt.css('visibility', 'visible').css('z-index', '55');; + actionArea.bodyElmt.css('visibility', 'visible').css('z-index', '55'); } } }; @@ -86,10 +86,10 @@ $(function() { if ("releases" in window) { if (isThereNewRelease()) { var container = $('
') - .appendTo(document.body) + .appendTo(document.body); var notification = $('
') .text('New version! ') - .appendTo(container) + .appendTo(container); $('') .addClass('notification-action') .attr("href", releases.homepage) diff --git a/main/webapp/modules/core/scripts/index/create-project-ui.js b/main/webapp/modules/core/scripts/index/create-project-ui.js index 4d517734c..b448f5a4f 100644 --- a/main/webapp/modules/core/scripts/index/create-project-ui.js +++ b/main/webapp/modules/core/scripts/index/create-project-ui.js @@ -248,7 +248,9 @@ Refine.CreateProjectUI.prototype.showImportJobError = function(message, stack) { Refine.CreateProjectUI.composeErrorMessage = function(job) { var messages = []; - $.each(job.config.errors, function() { messages.push(this.message) }); + $.each(job.config.errors, function() { + messages.push(this.message); + }); return messages.join('\n'); }; diff --git a/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js b/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js index b6231fac5..3a1aa6149 100644 --- a/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js +++ b/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js @@ -256,7 +256,7 @@ Refine.DefaultImportingController.prototype.getPreviewData = function(callback, Refine.DefaultImportingController.prototype._createProject = function() { if ((this._formatParserUI) && this._formatParserUI.confirmReadyToCreateProject()) { var projectName = $.trim(this._parsingPanelElmts.projectNameInput[0].value); - if (projectName.length == 0) { + if (projectName.length === 0) { window.alert("Please name the project."); this._parsingPanelElmts.projectNameInput.focus(); return; diff --git a/main/webapp/modules/core/scripts/index/default-importing-controller/file-selection-panel.js b/main/webapp/modules/core/scripts/index/default-importing-controller/file-selection-panel.js index a50d50bd8..0b8fe5a37 100644 --- a/main/webapp/modules/core/scripts/index/default-importing-controller/file-selection-panel.js +++ b/main/webapp/modules/core/scripts/index/default-importing-controller/file-selection-panel.js @@ -121,7 +121,7 @@ Refine.DefaultImportingController.prototype._renderFileSelectionPanelFileTable = var renderFile = function(fileRecord, index) { var id = "import-file-selection-" + Math.round(Math.random() * 1000000); var tr = fileTable.insertRow(fileTable.rows.length); - $(tr).addClass(index % 2 == 0 ? 'even' : 'odd'); + $(tr).addClass((index % 2 === 0) ? 'even' : 'odd'); var createLabeledCell = function(className) { var td = $('').appendTo(tr); @@ -308,7 +308,7 @@ Refine.DefaultImportingController.prototype._updateFileSelectionSummary = functi }; Refine.DefaultImportingController.prototype._commitFileSelection = function() { - if (this._job.config.fileSelection.length == 0) { + if (this._job.config.fileSelection.length === 0) { alert("Please select at least one file."); return; } diff --git a/main/webapp/modules/core/scripts/index/open-project-ui.js b/main/webapp/modules/core/scripts/index/open-project-ui.js index 640b39acf..598e84db2 100644 --- a/main/webapp/modules/core/scripts/index/open-project-ui.js +++ b/main/webapp/modules/core/scripts/index/open-project-ui.js @@ -40,10 +40,10 @@ Refine.OpenProjectUI = function(elmt) { this._elmts = DOM.bind(elmt); $("#project-file-input").change(function() { - if ($("#project-name-input")[0].value.length == 0) { + if ($("#project-name-input")[0].value.length === 0) { var fileName = this.files[0].fileName; if (fileName) { - $("#project-name-input")[0].value = fileName.replace(/\.\w+/, "").replace(/[_-]/g, " "); + $("#project-name-input")[0].value = fileName.replace(/\.\w+/, "").replace(/[_\-]/g, " "); } $("#project-name-input").focus().select(); } @@ -54,7 +54,7 @@ Refine.OpenProjectUI = function(elmt) { }); $("#upload-file-button").click(function(evt) { - return self._onClickUploadFileButton(evt) + return self._onClickUploadFileButton(evt); }); $('#projects-workspace-open').click(function() { @@ -83,7 +83,7 @@ Refine.OpenProjectUI.prototype.resize = function() { this._elmts.workspaceControls .css("bottom", "0px") - .css("width", (width - DOM.getHPaddings(this._elmts.workspaceControls)) + "px") + .css("width", (width - DOM.getHPaddings(this._elmts.workspaceControls)) + "px"); }; Refine.OpenProjectUI.prototype._fetchProjects = function() { @@ -163,12 +163,12 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) { .css("visibility", "hidden") .click(function() { var name = window.prompt("New project name:", project.name); - if (name == null) { + if (name === null) { return; } name = $.trim(name); - if (project.name == name || name.length == 0) { + if (project.name == name || name.length === 0) { return; } @@ -181,7 +181,7 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) { if (data && typeof data.code != 'undefined' && data.code == "ok") { nameLink.text(name); } else { - alert("Failed to rename project: " + data.message) + alert("Failed to rename project: " + data.message); } } }); diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/excel-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/excel-parser-ui.js index 1097acf7e..18709a49d 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/excel-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/excel-parser-ui.js @@ -47,10 +47,10 @@ Refine.ExcelParserUI = function(controller, jobID, job, format, config, this._initialize(); this._updatePreview(); }; -Refine.DefaultImportingController.parserUIs["ExcelParserUI"] = Refine.ExcelParserUI; +Refine.DefaultImportingController.parserUIs.ExcelParserUI = Refine.ExcelParserUI; Refine.ExcelParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -68,7 +68,7 @@ Refine.ExcelParserUI.prototype.getOptions = function() { var parseIntDefault = function(s, def) { try { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { return n; } @@ -80,7 +80,7 @@ Refine.ExcelParserUI.prototype.getOptions = function() { this._optionContainerElmts.sheetRecordContainer.find('input').each(function() { if (this.checked) { - options.sheets.push(parseInt(this.getAttribute('index'))); + options.sheets.push(parseInt(this.getAttribute('index'),10)); } }); @@ -178,7 +178,7 @@ Refine.ExcelParserUI.prototype._initialize = function() { }; Refine.ExcelParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js index 2bbd4afce..51a61352d 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/fixed-width-parser-ui.js @@ -48,10 +48,10 @@ Refine.FixedWidthParserUI = function(controller, jobID, job, format, config, this._initialize(); this.updatePreview(); }; -Refine.DefaultImportingController.parserUIs["FixedWidthParserUI"] = Refine.FixedWidthParserUI; +Refine.DefaultImportingController.parserUIs.FixedWidthParserUI = Refine.FixedWidthParserUI; Refine.FixedWidthParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -72,18 +72,15 @@ Refine.FixedWidthParserUI.prototype.getOptions = function() { options.columnNames = columnNames; } - switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) { - case 'new-line': + if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") { options.lineSeparator = "\n"; - break; - default: - options.lineSeparator = String.decodeSeparator( - this._optionContainerElmts.rowSeparatorInput[0].value); + } else { + options.lineSeparator = String.decodeSeparator(this._optionContainerElmts.rowSeparatorInput[0].value); } var parseIntDefault = function(s, def) { try { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { return n; } @@ -191,7 +188,7 @@ Refine.FixedWidthParserUI.prototype._getColumnWidths = function() { var newColumnWidths = []; var a = $.trim(this._optionContainerElmts.columnWidthsInput[0].value).replace(/,\s+/g, ',').split(','); for (var i = 0; i < a.length; i++) { - var n = parseInt(a[i]); + var n = parseInt(a[i],10); if (!isNaN(n)) { newColumnWidths.push(n); } @@ -200,7 +197,7 @@ Refine.FixedWidthParserUI.prototype._getColumnWidths = function() { }; Refine.FixedWidthParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -266,7 +263,7 @@ Refine.FixedWidthPreviewTable.prototype._render = function() { var addCell = function(tr) { var index = tr.cells.length; var td = tr.insertCell(index); - td.className = (index % 2 == 0) ? 'even' : 'odd'; + td.className = (index % 2 === 0) ? 'even' : 'odd'; return td; }; @@ -373,7 +370,7 @@ Refine.FixedWidthPreviewTable.prototype._render = function() { var newColumnWidths = []; for (var i = 0; i < columnCharIndexes.length; i++) { var charIndex = columnCharIndexes[i]; - var columnWidth = (i == 0) ? charIndex : (charIndex - columnCharIndexes[i - 1]); + var columnWidth = (i === 0) ? charIndex : (charIndex - columnCharIndexes[i - 1]); if (columnWidth > 0) { newColumnWidths.push(columnWidth); } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/json-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/json-parser-ui.js index 7cacb776a..c5d23f777 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/json-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/json-parser-ui.js @@ -48,10 +48,10 @@ Refine.JsonParserUI = function(controller, jobID, job, format, config, this._initialize(); this._showPickRecordNodesUI(); }; -Refine.DefaultImportingController.parserUIs["JsonParserUI"] = Refine.JsonParserUI; +Refine.DefaultImportingController.parserUIs.JsonParserUI = Refine.JsonParserUI; Refine.JsonParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -72,7 +72,7 @@ Refine.JsonParserUI.prototype.getOptions = function() { var parseIntDefault = function(s, def) { try { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { return n; } @@ -162,7 +162,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() { var elementNode = null; for (var i = 0; i < a.length; i++) { - if (elementNode != null) { + if (elementNode !== null) { $('').addClass('punctuation').text(',').appendTo(elementNode); } elementNode = $('
').addClass('node').addClass('indented').appendTo(container); @@ -178,7 +178,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() { var elementNode = null; for (var key in o) { if (o.hasOwnProperty(key)) { - if (elementNode != null) { + if (elementNode !== null) { $('').addClass('punctuation').text(',').appendTo(elementNode); } elementNode = $('
').addClass('node').addClass('indented').appendTo(container); @@ -197,7 +197,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() { registerEvents(container, parentPath); }; var renderNode = function(node, container, parentPath) { - if (node == null) { + if (node === null) { $('').addClass('literal').text('null').appendTo(container); } else { if ($.isPlainObject(node)) { @@ -214,7 +214,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() { }; Refine.JsonParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js index d7d8c2a77..861b804ee 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/line-based-parser-ui.js @@ -48,14 +48,14 @@ Refine.LineBasedParserUI = function(controller, jobID, job, format, config, this._initialize(); this._updatePreview(); }; -Refine.DefaultImportingController.parserUIs["LineBasedParserUI"] = Refine.LineBasedParserUI; +Refine.DefaultImportingController.parserUIs.LineBasedParserUI = Refine.LineBasedParserUI; Refine.LineBasedParserUI.prototype.confirmReadyToCreateProject = function() { return true; }; Refine.LineBasedParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -69,7 +69,7 @@ Refine.LineBasedParserUI.prototype.getOptions = function() { var parseIntDefault = function(s, def) { try { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { return n; } @@ -80,13 +80,10 @@ Refine.LineBasedParserUI.prototype.getOptions = function() { }; options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1); - switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) { - case 'new-line': - options.lineSeparator = "\n"; - break; - default: - options.lineSeparator = String.decodeSeparator( - this._optionContainerElmts.rowSeparatorInput[0].value); + if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") { + options.lineSeparator = "\n"; + } else { + options.lineSeparator = String.decodeSeparator(this._optionContainerElmts.rowSeparatorInput[0].value); } if (this._optionContainerElmts.ignoreCheckbox[0].checked) { @@ -166,7 +163,7 @@ Refine.LineBasedParserUI.prototype._initialize = function() { }; Refine.LineBasedParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/rdf-triples-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/rdf-triples-parser-ui.js index 36966bb20..b0db21077 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/rdf-triples-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/rdf-triples-parser-ui.js @@ -48,14 +48,14 @@ Refine.RdfTriplesParserUI = function(controller, jobID, job, format, config, this._initialize(); this._updatePreview(); }; -Refine.DefaultImportingController.parserUIs["RdfTriplesParserUI"] = Refine.RdfTriplesParserUI; +Refine.DefaultImportingController.parserUIs.RdfTriplesParserUI = Refine.RdfTriplesParserUI; Refine.RdfTriplesParserUI.prototype.confirmReadyToCreateProject = function() { return true; }; Refine.RdfTriplesParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -92,7 +92,7 @@ Refine.RdfTriplesParserUI.prototype._initialize = function() { }; Refine.RdfTriplesParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js index 36d228b5c..f249dea0a 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/separator-based-parser-ui.js @@ -47,10 +47,10 @@ Refine.SeparatorBasedParserUI = function(controller, jobID, job, format, config, this._initialize(); this._updatePreview(); }; -Refine.DefaultImportingController.parserUIs["SeparatorBasedParserUI"] = Refine.SeparatorBasedParserUI; +Refine.DefaultImportingController.parserUIs.SeparatorBasedParserUI = Refine.SeparatorBasedParserUI; Refine.SeparatorBasedParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -65,14 +65,12 @@ Refine.SeparatorBasedParserUI.prototype.getOptions = function() { encoding: $.trim(this._optionContainerElmts.encodingInput[0].value) }; - switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) { - case 'new-line': + if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") { options.lineSeparator = "\n"; - break; - default: - options.lineSeparator = String.decodeSeparator( - this._optionContainerElmts.rowSeparatorInput[0].value); + } else { + options.lineSeparator = String.decodeSeparator(this._optionContainerElmts.rowSeparatorInput[0].value); } + switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) { case 'comma': options.separator = ","; @@ -87,7 +85,7 @@ Refine.SeparatorBasedParserUI.prototype.getOptions = function() { var parseIntDefault = function(s, def) { try { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { return n; } @@ -198,7 +196,7 @@ Refine.SeparatorBasedParserUI.prototype._initialize = function() { }; Refine.SeparatorBasedParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } diff --git a/main/webapp/modules/core/scripts/index/parser-interfaces/xml-parser-ui.js b/main/webapp/modules/core/scripts/index/parser-interfaces/xml-parser-ui.js index 543229860..46015bebc 100644 --- a/main/webapp/modules/core/scripts/index/parser-interfaces/xml-parser-ui.js +++ b/main/webapp/modules/core/scripts/index/parser-interfaces/xml-parser-ui.js @@ -48,10 +48,10 @@ Refine.XmlParserUI = function(controller, jobID, job, format, config, this._initialize(); this._showPickRecordElementsUI(); }; -Refine.DefaultImportingController.parserUIs["XmlParserUI"] = Refine.XmlParserUI; +Refine.DefaultImportingController.parserUIs.XmlParserUI = Refine.XmlParserUI; Refine.XmlParserUI.prototype.dispose = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } @@ -71,7 +71,7 @@ Refine.XmlParserUI.prototype.getOptions = function() { }; var parseIntDefault = function(s, def) { try { - var n = parseInt(s); + var n = parseInt(s,10); if (!isNaN(n)) { return n; } @@ -210,7 +210,7 @@ Refine.XmlParserUI.prototype._showPickRecordElementsUI = function() { }; Refine.XmlParserUI.prototype._scheduleUpdatePreview = function() { - if (this._timerID != null) { + if (this._timerID !== null) { window.clearTimeout(this._timerID); this._timerID = null; } diff --git a/main/webapp/modules/core/scripts/preferences.js b/main/webapp/modules/core/scripts/preferences.js index d797e2565..c26301e8d 100644 --- a/main/webapp/modules/core/scripts/preferences.js +++ b/main/webapp/modules/core/scripts/preferences.js @@ -33,63 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. var preferenceUIs = []; -function onLoad() { - $.post( - "/command/core/get-all-preferences", - null, - populatePreferences, - "json" - ); -} - -$(onLoad); - -function populatePreferences(prefs) { - var body = $("#body-info").empty(); - - $('

').text("Preferences").appendTo(body); - - var table = $('') - .addClass("list-table") - .addClass("preferences") - .html('') - .appendTo(body)[0]; - - for (var k in prefs) { - var tr = table.insertRow(table.rows.length); - preferenceUIs.push(new PreferenceUI(tr, k, prefs[k])); - } - - var trLast = table.insertRow(table.rows.length); - var tdLast0 = trLast.insertCell(0); - trLast.insertCell(1); - trLast.insertCell(2); - $('
KeyValue
') + .addClass("list-table") + .addClass("preferences") + .html('') + .appendTo(body)[0]; + + for (var k in prefs) { + var tr = table.insertRow(table.rows.length); + preferenceUIs.push(new PreferenceUI(tr, k, prefs[k])); + } + + var trLast = table.insertRow(table.rows.length); + var tdLast0 = trLast.insertCell(0); + trLast.insertCell(1); + trLast.insertCell(2); + $('
KeyValue
').html('').appendTo(container)[0]; $.each(Refine.encodings, function() { - if (filter == null || this.code in filter) { + if (filter === null || this.code in filter) { renderEncoding(table, this); } }); diff --git a/main/webapp/modules/core/scripts/util/misc.js b/main/webapp/modules/core/scripts/util/misc.js index 2e1f2b84b..fca1d5f1a 100644 --- a/main/webapp/modules/core/scripts/util/misc.js +++ b/main/webapp/modules/core/scripts/util/misc.js @@ -81,4 +81,4 @@ function formatRelativeDate(d) { var diff = Math.floor(today.getYear() - d.getYear()); return (diff == 1) ? "a year ago" : diff + " years ago"; } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/main/webapp/modules/core/scripts/util/url.js b/main/webapp/modules/core/scripts/util/url.js index 5b929380e..998fe849c 100644 --- a/main/webapp/modules/core/scripts/util/url.js +++ b/main/webapp/modules/core/scripts/util/url.js @@ -95,8 +95,7 @@ URL.looksLikeUrl = function(s) { if (sep >= URL.minSchemeLength) { var scheme = s.substring(0, sep).toLowerCase(); if (scheme in URL.schemes) { - return URL.schemes[scheme] == 0 || - s.substring(sep + 1, sep + 3) == "//"; + return (URL.schemes[scheme] === 0) || (s.substring(sep + 1, sep + 3) == "//"); } } } diff --git a/main/webapp/modules/core/scripts/views/data-table/column-header-ui.js b/main/webapp/modules/core/scripts/views/data-table/column-header-ui.js index c41bb83ec..4f091e915 100644 --- a/main/webapp/modules/core/scripts/views/data-table/column-header-ui.js +++ b/main/webapp/modules/core/scripts/views/data-table/column-header-ui.js @@ -124,12 +124,12 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) { }, {}, ( - this._dataTableView._getSortingCriterionForColumn(this._column.name) == null ? + this._dataTableView._getSortingCriterionForColumn(this._column.name) === null ? { id: "core/sort", "label": "Sort...", "click": function() { - self._showSortingCriterion(null, self._dataTableView._getSortingCriteriaCount() > 0) + self._showSortingCriterion(null, self._dataTableView._getSortingCriteriaCount() > 0); } } : { @@ -204,18 +204,18 @@ DataTableColumnHeaderUI.prototype.createSortingMenu = function() { var self = this; var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name); var criteriaCount = this._dataTableView._getSortingCriteriaCount(); - var hasOtherCriteria = criterion == null ? (criteriaCount > 0) : criteriaCount > 1; + var hasOtherCriteria = (criterion === null) ? (criteriaCount > 0) : criteriaCount > 1; var items = [ { "label": "Sort...", "click": function() { - self._showSortingCriterion(criterion, hasOtherCriteria) + self._showSortingCriterion(criterion, hasOtherCriteria); } } ]; - if (criterion != null) { + if (criterion !== null) { items.push({ "label": "Reverse", "click": function() { diff --git a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js index c36769eaa..3398068fd 100644 --- a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js +++ b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js @@ -426,13 +426,13 @@ DataTableView.prototype._renderDataTables = function(table, headerTable) { DataTableView.prototype._adjustDataTables = function() { var dataTable = this._div.find('.data-table'); var headerTable = this._div.find('.data-header-table'); - if (dataTable.length == 0 || headerTable.length == 0) { + if (dataTable.length === 0 || headerTable.length === 0) { return; } dataTable = dataTable[0]; headerTable = headerTable[0]; - if (dataTable.rows.length == 0) { + if (dataTable.rows.length === 0) { return; } @@ -726,14 +726,14 @@ DataTableView.prototype._createSortingMenu = function(elmt) { } } return null; - } + }; var createSubmenu = function(criterion) { var columnHeaderUI = getColumnHeaderUI(criterion.column); - if (columnHeaderUI != null) { + if (columnHeaderUI !== null) { items.push({ "label" : "By " + criterion.column, "submenu" : columnHeaderUI.createSortingMenu() - }) + }); } }; for (var i = 0; i < this._sorting.criteria.length; i++) { diff --git a/main/webapp/modules/core/scripts/views/data-table/menu-edit-cells.js b/main/webapp/modules/core/scripts/views/data-table/menu-edit-cells.js index f94ea933f..042922232 100644 --- a/main/webapp/modules/core/scripts/views/data-table/menu-edit-cells.js +++ b/main/webapp/modules/core/scripts/views/data-table/menu-edit-cells.js @@ -306,9 +306,9 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { var doTransposeRowsIntoColumns = function() { var rowCount = window.prompt("How many rows to transpose?", "2"); - if (rowCount != null) { + if (rowCount !== null) { try { - rowCount = parseInt(rowCount); + rowCount = parseInt(rowCount,10); } catch (e) { // ignore } diff --git a/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js b/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js index d6feb186d..5cc67c84b 100644 --- a/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js +++ b/main/webapp/modules/core/scripts/views/data-table/menu-edit-column.js @@ -213,20 +213,25 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { var s = "[" + elmts.lengthsTextarea[0].value + "]"; try { var a = JSON.parse(s); + + var lengths = []; + $.each(a, function(i,n) { + if (typeof n == "number") { + lengths.push(n); + } + }); + + if (lengths.length === 0) { + alert("No field length is specified."); + return; + } + + config.fieldLengths = JSON.stringify(lengths); + } catch (e) { alert("The given field lengths are not properly formatted."); return; } - - var lengths = []; - $.each(a, function(i,n) { if (typeof n == "number") lengths.push(n); }); - - if (lengths.length === 0) { - alert("No field length is specified."); - return; - } - - config.fieldLengths = JSON.stringify(lengths); } Refine.postCoreProcess( diff --git a/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js b/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js index bd84bd87a..3b6c025c2 100644 --- a/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js +++ b/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js @@ -52,7 +52,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { null, { cellsChanged: true, columnStatsChanged: true } ); - } + }; var doReconMatchBestCandidates = function() { Refine.postCoreProcess( @@ -161,9 +161,9 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { } }); - if (config.toColumnName.length == 0) { + if (config.toColumnName.length === 0) { alert("Please select some other column to copy to."); - } else if (config.judgment.length == 0) { + } else if (config.judgment.length === 0) { alert("Please select at least one kind of judgment to copy."); } else { Refine.postCoreProcess(
EncodingAliases