Fixes #24 - Expose oneClickSelect

This commit is contained in:
2024-10-18 18:25:40 -04:00
parent f70d94ea67
commit 7dcc72d5a0
2 changed files with 67 additions and 34 deletions

View File

@@ -71,21 +71,21 @@ const showMessage = (m, s) => {
}, 1000);
}
const oneClickSelect = (e, t = e.currentTarget) => {
// In here, "this" is the element
var range, selection;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(t);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(t);
range.select();
}
}
// const oneClickSelect = (e, t = e.currentTarget) => {
// // In here, "this" is the element
// var range, selection;
// if (window.getSelection) {
// selection = window.getSelection();
// range = document.createRange();
// range.selectNodeContents(t);
// selection.removeAllRanges();
// selection.addRange(range);
// } else if (document.body.createTextRange) {
// range = document.body.createTextRange();
// range.moveToElementText(t);
// range.select();
// }
// }
const getURLVars = () => {
var oResult = {};
@@ -149,8 +149,23 @@ module.exports = {
module.exports.cookie.set(cname, "", -1);
},
},
oneClickSelect: (e, t = e.currentTarget) => {
// In here, "this" is the element
alert("here");
var range, selection;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(t);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(t);
range.select();
}
},
colour: {
copy: (w, t) => {
let c = t.parentNode.getAttribute("data-" + (w=="var" ? "token" : w));
c = w == "var" ? `var(${c})` : c;
@@ -255,7 +270,7 @@ module.exports = {
a.querySelectorAll("code").forEach((c)=> {
c.onclick = (e) => {
oneClickSelect(e);
module.exports.oneClickSelect(e);
}
})