diff --git a/src/main/webapp/scripts/dialogs/recon-dialog.js b/src/main/webapp/scripts/dialogs/recon-dialog.js index 9f68e88ec..c0c338c1e 100644 --- a/src/main/webapp/scripts/dialogs/recon-dialog.js +++ b/src/main/webapp/scripts/dialogs/recon-dialog.js @@ -14,10 +14,12 @@ function ReconDialog(column, types) { delete defaultTypes[this.id]; }); for (var id in defaultTypes) { - this._types.push({ - id: id, - name: defaultTypes[id].name - }); + if (defaultTypes.hasOwnProperty(id)) { + this._types.push({ + id: id, + name: defaultTypes[id].name + }); + } } this._createDialog(); diff --git a/src/main/webapp/scripts/facets/list-facet.js b/src/main/webapp/scripts/facets/list-facet.js index bb96e5458..f16e16b3d 100644 --- a/src/main/webapp/scripts/facets/list-facet.js +++ b/src/main/webapp/scripts/facets/list-facet.js @@ -131,9 +131,9 @@ ListFacet.prototype.render = function() { $('
').text(this._data.error).addClass("facet-body-message").appendTo(bodyDiv); bodyDiv.appendTo(container); } else { - var selectionCount = this._selection.length - + (this._blankChoice !== null && this._blankChoice.s ? 1 : 0) - + (this._errorChoice !== null && this._errorChoice.s ? 1 : 0); + var selectionCount = this._selection.length + + (this._blankChoice !== null && this._blankChoice.s ? 1 : 0) + + (this._errorChoice !== null && this._errorChoice.s ? 1 : 0); if (selectionCount > 0) { var reset = function() { diff --git a/src/main/webapp/scripts/index.js b/src/main/webapp/scripts/index.js index 05793d70f..cb0b303cf 100644 --- a/src/main/webapp/scripts/index.js +++ b/src/main/webapp/scripts/index.js @@ -1,23 +1,3 @@ -function onLoad() { - $.getJSON( - "/command/get-all-project-metadata", - null, - function(data) { - renderProjects(data); - $("#upload-file-button").click(onClickUploadFileButton); - }, - "json" - ); - - if (isThereNewRelease()) { - $('
' + - 'New version "' + GridworksReleases.releases[0].description + '" available for download here.' + - '
').appendTo(document.body); - } -} - -$(onLoad); - function onClickUploadFileButton(evt) { var projectName = $("#project-name-input")[0].value; if (! $.trim(projectName).length) { @@ -35,6 +15,36 @@ function onClickUploadFileButton(evt) { } } +function formatDate(d) { + var yesterday = Date.today().add({ days: -1 }); + var today = Date.today(); + var tomorrow = Date.today().add({ days: 1 }); + if (d.between(today, tomorrow)) { + return "Today " + d.toString("h:mm tt"); + } else if (d.between(yesterday, today)) { + return "Yesterday " + d.toString("h:mm tt"); + } else { + return d.toString("ddd, MMM d, yyyy"); + } +} + +function isThereNewRelease() { + var thisRevision = GridworksVersion.revision; + + var revision_pattern = /r([0-9]+)/; + + if (!revision_pattern.test(thisRevision)) { // probably "trunk" + return false; + } + + var latestRevision = GridworksReleases.releases[0].revision; + + var thisRev = parseInt(revision_pattern.exec(thisRevision)[1],10); + var latestRev = parseInt(revision_pattern.exec(GridworksReleases.releases[0].revision)[1],10); + + return latestRev > thisRev; +} + function renderProjects(data) { var projects = []; for (var n in data.projects) { @@ -97,32 +107,22 @@ function renderProjects(data) { } } -function formatDate(d) { - var yesterday = Date.today().add({ days: -1 }); - var today = Date.today(); - var tomorrow = Date.today().add({ days: 1 }); - if (d.between(today, tomorrow)) { - return "Today " + d.toString("h:mm tt"); - } else if (d.between(yesterday, today)) { - return "Yesterday " + d.toString("h:mm tt"); - } else { - return d.toString("ddd, MMM d, yyyy"); +function onLoad() { + $.getJSON( + "/command/get-all-project-metadata", + null, + function(data) { + renderProjects(data); + $("#upload-file-button").click(onClickUploadFileButton); + }, + "json" + ); + + if (isThereNewRelease()) { + $('
' + + 'New version "' + GridworksReleases.releases[0].description + '" available for download here.' + + '
').appendTo(document.body); } } -function isThereNewRelease() { - var thisRevision = GridworksVersion.revision; - - var revision_pattern = /r([0-9]+)/; - - if (!revision_pattern.test(thisRevision)) { // probably "trunk" - return false; - } - - var latestRevision = GridworksReleases.releases[0].revision; - - var thisRev = parseInt(revision_pattern.exec(thisRevision)[1],10); - var latestRev = parseInt(revision_pattern.exec(GridworksReleases.releases[0].revision)[1],10); - - return latestRev > thisRev; -} \ No newline at end of file +$(onLoad); diff --git a/src/main/webapp/scripts/project.js b/src/main/webapp/scripts/project.js index 085585e6b..90846c690 100644 --- a/src/main/webapp/scripts/project.js +++ b/src/main/webapp/scripts/project.js @@ -10,65 +10,6 @@ Gridworks.reportException = function(e) { } }; -function onLoad() { - var params = URL.getParameters(); - if ("project" in params) { - theProject = { - id: parseInt(params.project,10) - }; - - var uiState = {}; - if ("ui" in params) { - try { - uiState = JSON.parse(params.ui); - } catch (e) { - } - } - - Gridworks.reinitializeProjectData(function() { - initializeUI(uiState); - }); - } -} -$(onLoad); - -function initializeUI(uiState) { - document.title = theProject.metadata.name + " - Gridworks"; - - var path = $("#path"); - - $('' + - '' + theProject.metadata.name + ' project' + - '').appendTo(path); - - $('current view') - .mouseenter(function() { - this.href = Gridworks.getPermanentLink(); - }) - .appendTo($('').appendTo(path)); - - var body = $("#body").empty().html( - '
' + - '
' + - '
' + - '
' + - '' - ); - ui = DOM.bind(body); - - ui.menuBarContainer.css("top", $("#header").outerHeight() + "px"); - ui.menuBar = new MenuBar(ui.menuBarPanel); // construct the menu first so we can resize everything else - - resize(); - - ui.browsingEngine = new BrowsingEngine(ui.facetPanel, uiState.facets || []); - ui.processWidget = new ProcessWidget(ui.processPanel); - ui.historyWidget = new HistoryWidget(ui.historyPanel); - ui.dataTableView = new DataTableView(ui.viewPanel); - - $(window).bind("resize", resizeAll); -} - function resize() { var header = $("#header"); var footer = $("#footer"); @@ -108,6 +49,43 @@ function resizeAll() { ui.dataTableView.resize(); } +function initializeUI(uiState) { + document.title = theProject.metadata.name + " - Gridworks"; + + var path = $("#path"); + + $('' + + '' + theProject.metadata.name + ' project' + + '').appendTo(path); + + $('current view') + .mouseenter(function() { + this.href = Gridworks.getPermanentLink(); + }) + .appendTo($('').appendTo(path)); + + var body = $("#body").empty().html( + '
' + + '
' + + '
' + + '
' + + '' + ); + ui = DOM.bind(body); + + ui.menuBarContainer.css("top", $("#header").outerHeight() + "px"); + ui.menuBar = new MenuBar(ui.menuBarPanel); // construct the menu first so we can resize everything else + + resize(); + + ui.browsingEngine = new BrowsingEngine(ui.facetPanel, uiState.facets || []); + ui.processWidget = new ProcessWidget(ui.processPanel); + ui.historyWidget = new HistoryWidget(ui.historyPanel); + ui.dataTableView = new DataTableView(ui.viewPanel); + + $(window).bind("resize", resizeAll); +} + Gridworks.reinitializeProjectData = function(f) { Ajax.chainGetJSON( "/command/get-project-metadata?" + $.param({ project: theProject.id }), null, @@ -306,3 +284,30 @@ Gridworks.getPermanentLink = function() { ]; return "project.html?" + params.join("&"); }; + +/* + * Loader + */ + +function onLoad() { + var params = URL.getParameters(); + if ("project" in params) { + theProject = { + id: parseInt(params.project,10) + }; + + var uiState = {}; + if ("ui" in params) { + try { + uiState = JSON.parse(params.ui); + } catch (e) { + } + } + + Gridworks.reinitializeProjectData(function() { + initializeUI(uiState); + }); + } +} + +$(onLoad); diff --git a/src/main/webapp/scripts/project/history-widget.js b/src/main/webapp/scripts/project/history-widget.js index c563af45b..d08bbda00 100644 --- a/src/main/webapp/scripts/project/history-widget.js +++ b/src/main/webapp/scripts/project/history-widget.js @@ -219,8 +219,10 @@ HistoryWidget.prototype._showApplyOperationsDialog = function() { var elmts = DOM.bind(html); $('').text("Apply").click(function() { + var json; + try { - var json = JSON.parse(elmts.textarea[0].value); + json = JSON.parse(elmts.textarea[0].value); } catch (e) { alert("The JSON you pasted is invalid."); return; diff --git a/src/main/webapp/scripts/protograph/schema-alignment-ui-link.js b/src/main/webapp/scripts/protograph/schema-alignment-ui-link.js index 6d6180f94..0e0141172 100644 --- a/src/main/webapp/scripts/protograph/schema-alignment-ui-link.js +++ b/src/main/webapp/scripts/protograph/schema-alignment-ui-link.js @@ -275,8 +275,10 @@ SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt self._configureTarget(); }; + var divSearch; + if (suggestions.length > 0) { - var divSearch = $('
').addClass("schema-alignment-link-menu-type-search2").html('
Search for a property or pick one below
').appendTo(menu); + divSearch = $('
').addClass("schema-alignment-link-menu-type-search2").html('
Search for a property or pick one below
').appendTo(menu); function createSuggestion(suggestion) { var menuItem = MenuSystem.createMenuItem().appendTo(menu); @@ -289,7 +291,7 @@ SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt createSuggestion(suggestions[i]); } } else { - var divSearch = $('
').addClass("schema-alignment-link-menu-type-search").html('
Search for a property
').appendTo(menu); + divSearch = $('
').addClass("schema-alignment-link-menu-type-search").html('
Search for a property
').appendTo(menu); } var input = $('').appendTo($('
').appendTo(divSearch)); diff --git a/src/main/webapp/scripts/views/data-table-view.js b/src/main/webapp/scripts/views/data-table-view.js index 63702447a..ffe25cd7b 100644 --- a/src/main/webapp/scripts/views/data-table-view.js +++ b/src/main/webapp/scripts/views/data-table-view.js @@ -131,6 +131,7 @@ DataTableView.prototype._renderDataTable = function(table) { } } }; + var renderColumnGroups = function(groups, keys) { var nextLayer = []; @@ -143,8 +144,8 @@ DataTableView.prototype._renderDataTable = function(table) { var foundGroup = false; for (var g = 0; g < groups.length; g++) { - var columnGroup = groups[g]; - if (columnGroup.startColumnIndex == c) { + var cg = groups[g]; + if (cg.startColumnIndex == c) { foundGroup = true; break; }