Skip to content

Commit ef44f19

Browse files
committed
refactor, set up for vacant site
1 parent 07ce14d commit ef44f19

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ <h4>STREET SEGMENT:</h4>
134134
<h5>Report an Issue</h5>
135135
<span>Notice an issue with this site? Want to request a new tree?
136136
Contact Santa Monica's Public Landscape Manager via
137-
<a href="https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
138-
target="_blank" rel="noopener">
137+
<a href=""
138+
target="_blank" rel="noopener" id = "report-link-vacant">
139139
Santa Monica Works
140140
</a>
141141
</span>

public/js/Sidebar.js

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ var initialY = null;
112112
this.vacantPruningYear.innerText = tree.pruning_year;
113113
this.vacantReplacementSpecies.innerHTML = `<em>${tree.replacement_species}</em>`;
114114
this.vacantStreetSegment.innerText = tree.segment;
115+
116+
//report link for vacant sites
117+
const report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
118+
const report_link_vacant = document.getElementById('report-link-vacant')
119+
report_link_vacant.onclick = () => {
120+
121+
to_clipboard(`${tree.address}, Vacant site, Tree ID ${tree.tree_id} `)
122+
//open city website
123+
window.open(report_url)
124+
}
115125
}
116126

117127
Sidebar.prototype.populateTreePanel = function(tree) {
@@ -158,29 +168,14 @@ var initialY = null;
158168
this.heritageContainer.classList.remove('active');
159169
}
160170

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)
181171

172+
//report link for trees
173+
const report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
174+
const report_link_tree = document.getElementById('report-link-tree')
175+
report_link_tree.onclick = () => {
176+
to_clipboard(`${tree.address} Tree ID ${tree.tree_id} `)
182177
//open city website
183-
report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
178+
184179
window.open(report_url)
185180
}
186181
}
@@ -339,7 +334,7 @@ var initialY = null;
339334
window.history.pushState('object', document.title, newURL);
340335
}
341336

342-
const fillLastUpdate = () => {
337+
const fillLastUpdate = () => {
343338
//only preform fetch & update when this.lastUpdate is uninitialized
344339
if(this.lastUpdate) { return }
345340

@@ -381,6 +376,27 @@ var initialY = null;
381376

382377

383378
}
379+
380+
//helper function for clipboard copy
381+
const to_clipboard = (str) => {
382+
//create dummy input element for clipboard operations
383+
const dummy = document.createElement('input')
384+
dummy.setAttribute('readonly', 'readonly')
385+
//set content to be copied
386+
dummy.setAttribute('value',str)
387+
document.body.appendChild(dummy)
388+
//select & copy
389+
dummy.focus()
390+
dummy.setSelectionRange(0, dummy.value.length)
391+
try {
392+
document.execCommand('copy')
393+
} catch (error) {
394+
console.log(error)
395+
}
396+
//remove dummy element
397+
document.body.removeChild(dummy)
398+
}
399+
384400
// Exports
385401
module.Sidebar = Sidebar;
386402

0 commit comments

Comments
 (0)