2022-01-07 15:18:07 +00:00
|
|
|
const { applyTheme } = require("./darkmode")
|
|
|
|
const { createCopyButton } = require("./copycode.js")
|
|
|
|
const Clipboard = require("clipboard")
|
2022-01-06 12:58:10 +00:00
|
|
|
|
|
|
|
;(() => {
|
|
|
|
applyTheme()
|
|
|
|
})()
|
|
|
|
|
2021-05-21 09:33:17 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
2022-01-06 12:58:10 +00:00
|
|
|
let clipboard = new Clipboard(".clip")
|
2021-11-07 21:12:14 +00:00
|
|
|
|
|
|
|
clipboard.on("success", function (e) {
|
2022-01-06 12:58:10 +00:00
|
|
|
const trigger = e.trigger
|
2021-11-07 21:12:14 +00:00
|
|
|
|
|
|
|
if (trigger.hasAttribute("data-copy-feedback")) {
|
2022-01-06 12:58:10 +00:00
|
|
|
trigger.classList.add("gdoc-post__codecopy--success")
|
|
|
|
trigger.querySelector(".icon.copy").classList.add("hidden")
|
|
|
|
trigger.querySelector(".icon.check").classList.remove("hidden")
|
2021-11-07 21:12:14 +00:00
|
|
|
|
|
|
|
setTimeout(function () {
|
2022-01-06 12:58:10 +00:00
|
|
|
trigger.classList.remove("gdoc-post__codecopy--success")
|
|
|
|
trigger.querySelector(".icon.copy").classList.remove("hidden")
|
|
|
|
trigger.querySelector(".icon.check").classList.add("hidden")
|
|
|
|
}, 3000)
|
2021-11-07 21:12:14 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 12:58:10 +00:00
|
|
|
e.clearSelection()
|
|
|
|
})
|
|
|
|
|
|
|
|
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv))
|
|
|
|
})
|