User:Killer9000/common.js: Difference between revisions

From wowdev
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
var elms = document.querySelectorAll("*[style]");
var elms = document.querySelectorAll("*[style]");
Array.prototype.forEach.call(elms, function(elm) {
Array.prototype.forEach.call(elms, function(elm) {
   var clr = elm.style.background|| "";
   if (elm.style.background)
  // Remove all whitespace, make it all lower case
  clr = clr.replace(/\s/g, "").toLowerCase();
  console.log("- " + elm.style.background);
  switch (clr)
   {
   {
  case "#eee":
    console.log("- " + elm.style.background);
  case "rgb(238, 238, 238)":
     elm.style.background.color = "#00000000";
     elm.style.background.color = "rgb(22, 22, 22)";
     console.log("- " + elm.style.background);
     console.log("-- " + elm.style.background);
    break;
   }
   }
}); 
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;
    }
  });
});
});

Revision as of 22:34, 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.color = "#00000000";
    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;
    }
  });
});