From 07ce14d4555c02b7249d3e27a27b1d49af80d902 Mon Sep 17 00:00:00 2001
From: Mai <24775373+mrtmrt233@users.noreply.github.com>
Date: Sat, 2 May 2020 22:05:47 -0700
Subject: [PATCH 1/2] report link: copy information to clipboard onclick,
initial setup
---
public/index.html | 4 ++--
public/js/Sidebar.js | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/public/index.html b/public/index.html
index 2ec81ee..cf10857 100644
--- a/public/index.html
+++ b/public/index.html
@@ -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..3d9f378 100644
--- a/public/js/Sidebar.js
+++ b/public/js/Sidebar.js
@@ -105,6 +105,7 @@ 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;
@@ -156,6 +157,32 @@ var initialY = null;
} else {
this.heritageContainer.classList.remove('active');
}
+
+ //report link
+ const report_link = document.getElementById('report-link-tree')
+
+ report_link.onclick = () => {
+ //create dummy input element for clipboard operations
+ const dummy = document.createElement('input')
+ dummy.setAttribute('readonly', 'readonly')
+ //set content to be copied
+ dummy.setAttribute('value', `${tree.address} Tree ID ${tree.tree_id} `)
+ 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)
+
+ //open city website
+ report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
+ window.open(report_url)
+ }
}
Sidebar.prototype.showDefault = function() {
From ef44f19f46f39135cc896d73d5074d97209d9a86 Mon Sep 17 00:00:00 2001
From: Mai <24775373+mrtmrt233@users.noreply.github.com>
Date: Sun, 3 May 2020 15:34:13 -0700
Subject: [PATCH 2/2] refactor, set up for vacant site
---
public/index.html | 4 +--
public/js/Sidebar.js | 60 ++++++++++++++++++++++++++++----------------
2 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/public/index.html b/public/index.html
index cf10857..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
diff --git a/public/js/Sidebar.js b/public/js/Sidebar.js
index 3d9f378..dd5031d 100644
--- a/public/js/Sidebar.js
+++ b/public/js/Sidebar.js
@@ -112,6 +112,16 @@ var initialY = null;
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) {
@@ -158,29 +168,14 @@ var initialY = null;
this.heritageContainer.classList.remove('active');
}
- //report link
- const report_link = document.getElementById('report-link-tree')
-
- report_link.onclick = () => {
- //create dummy input element for clipboard operations
- const dummy = document.createElement('input')
- dummy.setAttribute('readonly', 'readonly')
- //set content to be copied
- dummy.setAttribute('value', `${tree.address} Tree ID ${tree.tree_id} `)
- 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)
+ //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
- report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
+
window.open(report_url)
}
}
@@ -339,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 }
@@ -381,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;