User:Iritscen/vector-2022.js: Difference between revisions

From OniGalore
No edit summary
(moved to Common.js)
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
function getLang()
{
  if (navigator.languages !== undefined)
    return navigator.languages[0];
  return navigator.language;
}
function localizeDates()
{
  const lang = getLang();
  const root = document.querySelector(':root');
  if (root == undefined || lang == undefined)
    return;
  if (lang != "en-US") // LocaleDate prints dates in U.S.-style by default
  {
    alert("Re-ordering date.");
    root.style.setProperty('--month-order', '2');
    root.style.setProperty('--day-order', '1');
    root.style.setProperty('--month-before', '/');
    root.style.setProperty('--day-before', '');
  }
}
$(localizeDates);
mw.hook('wikiEditor.toolbarReady').add(function($textarea)
mw.hook('wikiEditor.toolbarReady').add(function($textarea)
{
{

Latest revision as of 21:58, 5 May 2025

mw.hook('wikiEditor.toolbarReady').add(function($textarea)
{
  $textarea.wikiEditor('addToToolbar',
    {section:'secondary',
    group:'default',
    tools:
    {
      smile:
      {
        label:'Smile!', // or use mw.message(key).escaped() for a localized label, see above
        type:'button',
        icon:'//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
        action:
        {
          type:'encapsulate',
          options:
          {
            pre:":)" // text to be inserted
          }
        }
      }
    }
  });
});