fixing a bunch of jslint issues

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2303 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2011-10-07 23:44:11 +00:00
parent fffd24d64b
commit b413833ca1
34 changed files with 175 additions and 176 deletions

View File

@ -436,7 +436,7 @@
/> />
<jslint> <jslint>
<formatter type="plain" destfile="${reports.dir}/jslint.txt" /> <formatter type="plain" destfile="${reports.dir}/jslint.txt" />
<fileset dir="${webapp.dir}/scripts"> <fileset dir="${webapp.dir}/modules/core/scripts">
<include name="**/*.js" /> <include name="**/*.js" />
</fileset> </fileset>
</jslint> </jslint>

View File

@ -45,7 +45,7 @@ function CustomTabularExporterDialog(options) {
this._columnOptionMap = {}; this._columnOptionMap = {};
this._createDialog(options); this._createDialog(options);
}; }
CustomTabularExporterDialog.formats = { CustomTabularExporterDialog.formats = {
'csv': { 'csv': {
@ -77,7 +77,7 @@ CustomTabularExporterDialog.prototype._createDialog = function(options) {
this._elmts = DOM.bind(this._dialog); this._elmts = DOM.bind(this._dialog);
this._level = DialogSystem.showDialog(this._dialog); this._level = DialogSystem.showDialog(this._dialog);
if (CustomTabularExporterDialog.uploadTargets.length == 0) { if (CustomTabularExporterDialog.uploadTargets.length === 0) {
this._elmts.uploadTabHeader.remove(); this._elmts.uploadTabHeader.remove();
this._elmts.uploadTabBody.remove(); this._elmts.uploadTabBody.remove();
} }
@ -208,7 +208,7 @@ CustomTabularExporterDialog.prototype._configureUIFromOptionCode = function(opti
this._elmts.outputColumnHeadersCheckbox.attr('checked', (options.outputColumnHeaders) ? 'checked' : ''); this._elmts.outputColumnHeadersCheckbox.attr('checked', (options.outputColumnHeaders) ? 'checked' : '');
this._elmts.outputBlankRowsCheckbox.attr('checked', (options.outputBlankRows) ? 'checked' : ''); this._elmts.outputBlankRowsCheckbox.attr('checked', (options.outputBlankRows) ? 'checked' : '');
if (options.columns != null) { if (options.columns !== null) {
var self = this; var self = this;
this._elmts.columnList.find('.custom-tabular-exporter-dialog-column input[type="checkbox"]').attr('checked', ''); this._elmts.columnList.find('.custom-tabular-exporter-dialog-column input[type="checkbox"]').attr('checked', '');
$.each(options.columns, function() { $.each(options.columns, function() {
@ -371,7 +371,7 @@ CustomTabularExporterDialog.prototype._getOptionCode = function() {
}; };
CustomTabularExporterDialog.prototype._upload = 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++) { for (var i = 0; i < CustomTabularExporterDialog.uploadTargets.length; i++) {
var target = CustomTabularExporterDialog.uploadTargets[i]; var target = CustomTabularExporterDialog.uploadTargets[i];
if (id == target.id) { if (id == target.id) {

View File

@ -373,7 +373,8 @@ ExpressionPreviewDialog.Widget.prototype._renderStarredExpressions = function(da
var entry = data.expressions[i]; var entry = data.expressions[i];
renderEntry(entry); renderEntry(entry);
} }
} };
ExpressionPreviewDialog.Widget.prototype._scheduleUpdate = function() { ExpressionPreviewDialog.Widget.prototype._scheduleUpdate = function() {
if (this._timerID !== null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);

View File

@ -63,7 +63,7 @@ TemplatingExporterDialog.prototype._getSavedTemplate = function(f) {
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "exporters.templating.template" }), "/command/core/get-preference?" + $.param({ project: theProject.id, name: "exporters.templating.template" }),
null, null,
function(data) { function(data) {
if (data.value != null) { if (data.value !== null) {
f(JSON.parse(data.value)); f(JSON.parse(data.value));
} else { } else {
f(null); f(null);
@ -147,7 +147,7 @@ TemplatingExporterDialog.prototype._export = function() {
.attr("name", name) .attr("name", name)
.attr("value", value) .attr("value", value)
.appendTo(form); .appendTo(form);
} };
appendField("engine", JSON.stringify(ui.browsingEngine.getJSON())); appendField("engine", JSON.stringify(ui.browsingEngine.getJSON()));
appendField("project", theProject.id); appendField("project", theProject.id);

View File

@ -491,7 +491,7 @@ ListFacet.prototype._getMetaExpression = function() {
JSON.stringify(this._config.expression), JSON.stringify(this._config.expression),
JSON.stringify(this._config.columnName) JSON.stringify(this._config.columnName)
].join(', ') + ')'; ].join(', ') + ')';
} };
ListFacet.prototype._doEdit = function() { ListFacet.prototype._doEdit = function() {
new ClusteringDialog(this._config.columnName, this._config.expression); 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 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); 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) { if (s) {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
var self = this; var self = this;

View File

@ -274,7 +274,7 @@ TimeRangeFacet.prototype.steps = [
1000*31556952, // year (average Gregorian year) 1000*31556952, // year (average Gregorian year)
1000*31556952*10, // decade 1000*31556952*10, // decade
1000*31556952*100, // century 1000*31556952*100, // century
1000*31556952*1000, // millennium 1000*31556952*1000 // millennium
]; ];
TimeRangeFacet.prototype._setRangeIndicators = function() { TimeRangeFacet.prototype._setRangeIndicators = function() {

View File

@ -45,7 +45,7 @@ Refine.selectActionArea = function(id) {
var actionArea = Refine.actionAreas[i]; var actionArea = Refine.actionAreas[i];
if (id == actionArea.id) { if (id == actionArea.id) {
actionArea.tabElmt.addClass('selected'); 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 ("releases" in window) {
if (isThereNewRelease()) { if (isThereNewRelease()) {
var container = $('<div id="notification-container">') var container = $('<div id="notification-container">')
.appendTo(document.body) .appendTo(document.body);
var notification = $('<div id="notification">') var notification = $('<div id="notification">')
.text('New version! ') .text('New version! ')
.appendTo(container) .appendTo(container);
$('<a>') $('<a>')
.addClass('notification-action') .addClass('notification-action')
.attr("href", releases.homepage) .attr("href", releases.homepage)

View File

@ -248,7 +248,9 @@ Refine.CreateProjectUI.prototype.showImportJobError = function(message, stack) {
Refine.CreateProjectUI.composeErrorMessage = function(job) { Refine.CreateProjectUI.composeErrorMessage = function(job) {
var messages = []; var messages = [];
$.each(job.config.errors, function() { messages.push(this.message) }); $.each(job.config.errors, function() {
messages.push(this.message);
});
return messages.join('\n'); return messages.join('\n');
}; };

View File

@ -256,7 +256,7 @@ Refine.DefaultImportingController.prototype.getPreviewData = function(callback,
Refine.DefaultImportingController.prototype._createProject = function() { Refine.DefaultImportingController.prototype._createProject = function() {
if ((this._formatParserUI) && this._formatParserUI.confirmReadyToCreateProject()) { if ((this._formatParserUI) && this._formatParserUI.confirmReadyToCreateProject()) {
var projectName = $.trim(this._parsingPanelElmts.projectNameInput[0].value); var projectName = $.trim(this._parsingPanelElmts.projectNameInput[0].value);
if (projectName.length == 0) { if (projectName.length === 0) {
window.alert("Please name the project."); window.alert("Please name the project.");
this._parsingPanelElmts.projectNameInput.focus(); this._parsingPanelElmts.projectNameInput.focus();
return; return;

View File

@ -121,7 +121,7 @@ Refine.DefaultImportingController.prototype._renderFileSelectionPanelFileTable =
var renderFile = function(fileRecord, index) { var renderFile = function(fileRecord, index) {
var id = "import-file-selection-" + Math.round(Math.random() * 1000000); var id = "import-file-selection-" + Math.round(Math.random() * 1000000);
var tr = fileTable.insertRow(fileTable.rows.length); 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 createLabeledCell = function(className) {
var td = $('<td>').appendTo(tr); var td = $('<td>').appendTo(tr);
@ -308,7 +308,7 @@ Refine.DefaultImportingController.prototype._updateFileSelectionSummary = functi
}; };
Refine.DefaultImportingController.prototype._commitFileSelection = function() { 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."); alert("Please select at least one file.");
return; return;
} }

View File

@ -40,10 +40,10 @@ Refine.OpenProjectUI = function(elmt) {
this._elmts = DOM.bind(elmt); this._elmts = DOM.bind(elmt);
$("#project-file-input").change(function() { $("#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; var fileName = this.files[0].fileName;
if (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(); $("#project-name-input").focus().select();
} }
@ -54,7 +54,7 @@ Refine.OpenProjectUI = function(elmt) {
}); });
$("#upload-file-button").click(function(evt) { $("#upload-file-button").click(function(evt) {
return self._onClickUploadFileButton(evt) return self._onClickUploadFileButton(evt);
}); });
$('#projects-workspace-open').click(function() { $('#projects-workspace-open').click(function() {
@ -83,7 +83,7 @@ Refine.OpenProjectUI.prototype.resize = function() {
this._elmts.workspaceControls this._elmts.workspaceControls
.css("bottom", "0px") .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() { Refine.OpenProjectUI.prototype._fetchProjects = function() {
@ -163,12 +163,12 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
.css("visibility", "hidden") .css("visibility", "hidden")
.click(function() { .click(function() {
var name = window.prompt("New project name:", project.name); var name = window.prompt("New project name:", project.name);
if (name == null) { if (name === null) {
return; return;
} }
name = $.trim(name); name = $.trim(name);
if (project.name == name || name.length == 0) { if (project.name == name || name.length === 0) {
return; return;
} }
@ -181,7 +181,7 @@ Refine.OpenProjectUI.prototype._renderProjects = function(data) {
if (data && typeof data.code != 'undefined' && data.code == "ok") { if (data && typeof data.code != 'undefined' && data.code == "ok") {
nameLink.text(name); nameLink.text(name);
} else { } else {
alert("Failed to rename project: " + data.message) alert("Failed to rename project: " + data.message);
} }
} }
}); });

View File

@ -47,10 +47,10 @@ Refine.ExcelParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this._updatePreview(); this._updatePreview();
}; };
Refine.DefaultImportingController.parserUIs["ExcelParserUI"] = Refine.ExcelParserUI; Refine.DefaultImportingController.parserUIs.ExcelParserUI = Refine.ExcelParserUI;
Refine.ExcelParserUI.prototype.dispose = function() { Refine.ExcelParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -68,7 +68,7 @@ Refine.ExcelParserUI.prototype.getOptions = function() {
var parseIntDefault = function(s, def) { var parseIntDefault = function(s, def) {
try { try {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
return n; return n;
} }
@ -80,7 +80,7 @@ Refine.ExcelParserUI.prototype.getOptions = function() {
this._optionContainerElmts.sheetRecordContainer.find('input').each(function() { this._optionContainerElmts.sheetRecordContainer.find('input').each(function() {
if (this.checked) { 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() { Refine.ExcelParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }

View File

@ -48,10 +48,10 @@ Refine.FixedWidthParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this.updatePreview(); this.updatePreview();
}; };
Refine.DefaultImportingController.parserUIs["FixedWidthParserUI"] = Refine.FixedWidthParserUI; Refine.DefaultImportingController.parserUIs.FixedWidthParserUI = Refine.FixedWidthParserUI;
Refine.FixedWidthParserUI.prototype.dispose = function() { Refine.FixedWidthParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -72,18 +72,15 @@ Refine.FixedWidthParserUI.prototype.getOptions = function() {
options.columnNames = columnNames; options.columnNames = columnNames;
} }
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) { if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") {
case 'new-line':
options.lineSeparator = "\n"; options.lineSeparator = "\n";
break; } else {
default: options.lineSeparator = String.decodeSeparator(this._optionContainerElmts.rowSeparatorInput[0].value);
options.lineSeparator = String.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
} }
var parseIntDefault = function(s, def) { var parseIntDefault = function(s, def) {
try { try {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
return n; return n;
} }
@ -191,7 +188,7 @@ Refine.FixedWidthParserUI.prototype._getColumnWidths = function() {
var newColumnWidths = []; var newColumnWidths = [];
var a = $.trim(this._optionContainerElmts.columnWidthsInput[0].value).replace(/,\s+/g, ',').split(','); var a = $.trim(this._optionContainerElmts.columnWidthsInput[0].value).replace(/,\s+/g, ',').split(',');
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var n = parseInt(a[i]); var n = parseInt(a[i],10);
if (!isNaN(n)) { if (!isNaN(n)) {
newColumnWidths.push(n); newColumnWidths.push(n);
} }
@ -200,7 +197,7 @@ Refine.FixedWidthParserUI.prototype._getColumnWidths = function() {
}; };
Refine.FixedWidthParserUI.prototype._scheduleUpdatePreview = function() { Refine.FixedWidthParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -266,7 +263,7 @@ Refine.FixedWidthPreviewTable.prototype._render = function() {
var addCell = function(tr) { var addCell = function(tr) {
var index = tr.cells.length; var index = tr.cells.length;
var td = tr.insertCell(index); var td = tr.insertCell(index);
td.className = (index % 2 == 0) ? 'even' : 'odd'; td.className = (index % 2 === 0) ? 'even' : 'odd';
return td; return td;
}; };
@ -373,7 +370,7 @@ Refine.FixedWidthPreviewTable.prototype._render = function() {
var newColumnWidths = []; var newColumnWidths = [];
for (var i = 0; i < columnCharIndexes.length; i++) { for (var i = 0; i < columnCharIndexes.length; i++) {
var charIndex = columnCharIndexes[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) { if (columnWidth > 0) {
newColumnWidths.push(columnWidth); newColumnWidths.push(columnWidth);
} }

View File

@ -48,10 +48,10 @@ Refine.JsonParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this._showPickRecordNodesUI(); this._showPickRecordNodesUI();
}; };
Refine.DefaultImportingController.parserUIs["JsonParserUI"] = Refine.JsonParserUI; Refine.DefaultImportingController.parserUIs.JsonParserUI = Refine.JsonParserUI;
Refine.JsonParserUI.prototype.dispose = function() { Refine.JsonParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -72,7 +72,7 @@ Refine.JsonParserUI.prototype.getOptions = function() {
var parseIntDefault = function(s, def) { var parseIntDefault = function(s, def) {
try { try {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
return n; return n;
} }
@ -162,7 +162,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() {
var elementNode = null; var elementNode = null;
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
if (elementNode != null) { if (elementNode !== null) {
$('<span>').addClass('punctuation').text(',').appendTo(elementNode); $('<span>').addClass('punctuation').text(',').appendTo(elementNode);
} }
elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container); elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container);
@ -178,7 +178,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() {
var elementNode = null; var elementNode = null;
for (var key in o) { for (var key in o) {
if (o.hasOwnProperty(key)) { if (o.hasOwnProperty(key)) {
if (elementNode != null) { if (elementNode !== null) {
$('<span>').addClass('punctuation').text(',').appendTo(elementNode); $('<span>').addClass('punctuation').text(',').appendTo(elementNode);
} }
elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container); elementNode = $('<div>').addClass('node').addClass('indented').appendTo(container);
@ -197,7 +197,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() {
registerEvents(container, parentPath); registerEvents(container, parentPath);
}; };
var renderNode = function(node, container, parentPath) { var renderNode = function(node, container, parentPath) {
if (node == null) { if (node === null) {
$('<span>').addClass('literal').text('null').appendTo(container); $('<span>').addClass('literal').text('null').appendTo(container);
} else { } else {
if ($.isPlainObject(node)) { if ($.isPlainObject(node)) {
@ -214,7 +214,7 @@ Refine.JsonParserUI.prototype._showPickRecordNodesUI = function() {
}; };
Refine.JsonParserUI.prototype._scheduleUpdatePreview = function() { Refine.JsonParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }

View File

@ -48,14 +48,14 @@ Refine.LineBasedParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this._updatePreview(); this._updatePreview();
}; };
Refine.DefaultImportingController.parserUIs["LineBasedParserUI"] = Refine.LineBasedParserUI; Refine.DefaultImportingController.parserUIs.LineBasedParserUI = Refine.LineBasedParserUI;
Refine.LineBasedParserUI.prototype.confirmReadyToCreateProject = function() { Refine.LineBasedParserUI.prototype.confirmReadyToCreateProject = function() {
return true; return true;
}; };
Refine.LineBasedParserUI.prototype.dispose = function() { Refine.LineBasedParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -69,7 +69,7 @@ Refine.LineBasedParserUI.prototype.getOptions = function() {
var parseIntDefault = function(s, def) { var parseIntDefault = function(s, def) {
try { try {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
return n; return n;
} }
@ -80,13 +80,10 @@ Refine.LineBasedParserUI.prototype.getOptions = function() {
}; };
options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1); options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1);
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) { if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") {
case 'new-line': options.lineSeparator = "\n";
options.lineSeparator = "\n"; } else {
break; options.lineSeparator = String.decodeSeparator(this._optionContainerElmts.rowSeparatorInput[0].value);
default:
options.lineSeparator = String.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
} }
if (this._optionContainerElmts.ignoreCheckbox[0].checked) { if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
@ -166,7 +163,7 @@ Refine.LineBasedParserUI.prototype._initialize = function() {
}; };
Refine.LineBasedParserUI.prototype._scheduleUpdatePreview = function() { Refine.LineBasedParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }

View File

@ -48,14 +48,14 @@ Refine.RdfTriplesParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this._updatePreview(); this._updatePreview();
}; };
Refine.DefaultImportingController.parserUIs["RdfTriplesParserUI"] = Refine.RdfTriplesParserUI; Refine.DefaultImportingController.parserUIs.RdfTriplesParserUI = Refine.RdfTriplesParserUI;
Refine.RdfTriplesParserUI.prototype.confirmReadyToCreateProject = function() { Refine.RdfTriplesParserUI.prototype.confirmReadyToCreateProject = function() {
return true; return true;
}; };
Refine.RdfTriplesParserUI.prototype.dispose = function() { Refine.RdfTriplesParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -92,7 +92,7 @@ Refine.RdfTriplesParserUI.prototype._initialize = function() {
}; };
Refine.RdfTriplesParserUI.prototype._scheduleUpdatePreview = function() { Refine.RdfTriplesParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }

View File

@ -47,10 +47,10 @@ Refine.SeparatorBasedParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this._updatePreview(); this._updatePreview();
}; };
Refine.DefaultImportingController.parserUIs["SeparatorBasedParserUI"] = Refine.SeparatorBasedParserUI; Refine.DefaultImportingController.parserUIs.SeparatorBasedParserUI = Refine.SeparatorBasedParserUI;
Refine.SeparatorBasedParserUI.prototype.dispose = function() { Refine.SeparatorBasedParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -65,14 +65,12 @@ Refine.SeparatorBasedParserUI.prototype.getOptions = function() {
encoding: $.trim(this._optionContainerElmts.encodingInput[0].value) encoding: $.trim(this._optionContainerElmts.encodingInput[0].value)
}; };
switch (this._optionContainer.find("input[name='row-separator']:checked")[0].value) { if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") {
case 'new-line':
options.lineSeparator = "\n"; options.lineSeparator = "\n";
break; } else {
default: options.lineSeparator = String.decodeSeparator(this._optionContainerElmts.rowSeparatorInput[0].value);
options.lineSeparator = String.decodeSeparator(
this._optionContainerElmts.rowSeparatorInput[0].value);
} }
switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) { switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) {
case 'comma': case 'comma':
options.separator = ","; options.separator = ",";
@ -87,7 +85,7 @@ Refine.SeparatorBasedParserUI.prototype.getOptions = function() {
var parseIntDefault = function(s, def) { var parseIntDefault = function(s, def) {
try { try {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
return n; return n;
} }
@ -198,7 +196,7 @@ Refine.SeparatorBasedParserUI.prototype._initialize = function() {
}; };
Refine.SeparatorBasedParserUI.prototype._scheduleUpdatePreview = function() { Refine.SeparatorBasedParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }

View File

@ -48,10 +48,10 @@ Refine.XmlParserUI = function(controller, jobID, job, format, config,
this._initialize(); this._initialize();
this._showPickRecordElementsUI(); this._showPickRecordElementsUI();
}; };
Refine.DefaultImportingController.parserUIs["XmlParserUI"] = Refine.XmlParserUI; Refine.DefaultImportingController.parserUIs.XmlParserUI = Refine.XmlParserUI;
Refine.XmlParserUI.prototype.dispose = function() { Refine.XmlParserUI.prototype.dispose = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }
@ -71,7 +71,7 @@ Refine.XmlParserUI.prototype.getOptions = function() {
}; };
var parseIntDefault = function(s, def) { var parseIntDefault = function(s, def) {
try { try {
var n = parseInt(s); var n = parseInt(s,10);
if (!isNaN(n)) { if (!isNaN(n)) {
return n; return n;
} }
@ -210,7 +210,7 @@ Refine.XmlParserUI.prototype._showPickRecordElementsUI = function() {
}; };
Refine.XmlParserUI.prototype._scheduleUpdatePreview = function() { Refine.XmlParserUI.prototype._scheduleUpdatePreview = function() {
if (this._timerID != null) { if (this._timerID !== null) {
window.clearTimeout(this._timerID); window.clearTimeout(this._timerID);
this._timerID = null; this._timerID = null;
} }

View File

@ -33,63 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var preferenceUIs = []; var preferenceUIs = [];
function onLoad() {
$.post(
"/command/core/get-all-preferences",
null,
populatePreferences,
"json"
);
}
$(onLoad);
function populatePreferences(prefs) {
var body = $("#body-info").empty();
$('<h1>').text("Preferences").appendTo(body);
var table = $('<table>')
.addClass("list-table")
.addClass("preferences")
.html('<tr><th>Key</th><th>Value</th><th></th></tr>')
.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);
$('<button class="button">').text("Add Preference").appendTo(tdLast0).click(function() {
var key = window.prompt("Preference key:");
if (key) {
var value = window.prompt("Preference key value:");
if (value != null) {
var tr = table.insertRow(table.rows.length - 1);
preferenceUIs.push(new PreferenceUI(tr, key, value));
$.post(
"/command/core/set-preference",
{
name : key,
value : JSON.stringify(value)
},
function(o) {
if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
}
});
}
function PreferenceUI(tr, key, value) { function PreferenceUI(tr, key, value) {
var self = this; var self = this;
@ -97,13 +40,13 @@ function PreferenceUI(tr, key, value) {
$(td0).text(key); $(td0).text(key);
var td1 = tr.insertCell(1); var td1 = tr.insertCell(1);
$(td1).text(value != null ? value : ""); $(td1).text((value !== null) ? value : "");
var td2 = tr.insertCell(2); var td2 = tr.insertCell(2);
$('<button class="button">').text("Edit").appendTo(td2).click(function() { $('<button class="button">').text("Edit").appendTo(td2).click(function() {
var newValue = window.prompt("Change value of preference key " + key, value); var newValue = window.prompt("Change value of preference key " + key, value);
if (newValue != null) { if (newValue !== null) {
$(td1).text(newValue); $(td1).text(newValue);
$.post( $.post(
"/command/core/set-preference", "/command/core/set-preference",
@ -146,4 +89,61 @@ function PreferenceUI(tr, key, value) {
); );
} }
}); });
} }
function populatePreferences(prefs) {
var body = $("#body-info").empty();
$('<h1>').text("Preferences").appendTo(body);
var table = $('<table>')
.addClass("list-table")
.addClass("preferences")
.html('<tr><th>Key</th><th>Value</th><th></th></tr>')
.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);
$('<button class="button">').text("Add Preference").appendTo(tdLast0).click(function() {
var key = window.prompt("Preference key:");
if (key) {
var value = window.prompt("Preference key value:");
if (value !== null) {
var tr = table.insertRow(table.rows.length - 1);
preferenceUIs.push(new PreferenceUI(tr, key, value));
$.post(
"/command/core/set-preference",
{
name : key,
value : JSON.stringify(value)
},
function(o) {
if (o.code == "error") {
alert(o.message);
}
},
"json"
);
}
}
});
}
function onLoad() {
$.post(
"/command/core/get-all-preferences",
null,
populatePreferences,
"json"
);
}
$(onLoad);

View File

@ -173,12 +173,12 @@ Refine.reinitializeProjectData = function(f) {
Refine._renameProject = function() { Refine._renameProject = function() {
var name = window.prompt("New project name:", theProject.metadata.name); var name = window.prompt("New project name:", theProject.metadata.name);
if (name == null) { if (name === null) {
return; return;
} }
name = $.trim(name); name = $.trim(name);
if (theProject.metadata.name == name || name.length == 0) { if (theProject.metadata.name == name || name.length === 0) {
return; return;
} }
@ -389,7 +389,7 @@ Refine.fetchRows = function(start, limit, onDone, sorting) {
engine: JSON.stringify(ui.browsingEngine.getJSON()) engine: JSON.stringify(ui.browsingEngine.getJSON())
}; };
if (sorting) { if (sorting) {
body.sorting = JSON.stringify(sorting) body.sorting = JSON.stringify(sorting);
} }
$.post( $.post(

View File

@ -227,7 +227,7 @@ BrowsingEngine.prototype.removeFacet = function(facet) {
if (update) { if (update) {
Refine.update({ engineChanged: true }); Refine.update({ engineChanged: true });
} else if (this._facets.length == 0) { } else if (this._facets.length === 0) {
this._elmts.help.show(); this._elmts.help.show();
this._elmts.header.hide(); this._elmts.header.hide();
} }

View File

@ -41,7 +41,7 @@ ExtensionBar.MenuItems = [
ExtensionBar.addExtensionMenu = function(what) { ExtensionBar.addExtensionMenu = function(what) {
MenuSystem.appendTo(ExtensionBar.MenuItems, [], what); MenuSystem.appendTo(ExtensionBar.MenuItems, [], what);
} };
ExtensionBar.appendTo = function(path, what) { ExtensionBar.appendTo = function(path, what) {
MenuSystem.appendTo(ExtensionBar.MenuItems, path, what); MenuSystem.appendTo(ExtensionBar.MenuItems, path, what);

View File

@ -133,7 +133,7 @@ HistoryPanel.prototype._render = function() {
elmts.filterInput.keyup(function() { elmts.filterInput.keyup(function() {
var filter = $.trim(this.value.toLowerCase()); var filter = $.trim(this.value.toLowerCase());
if (filter.length == 0) { if (filter.length === 0) {
elmts.bodyDiv.find(".history-entry").removeClass("filtered-out"); elmts.bodyDiv.find(".history-entry").removeClass("filtered-out");
} else { } else {
elmts.bodyDiv.find(".history-entry").each(function() { elmts.bodyDiv.find(".history-entry").each(function() {

View File

@ -138,7 +138,7 @@ ProcessPanel.prototype._render = function(newData) {
this._div.fadeOut(200); this._div.fadeOut(200);
} else { } else {
this._div.fadeIn(200); this._div.fadeIn(200);
var cancelmessage = "Cancel" var cancelmessage = "Cancel";
var noticeDiv = $('<div id="notification"></div>').appendTo(this._div); var noticeDiv = $('<div id="notification"></div>').appendTo(this._div);
var descriptionSpan = $('<span></span>').appendTo(noticeDiv); var descriptionSpan = $('<span></span>').appendTo(noticeDiv);
var statusDiv = $('<div></div>').appendTo(noticeDiv); var statusDiv = $('<div></div>').appendTo(noticeDiv);

View File

@ -56,7 +56,7 @@ ReconStandardServicePanel.prototype._guessTypes = function(f) {
if (self._types.length === 0 && "defaultTypes" in self._service) { if (self._types.length === 0 && "defaultTypes" in self._service) {
var defaultTypes = {}; var defaultTypes = {};
$.each(self._service["defaultTypes"], function() { $.each(self._service.defaultTypes, function() {
defaultTypes[this.id] = this.name; defaultTypes[this.id] = this.name;
}); });
$.each(self._types, function() { $.each(self._types, function() {

View File

@ -114,7 +114,7 @@ DOM.loadHTML = function(module, path) {
success: function(html) { success: function(html) {
DOM._loadedHTML[fullPath] = html; DOM._loadedHTML[fullPath] = html;
} }
}) });
} }
return DOM._loadedHTML[fullPath]; return DOM._loadedHTML[fullPath];
}; };

View File

@ -64,7 +64,7 @@ Encoding.selectEncoding = function(input, onDone) {
var generateEncodingList = function(container, filter) { var generateEncodingList = function(container, filter) {
var table = $('<table>').html('<tr><th>Encoding</th><th>Aliases</th></tr>').appendTo(container)[0]; var table = $('<table>').html('<tr><th>Encoding</th><th>Aliases</th></tr>').appendTo(container)[0];
$.each(Refine.encodings, function() { $.each(Refine.encodings, function() {
if (filter == null || this.code in filter) { if (filter === null || this.code in filter) {
renderEncoding(table, this); renderEncoding(table, this);
} }
}); });

View File

@ -81,4 +81,4 @@ function formatRelativeDate(d) {
var diff = Math.floor(today.getYear() - d.getYear()); var diff = Math.floor(today.getYear() - d.getYear());
return (diff == 1) ? "a year ago" : diff + " years ago"; return (diff == 1) ? "a year ago" : diff + " years ago";
} }
}; }

View File

@ -95,8 +95,7 @@ URL.looksLikeUrl = function(s) {
if (sep >= URL.minSchemeLength) { if (sep >= URL.minSchemeLength) {
var scheme = s.substring(0, sep).toLowerCase(); var scheme = s.substring(0, sep).toLowerCase();
if (scheme in URL.schemes) { if (scheme in URL.schemes) {
return URL.schemes[scheme] == 0 || return (URL.schemes[scheme] === 0) || (s.substring(sep + 1, sep + 3) == "//");
s.substring(sep + 1, sep + 3) == "//";
} }
} }
} }

View File

@ -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", id: "core/sort",
"label": "Sort...", "label": "Sort...",
"click": function() { "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 self = this;
var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name); var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name);
var criteriaCount = this._dataTableView._getSortingCriteriaCount(); var criteriaCount = this._dataTableView._getSortingCriteriaCount();
var hasOtherCriteria = criterion == null ? (criteriaCount > 0) : criteriaCount > 1; var hasOtherCriteria = (criterion === null) ? (criteriaCount > 0) : criteriaCount > 1;
var items = [ var items = [
{ {
"label": "Sort...", "label": "Sort...",
"click": function() { "click": function() {
self._showSortingCriterion(criterion, hasOtherCriteria) self._showSortingCriterion(criterion, hasOtherCriteria);
} }
} }
]; ];
if (criterion != null) { if (criterion !== null) {
items.push({ items.push({
"label": "Reverse", "label": "Reverse",
"click": function() { "click": function() {

View File

@ -426,13 +426,13 @@ DataTableView.prototype._renderDataTables = function(table, headerTable) {
DataTableView.prototype._adjustDataTables = function() { DataTableView.prototype._adjustDataTables = function() {
var dataTable = this._div.find('.data-table'); var dataTable = this._div.find('.data-table');
var headerTable = this._div.find('.data-header-table'); var headerTable = this._div.find('.data-header-table');
if (dataTable.length == 0 || headerTable.length == 0) { if (dataTable.length === 0 || headerTable.length === 0) {
return; return;
} }
dataTable = dataTable[0]; dataTable = dataTable[0];
headerTable = headerTable[0]; headerTable = headerTable[0];
if (dataTable.rows.length == 0) { if (dataTable.rows.length === 0) {
return; return;
} }
@ -726,14 +726,14 @@ DataTableView.prototype._createSortingMenu = function(elmt) {
} }
} }
return null; return null;
} };
var createSubmenu = function(criterion) { var createSubmenu = function(criterion) {
var columnHeaderUI = getColumnHeaderUI(criterion.column); var columnHeaderUI = getColumnHeaderUI(criterion.column);
if (columnHeaderUI != null) { if (columnHeaderUI !== null) {
items.push({ items.push({
"label" : "By " + criterion.column, "label" : "By " + criterion.column,
"submenu" : columnHeaderUI.createSortingMenu() "submenu" : columnHeaderUI.createSortingMenu()
}) });
} }
}; };
for (var i = 0; i < this._sorting.criteria.length; i++) { for (var i = 0; i < this._sorting.criteria.length; i++) {

View File

@ -306,9 +306,9 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var doTransposeRowsIntoColumns = function() { var doTransposeRowsIntoColumns = function() {
var rowCount = window.prompt("How many rows to transpose?", "2"); var rowCount = window.prompt("How many rows to transpose?", "2");
if (rowCount != null) { if (rowCount !== null) {
try { try {
rowCount = parseInt(rowCount); rowCount = parseInt(rowCount,10);
} catch (e) { } catch (e) {
// ignore // ignore
} }

View File

@ -213,20 +213,25 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
var s = "[" + elmts.lengthsTextarea[0].value + "]"; var s = "[" + elmts.lengthsTextarea[0].value + "]";
try { try {
var a = JSON.parse(s); 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) { } catch (e) {
alert("The given field lengths are not properly formatted."); alert("The given field lengths are not properly formatted.");
return; 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( Refine.postCoreProcess(

View File

@ -52,7 +52,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
null, null,
{ cellsChanged: true, columnStatsChanged: true } { cellsChanged: true, columnStatsChanged: true }
); );
} };
var doReconMatchBestCandidates = function() { var doReconMatchBestCandidates = function() {
Refine.postCoreProcess( 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."); 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."); alert("Please select at least one kind of judgment to copy.");
} else { } else {
Refine.postCoreProcess( Refine.postCoreProcess(