2022-01-07 16:18:07 +01:00
|
|
|
const { applyTheme } = require("./darkmode")
|
|
|
|
const { createCopyButton } = require("./copycode.js")
|
|
|
|
const Clipboard = require("clipboard")
|
2022-01-06 13:58:10 +01:00
|
|
|
|
|
|
|
;(() => {
|
|
|
|
applyTheme()
|
|
|
|
})()
|
|
|
|
|
2021-05-21 11:33:17 +02:00
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
2022-01-06 13:58:10 +01:00
|
|
|
let clipboard = new Clipboard(".clip")
|
2021-11-07 22:12:14 +01:00
|
|
|
|
|
|
|
clipboard.on("success", function (e) {
|
2022-01-06 13:58:10 +01:00
|
|
|
const trigger = e.trigger
|
2021-11-07 22:12:14 +01:00
|
|
|
|
|
|
|
if (trigger.hasAttribute("data-copy-feedback")) {
|
2022-01-06 13:58:10 +01: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 22:12:14 +01:00
|
|
|
|
|
|
|
setTimeout(function () {
|
2022-01-06 13:58:10 +01: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 22:12:14 +01:00
|
|
|
}
|
|
|
|
|
2022-01-06 13:58:10 +01:00
|
|
|
e.clearSelection()
|
|
|
|
})
|
|
|
|
|
|
|
|
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv))
|
|
|
|
})
|