User:Xenwolf/vector.js

From Xenharmonic Wiki
Revision as of 13:35, 31 May 2020 by Xenwolf (talk | contribs) (testing...)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
function format_words(title, numWords){
  console.log("format_words [enter]");
  const text = title+" ("+numWords+" words)";
  console.log("format_words: text:"+text);
  return text;
}

$(document).ready(function(){
  console.log("on ready [enter]");
  const numWords = $("#mw-content-text > div").text().split(" ").length;
  const header = $("#firstHeading").text();
  $("#firstHeading").text(format_words(header, numWords));
  $("#toolbar").add('<div title="smile" id="user-button-smile" class="mw-toolbar-editbutton">"&#x1F642;"</div>');
  console.log("on ready [leave]");
});