Skip to content

report link: copy information to clipboard onclick, initial setup #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ <h4>STREET SEGMENT:</h4>
<h5>Report an Issue</h5>
<span>Notice an issue with this site? Want to request a new tree?
Contact Santa Monica's Public Landscape Manager via
<a href="https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
target="_blank" rel="noopener">
<a href=""
target="_blank" rel="noopener" id = "report-link-vacant">
Santa Monica Works
</a>
</span>
Expand Down Expand Up @@ -235,8 +235,8 @@ <h4>STREET SEGMENT:</h4>
<div class="sidebar-divider"></div>
<h5>Report an Issue</h5>
<span>Notice an issue with this tree? Contact Santa Monica's Public Landscape Manager via
<a href="https://user.govoutreach.com/santamonica/support.php?classificationId=30642&cmd=shell"
target="_blank" rel="noopener">
<a href=""
target="_blank" rel="noopener" id = "report-link-tree">
Santa Monica Works
</a>
</span>
Expand Down
45 changes: 44 additions & 1 deletion public/js/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<em>${tree.replacement_species}</em>`;
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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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;

Expand Down