@@ -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