Mercurial > hg > STI-GWT
changeset 42:fe6778a2fada CellTable
cleanup of grid table left-overs
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 07 Dec 2012 16:01:51 +0100 |
parents | 20eb7596d466 |
children | fad6fb60a2db |
files | war/Sti.html war/scripts/sti/DynamicTable.js war/scripts/sti/STITable.js |
diffstat | 3 files changed, 0 insertions(+), 365 deletions(-) [+] |
line wrap: on
line diff
--- a/war/Sti.html Thu Dec 06 18:05:39 2012 +0100 +++ b/war/Sti.html Fri Dec 07 16:01:51 2012 +0100 @@ -27,7 +27,6 @@ <!--[if IE]><script type="text/javascript" src="scripts/libs/lib/excanvas.js"></script><![endif]--> <script src="scripts/sti/STIMap.js"></script> - <script src="scripts/sti/STITable.js"></script> <script src="scripts/sti/STITimeplot.js"></script> <script src="scripts/sti/STITutorial.js"></script> <script src="scripts/sti/STICore.js"></script>
--- a/war/scripts/sti/DynamicTable.js Thu Dec 06 18:05:39 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,286 +0,0 @@ -/** - * @author stjaenicke - */ -function DynamicTable(core, dataSet, index){ - - this.core = core; - this.dataSet = dataSet; - this.index = index; - this.tableDiv; - this.tableHeader; - this.tableBody; - this.tableFooter; - this.chunkSelect; - this.actualChunk; - this.rows; - - this.initialize(); - -} - -DynamicTable.prototype = { - - initialize: function(){ - /* - - this.chunks.push([]); - for (var i = 0; i < this.dataSet.objects.length; i++) { - if (this.chunks[this.chunks.length - 1].length == tableElements) - this.chunks.push([]); - this.chunks[this.chunks.length - 1].push(this.dataSet.objects[i]); - } - this.rows = []; - - var base = this; - - this.tableDiv = document.createElement("div"); - this.tableDiv.id = "dataTable"; - - var table = document.createElement("table"); - table.onselectstart = function(){ - return false; - }; - this.tableDiv.appendChild(table); - - // Initialisation of the table header - - this.tableHeader = document.createElement("thead"); - var headerRow = document.createElement("tr"); - this.tableHeader.appendChild(headerRow); - var visibilityLink = document.createElement("a"); - visibilityLink.id = "visibilityLink" + this.index; - if (this.dataSet.hidden) - visibilityLink.innerHTML = "show"; - else - visibilityLink.innerHTML = "hide"; - visibilityLink.onclick = function(){ - if (base.core.changeVisibilityStatus(base.index)) - document.getElementById("visibilityLink" + base.index).innerHTML = "show"; - else - document.getElementById("visibilityLink" + base.index).innerHTML = "hide"; - } - - var cell1 = document.createElement("th"); - cell1.appendChild(visibilityLink); - headerRow.appendChild(cell1); - - var thead = document.createElement("th"); - if (this.dataSet.type == 0) - thead.innerHTML = "Hits for: \"" + this.dataSet.termIdentifier + "\""; - else - if (this.dataSet.type == 1) - thead.innerHTML = "Individual Data"; - headerRow.appendChild(thead); - - var colorBox = document.createElement("th"); - var canvas = document.createElement("canvas"); - canvas.width = 15; - canvas.height = 15; - if (!canvas.getContext && G_vmlCanvasManager) - canvas = G_vmlCanvasManager.initElement(canvas); - var ctx = canvas.getContext("2d"); - ctx.fillStyle = 'rgb(' + colors[this.index].rt + ',' + colors[this.index].gt + ',' + colors[this.index].bt + ')'; - ctx.fillRect (0, 0, 15, 15); - colorBox.appendChild(canvas); - headerRow.appendChild(colorBox); - - var deleteLink = document.createElement("a"); - deleteLink.innerHTML = "delete"; - deleteLink.onclick = function(){ - base.core.deleteSearch(base.index); - } - var cell2 = document.createElement("th"); - cell2.appendChild(deleteLink); - headerRow.appendChild(cell2); - - table.appendChild(this.tableHeader); - - - // Initialisation of the table footer - - this.tableBody = document.createElement("tbody"); - table.appendChild(this.tableBody); - - - // Initialisation of the table footer - - this.tableFooter = document.createElement("tfoot"); - var footerRow = document.createElement("tr"); - this.tableFooter.appendChild(footerRow); - - var previousLink = document.createElement("a"); - previousLink.innerHTML = "<<<"; - previousLink.onclick = function(){ - if (base.actualChunk > 0) { - base.chunkSelect.value = base.actualChunk; - base.createTableBody(); - } - } - var nextLink = document.createElement("a"); - nextLink.innerHTML = ">>>"; - nextLink.onclick = function(){ - if (base.actualChunk + 1 < base.chunks.length) { - base.chunkSelect.value = base.actualChunk + 2; - base.createTableBody(); - } - } - var tfoot = document.createElement("th"); - tfoot.colSpan = "4"; - this.chunkSelect = document.createElement("input"); - this.chunkSelect.type = "text"; - this.chunkSelect.setAttribute( 'size', this.chunks.length.toString().length-1 ); - this.chunkSelect.setAttribute( 'maxlength', this.chunks.length.toString().length ); - this.chunkSelect.value = 1; - this.chunkSelect.onkeypress = function handleEnter(event){ - var charCode; - if (event && event.which) { - charCode = event.which; - } - else - if (window.event) { - event = window.event; - charCode = event.keyCode; - } - if (charCode == 13) - base.createTableBody(); - } - var maxChunks = document.createElement("label"); - maxChunks.innerHTML = "/" + this.chunks.length; - tfoot.appendChild(previousLink); - tfoot.appendChild(this.chunkSelect); - tfoot.appendChild(maxChunks); - tfoot.appendChild(nextLink); - footerRow.appendChild(tfoot); - - table.appendChild(this.tableFooter); - - this.createTableBody(); - */ - }, - - createRow: function(object, index){ - /* - - var base = this; - - var dataRow = document.createElement("tr"); - - var indexCell = document.createElement("td"); - indexCell.innerHTML = index + 1; - dataRow.appendChild(indexCell); - - var objectCell = document.createElement("td"); - if (object.link != null) { - var linkElement = document.createElement("a"); - linkElement.href = object.link; - linkElement.target = "_blank"; - linkElement.innerHTML = object.name; - objectCell.appendChild(linkElement); - } - else { - objectCell.innerHTML = object.name; - } - dataRow.appendChild(objectCell); - - var placeCell = document.createElement("td"); - placeCell.innerHTML = object.place; - dataRow.appendChild(placeCell); - - var timeCell = document.createElement("td"); - timeCell.innerHTML = base.core.getTimeString(object.time,object.granularity); - dataRow.appendChild(timeCell); - - var mouseover = function(){ - dataRow.lastColor = dataRow.style.backgroundColor; - dataRow.style.backgroundColor = "rgb(" + cellColor.ro + "," + cellColor.go + "," + cellColor.bo + ")"; - if( object.percentage != 1 ){ - object.hoverSelect = true; - base.core.timeplot.removePoles(); - base.core.updateTimeAndMap(); - } - } - - var mouseout = function(){ - dataRow.style.backgroundColor = dataRow.lastColor; - object.hoverSelect = false; - base.core.timeplot.removePoles(); - base.core.updateTimeAndMap(); - } - - var mouseclick = function(){ - base.core.resetCore(); - object.hoverSelect = false; - var c = colors[base.index]; - dataRow.style.background = 'rgb(' + c.rt + ',' + c.gt + ',' + c.bt + ')'; - dataRow.lastColor = dataRow.style.background; - object.setPercentage(1); - base.core.updateTimeAndMap(); - } - - if (document.addEventListener) { - dataRow.addEventListener("mouseover", mouseover, false); - dataRow.addEventListener("mouseout", mouseout, false); - dataRow.addEventListener("click", mouseclick, false); - } - else - if (document.attachEvent) { - dataRow.attachEvent("onmouseover", mouseover); - dataRow.attachEvent("onmouseout", mouseout); - dataRow.attachEvent("onclick", mouseclick); - } - - if (index % 20 == 0) { - indexCell.style.borderTop = "none"; - objectCell.style.borderTop = "none"; - placeCell.style.borderTop = "none"; - timeCell.style.borderTop = "none"; - } - - return dataRow; - */ - - }, - - createTableBody: function(){ - /* - try { - var selectedChunk = parseInt(this.chunkSelect.value); - if (selectedChunk > this.chunks.length) { - throw "Exception"; - } - this.actualChunk = selectedChunk - 1; - } - catch (exception) { - this.chunkSelect.value = this.actualChunk + 1; - return; - } - this.tableBody.innerHTML = ""; - this.rows = []; - - for (var i = 0; i < this.chunks[this.actualChunk].length; i++) { - var index = this.actualChunk * tableElements + i; - var row = this.createRow(this.chunks[this.actualChunk][i], index); - this.tableBody.appendChild(row); - this.rows.push(row); - } - this.update(); - */ - }, - - update: function(){ - /* - for (var i = 0; i < this.chunks[this.actualChunk].length; i++) { - var object = this.chunks[this.actualChunk][i]; - var p = object.percentage; - if (object.hoverSelect) { - p = 1; - } - var r = cellColor.r + Math.round(p * (colors[this.index].rt - cellColor.r)); - var g = cellColor.g + Math.round(p * (colors[this.index].gt - cellColor.g)); - var b = cellColor.b + Math.round(p * (colors[this.index].bt - cellColor.b)); - this.rows[i].style.background = 'rgb(' + r + ',' + g + ',' + b + ')'; - } - */ - } - -}
--- a/war/scripts/sti/STITable.js Thu Dec 06 18:05:39 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/** - * defines the table component of the Spatio Temporal Interface - * @param {STICore} core the sti core component, the table component has to deal with - * - * @constructor - */ -function STITable(core){ - - this.core = core; - this.baseRow; - this.dynamicTables; - this.tableColumns; - - this.initialize(); - -} - -STITable.prototype = { - - /** - * initializes the table component by creating a table with a single row, which cells will contain the tables of data sets - */ - initialize: function(){ - this.dynamicTables = []; - var baseTable = document.createElement("table"); - document.getElementById("dataTables").appendChild(baseTable); - baseTable.cellSpacing = "20"; - this.baseRow = baseTable.insertRow(0); - this.tableColumns = []; - this.status = 0; - document.getElementById("dataTables").onselectstart = function(){ - return false; - }; - }, - - /** - * deletes all tables - */ - deleteTables: function(){ - for (var i = this.tableColumns.length; i > 0; i--) { - this.baseRow.removeChild(this.tableColumns[i-1]); - delete this.tableColumns[i-1]; - delete this.dynamicTables[i-1]; - this.tableColumns.pop(); - this.dynamicTables.pop(); - } - }, - - /** - * initializes the tables for given datasets - * @param {Array} objects an array of object-array, which contain all elements that are in the actual display set - * @param {DataSet[]} dataSets all dataSets; needed for the header rows of the data tables - */ - initTables: function(dataSets){ - - this.deleteTables(); - - for (var i = 0; i < dataSets.length; i++) { - var dynamicTable = new DynamicTable(this.core,dataSets[i],i); - var column = this.baseRow.insertCell(0); - column.width = Math.floor(100 / dataSets.length) + '%'; - column.appendChild(dynamicTable.tableDiv); - this.tableColumns.push(column); - this.dynamicTables.push(dynamicTable); - } - - }, - - /** - * updates each dynamic table - */ - updateTables: function(){ - for (var i = 0; i < this.dynamicTables.length; i++){ - this.dynamicTables[i].update(); - } - } - -}