Skip to content

Commit 22d263e

Browse files
committed
refactor, set up for vacant site
1 parent d07b500 commit 22d263e

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
@@ -109,6 +109,16 @@ var initialY = null;
109109
this.vacantPruningYear.innerText = tree.pruning_year;
110110
this.vacantReplacementSpecies.innerHTML = `<em>${tree.replacement_species}</em>`;
111111
this.vacantStreetSegment.innerText = tree.segment;
112+
113+
//report link for vacant sites
114+
const report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
115+
const report_link_vacant = document.getElementById('report-link-vacant')
116+
report_link_vacant.onclick = () => {
117+
118+
to_clipboard(`${tree.address}, Vacant site, Tree ID ${tree.tree_id} `)
119+
//open city website
120+
window.open(report_url)
121+
}
112122
}
113123

114124
Sidebar.prototype.populateTreePanel = function(tree) {
@@ -155,29 +165,14 @@ var initialY = null;
155165
this.heritageContainer.classList.remove('active');
156166
}
157167

158-
//report link
159-
const report_link = document.getElementById('report-link-tree')
160-
161-
report_link.onclick = () => {
162-
//create dummy input element for clipboard operations
163-
const dummy = document.createElement('input')
164-
dummy.setAttribute('readonly', 'readonly')
165-
//set content to be copied
166-
dummy.setAttribute('value', `${tree.address} Tree ID ${tree.tree_id} `)
167-
document.body.appendChild(dummy)
168-
//select & copy
169-
dummy.focus()
170-
dummy.setSelectionRange(0, dummy.value.length)
171-
try {
172-
document.execCommand('copy')
173-
} catch (error) {
174-
console.log(error)
175-
}
176-
//remove dummy element
177-
document.body.removeChild(dummy)
178168

169+
//report link for trees
170+
const report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
171+
const report_link_tree = document.getElementById('report-link-tree')
172+
report_link_tree.onclick = () => {
173+
to_clipboard(`${tree.address} Tree ID ${tree.tree_id} `)
179174
//open city website
180-
report_url = "https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
175+
181176
window.open(report_url)
182177
}
183178
}
@@ -336,7 +331,7 @@ var initialY = null;
336331
window.history.pushState('object', document.title, newURL);
337332
}
338333

339-
const fillLastUpdate = () => {
334+
const fillLastUpdate = () => {
340335
//only preform fetch & update when this.lastUpdate is uninitialized
341336
if(this.lastUpdate) { return }
342337

@@ -378,6 +373,27 @@ var initialY = null;
378373

379374

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

0 commit comments

Comments
 (0)