diff --git a/src/index.html b/src/index.html index 9f83251..eb8982c 100644 --- a/src/index.html +++ b/src/index.html @@ -16,7 +16,7 @@ - + diff --git a/src/site.css b/src/site.css index 4e2cb07..f3976ca 100644 --- a/src/site.css +++ b/src/site.css @@ -28,11 +28,13 @@ table.dataTable>tbody>tr.odd { } table.dataTable>tbody>tr { border-bottom: 1pt solid #676767; - cursor: pointer; } table.dataTable>tbody>tr:hover { background-color: #e9e9e9; } +table.dataTable td { + padding-right: 10px; +} .map-overlay { font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif; diff --git a/src/site.js b/src/site.js index cf18b6f..f67d30c 100644 --- a/src/site.js +++ b/src/site.js @@ -521,7 +521,16 @@ function buildTable() { columns: config.tableHeaders.labels.map((header) => { return {'title': header}}) }); - config.table.column(config.tableHeaders.values.indexOf(config.tableHeaders.clickColumn)).visible(false); + if ('rightAlign' in config.tableHeaders) { + config.tableHeaders.rightAlign.forEach((col) => { + $("#site-style").get(0).sheet.insertRule('td:nth-child(' + (config.tableHeaders.values.indexOf(col)+1) + ') { text-align:right }', 0); + }); + } + if ('noWrap' in config.tableHeaders) { + config.tableHeaders.noWrap.forEach((col) => { + $("#site-style").get(0).sheet.insertRule('td:nth-child(' + (config.tableHeaders.values.indexOf(col)+1) + ') { white-space: nowrap }', 0); + }); + } $('#table-toggle').on("click", function() { if ($('#table-toggle-label').text().includes("Table view")) { @@ -538,16 +547,6 @@ function buildTable() { $('#basemap-toggle').show(); } }); - - $('#table tbody tr').click(function() { - window.open(config.table.row(this).data()[config.tableHeaders.values.indexOf(config.tableHeaders.clickColumn)], '_blank'); - }); - - config.table.on( 'draw', function () { - $('#table tbody tr').click(function() { - window.open(config.table.row(this).data()[config.tableHeaders.values.indexOf(config.tableHeaders.clickColumn)], '_blank'); - }); - }); } function updateTable() { config.table.clear(); @@ -555,8 +554,12 @@ function updateTable() { } function geoJSON2Table() { return config.preLinkedGeoJSON.features.map(feature => { - return config.tableHeaders.values.map((header) => { - return feature.properties[header]; + return config.tableHeaders.values.map((header) => { + if ('clickColumns' in config.tableHeaders && config.tableHeaders.clickColumns.includes(header)) { + return "" + feature.properties[header] + ''; + } else { + return feature.properties[header]; + } }); }); } diff --git a/trackers/coal-plant/config.js b/trackers/coal-plant/config.js index 27d9413..e015c69 100644 --- a/trackers/coal-plant/config.js +++ b/trackers/coal-plant/config.js @@ -45,9 +45,11 @@ var config = { /* configure the table view, selecting which columns to show, how to label them, and designated which column has the link */ tableHeaders: { - values: ['url','plant','unit','chinese_name','owner', 'parent', 'capacity', 'status', 'region', 'country', 'subnational', 'year'], - labels: ['url', 'Plant','Unit','Chinese Name','Owner','Parent','Capacity (MW)','Status','Region','Country','Subnational unit (province/state)','Start year'], - clickColumn: 'url' + values: ['plant','unit','chinese_name','owner', 'parent', 'capacity', 'status', 'region', 'country', 'subnational', 'year'], + labels: ['Plant','Unit','Chinese Name','Owner','Parent','Capacity (MW)','Status','Region','Country','Subnational unit (province/state)','Start year'], + clickColumns: ['plant'], + rightAlign: ['unit','capacity','year'], + noWrap: ['plant'] }, /* configure the search box; diff --git a/trackers/gas-plant/config.js b/trackers/gas-plant/config.js index 43d1bdb..603e633 100644 --- a/trackers/gas-plant/config.js +++ b/trackers/gas-plant/config.js @@ -25,9 +25,11 @@ var config = { assetLabel: 'units', nameField: 'project', tableHeaders: { - values: ['url','project','unit', 'owner', 'parent', 'capacity', 'status', 'region', 'country', 'province', 'start_year'], - labels: ['url', 'Plant','Unit','Owner','Parent','Capacity (MW)','Status','Region','Country','Subnational unit (province/state)','Start year'], - clickColumn: 'url' + values: ['project','unit', 'owner', 'parent', 'capacity', 'status', 'region', 'country', 'province', 'start_year'], + labels: ['Plant','Unit','Owner','Parent','Capacity (MW)','Status','Region','Country','Subnational unit (province/state)','Start year'], + clickColumns: ['project'], + rightAlign: ['unit','capacity','start_year'], + noWrap: ['project'] }, searchFields: { 'Plant': ['project'], 'Companies': ['owner', 'parent'], diff --git a/trackers/new-tracker/index.html b/trackers/new-tracker/index.html new file mode 120000 index 0000000..6b304e1 --- /dev/null +++ b/trackers/new-tracker/index.html @@ -0,0 +1 @@ +../../src/index.html \ No newline at end of file diff --git a/trackers/wind-power/config.js b/trackers/wind-power/config.js index 29048ff..3bc7c0c 100644 --- a/trackers/wind-power/config.js +++ b/trackers/wind-power/config.js @@ -33,9 +33,11 @@ var config = { assetLabel: 'phases', nameField: 'project', tableHeaders: { - values: ['url','project','unit','project_local','type','capacity','status', 'start_year', 'operator', 'owner', 'country'], - labels: ['url', 'Project Name','Phase name','Project Name in Local Language / Script','Installation Type','Capacity (MW)' ,'Status','Start Year','Operator', 'Owner','Country'], - clickColumn: 'url' + values: ['project','unit','project_local','type','capacity','status', 'start_year', 'operator', 'owner', 'country'], + labels: ['Project Name','Phase name','Project Name in Local Language / Script','Installation Type','Capacity (MW)' ,'Status','Start Year','Operator', 'Owner','Country'], + clickColumns: ['project'], + rightAlign: ['unit','capacity','start_year'], + noWrap: ['project'] }, searchFields: { 'Project': ['project'], 'Companies': ['owner', 'operator'],