26 lines
606 B
JavaScript
26 lines
606 B
JavaScript
|
|
var copy_on_update
|
|
|
|
export async function copy_func(now){
|
|
console.info([document, copy_on_update, now, "copy_func() executed"])
|
|
if ( copy_on_update || now ){
|
|
var ta = document.querySelector("textarea[name='snippet']")
|
|
ta.focus()
|
|
try {
|
|
await navigator.clipboard.writeText(ta.value)
|
|
} catch (error) {
|
|
console.error(error)
|
|
}
|
|
copy_on_update = false
|
|
}
|
|
}
|
|
|
|
document.querySelector("button[id='normcop']").onclick = function(ev){
|
|
copy_func(true)
|
|
copy_on_update = true
|
|
}
|
|
|
|
document.querySelector("button[id='copy-button']").onclick = function(ev){
|
|
copy_func(true)
|
|
}
|