diff --git a/public/index.html b/public/index.html index 2ec81ee..4a2a20a 100644 --- a/public/index.html +++ b/public/index.html @@ -134,8 +134,8 @@

STREET SEGMENT:

Report an Issue
Notice an issue with this site? Want to request a new tree? Contact Santa Monica's Public Landscape Manager via - + Santa Monica Works @@ -235,8 +235,8 @@

STREET SEGMENT:

Report an Issue
Notice an issue with this tree? Contact Santa Monica's Public Landscape Manager via - + Santa Monica Works diff --git a/public/js/Sidebar.js b/public/js/Sidebar.js index f0066f8..dd5031d 100644 --- a/public/js/Sidebar.js +++ b/public/js/Sidebar.js @@ -105,12 +105,23 @@ var initialY = null; } Sidebar.prototype.populateVacanciesPanel = function(tree) { + this.vacantCommonName.innerText = tree.name_common; this.vacantTreeId.innerText = tree.tree_id; this.vacantAddress.innerText = tree.address; this.vacantPruningYear.innerText = tree.pruning_year; this.vacantReplacementSpecies.innerHTML = `${tree.replacement_species}`; this.vacantStreetSegment.innerText = tree.segment; + + //report link for vacant sites + const report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell" + const report_link_vacant = document.getElementById('report-link-vacant') + report_link_vacant.onclick = () => { + + to_clipboard(`${tree.address}, Vacant site, Tree ID ${tree.tree_id} `) + //open city website + window.open(report_url) + } } Sidebar.prototype.populateTreePanel = function(tree) { @@ -156,6 +167,17 @@ var initialY = null; } else { this.heritageContainer.classList.remove('active'); } + + + //report link for trees + const report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell" + const report_link_tree = document.getElementById('report-link-tree') + report_link_tree.onclick = () => { + to_clipboard(`${tree.address} Tree ID ${tree.tree_id} `) + //open city website + + window.open(report_url) + } } Sidebar.prototype.showDefault = function() { @@ -312,7 +334,7 @@ var initialY = null; window.history.pushState('object', document.title, newURL); } - const fillLastUpdate = () => { + const fillLastUpdate = () => { //only preform fetch & update when this.lastUpdate is uninitialized if(this.lastUpdate) { return } @@ -354,6 +376,27 @@ var initialY = null; } + + //helper function for clipboard copy + const to_clipboard = (str) => { + //create dummy input element for clipboard operations + const dummy = document.createElement('input') + dummy.setAttribute('readonly', 'readonly') + //set content to be copied + dummy.setAttribute('value',str) + document.body.appendChild(dummy) + //select & copy + dummy.focus() + dummy.setSelectionRange(0, dummy.value.length) + try { + document.execCommand('copy') + } catch (error) { + console.log(error) + } + //remove dummy element + document.body.removeChild(dummy) + } + // Exports module.Sidebar = Sidebar;