Skip to content

Commit 07ce14d

Browse files
committed
report link: copy information to clipboard onclick, initial setup
1 parent 99452b0 commit 07ce14d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ <h4>STREET SEGMENT:</h4>
235235
<div class="sidebar-divider"></div>
236236
<h5>Report an Issue</h5>
237237
<span>Notice an issue with this tree? Contact Santa Monica's Public Landscape Manager via
238-
<a href="https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
239-
target="_blank" rel="noopener">
238+
<a href=""
239+
target="_blank" rel="noopener" id = "report-link-tree">
240240
Santa Monica Works
241241
</a>
242242
</span>

public/js/Sidebar.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ var initialY = null;
105105
}
106106

107107
Sidebar.prototype.populateVacanciesPanel = function(tree) {
108+
108109
this.vacantCommonName.innerText = tree.name_common;
109110
this.vacantTreeId.innerText = tree.tree_id;
110111
this.vacantAddress.innerText = tree.address;
@@ -156,6 +157,32 @@ var initialY = null;
156157
} else {
157158
this.heritageContainer.classList.remove('active');
158159
}
160+
161+
//report link
162+
const report_link = document.getElementById('report-link-tree')
163+
164+
report_link.onclick = () => {
165+
//create dummy input element for clipboard operations
166+
const dummy = document.createElement('input')
167+
dummy.setAttribute('readonly', 'readonly')
168+
//set content to be copied
169+
dummy.setAttribute('value', `${tree.address} Tree ID ${tree.tree_id} `)
170+
document.body.appendChild(dummy)
171+
//select & copy
172+
dummy.focus()
173+
dummy.setSelectionRange(0, dummy.value.length)
174+
try {
175+
document.execCommand('copy')
176+
} catch (error) {
177+
console.log(error)
178+
}
179+
//remove dummy element
180+
document.body.removeChild(dummy)
181+
182+
//open city website
183+
report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
184+
window.open(report_url)
185+
}
159186
}
160187

161188
Sidebar.prototype.showDefault = function() {

0 commit comments

Comments
 (0)