User:Killer9000/common.js: Difference between revisions
Jump to navigation
Jump to search
Killer9000 (talk | contribs) No edit summary |
Killer9000 (talk | contribs) No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
{ | { | ||
console.log("- " + elm.style.background); | console.log("- " + elm.style.background); | ||
elm.style.background | elm.style.background = "rgba(0,0,0,0)"; | ||
console.log("- " + elm.style.background); | console.log("- " + elm.style.background); | ||
} | } |
Latest revision as of 22:35, 14 May 2022
var elms = document.querySelectorAll("*[style]");
Array.prototype.forEach.call(elms, function(elm) {
if (elm.style.background)
{
console.log("- " + elm.style.background);
elm.style.background = "rgba(0,0,0,0)";
console.log("- " + elm.style.background);
}
});
var elms = document.querySelectorAll("textarea");
Array.prototype.forEach.call(elms, function(elm) {
elm.addEventListener('keydown', function(e) {
if (e.key == 'Tab') {
e.preventDefault();
var start = this.selectionStart;
var end = this.selectionEnd;
// set textarea value to: text before caret + tab + text after caret
this.value = this.value.substring(0, start) +
"\t" + this.value.substring(end);
// put caret at right position again
this.selectionStart =
this.selectionEnd = start + 1;
}
});
});