Final Fantasy Wiki
(+)
m (.)
Line 37: Line 37:
   
 
==Sign button==
 
==Sign button==
I wrote a function that automatically inserts four tildes into the page. It only work on Oasis:
+
I wrote a function that adds a button that automatically inserts four tildes into the page. It only work on Oasis:
 
<pre>function addSignButton()
 
<pre>function addSignButton()
 
{
 
{

Revision as of 16:11, 9 March 2013

FFWiki forum logo
Forums: Index > Rin's Travel Agency > Archive > Useful JS


Add edit links to WLH

I decided to write a JS script. The script adds an "(edit)" link next to all the links on WLH pages. Since the primary use of WLH is to fix links/transclusions to pages, I think this is helpful.

/* ---------------------------------Adds edit links to WLH page -- *
 * --------------------------------------------------------------- */
function addEditLinksToWLH() {
  if(wgCanonicalSpecialPageName=='Whatlinkshere')
  {
    var links = document.getElementById("mw-whatlinkshere-list").getElementsByTagName('li');
    for(var i = 0; i<links.length; i++)
    {
      aLink = links[i].getElementsByTagName('a');
      var linkHref = aLink[0].href+="?action=edit";
      var tools = getElementsByClassName(links[i], 'span', 'mw-whatlinkshere-tools');
      var editLinkSpan = document.createElement("span");
      editLinkSpan.className = "mw-whatlinkshere-edit";
      editLinkSpan.innerHTML = '<a title="Edit form" href="' + linkHref + '">(edit)</a> ';
      links[i].insertBefore(editLinkSpan,tools[0]);
    }
  }
}

addOnloadHook(addEditLinksToWLH);

I designed it for Oasis, but monobook's WLHs seem to work in the exact same way so I would find it odd if it didn't. And also I've only tested it on Firefox, so if you use it and it works on Firefox but not on another browser, let me know.

Also, if this is something we want implemented wiki-wide, then let me know also. JBed (talk) 12:51, March 9, 2013 (UTC)

So this is how you edit so fast... well, yeah, I would support putting this wiki-wide. C A T U S E 14:48, March 9, 2013 (UTC)
This actually isn't how I edit fast :p --I've yet to actually use this (or my

personal variation)-- I wrote it this morning. JBed (talk) 14:55, March 9, 2013 (UTC)

Installed across both skins, and confirmed working in Chrome and Firefox. JBed (talk) 16:04, March 9, 2013 (UTC)

Sign button

I wrote a function that adds a button that automatically inserts four tildes into the page. It only work on Oasis:

function addSignButton()
{
  if(wgAction=="edit")
  {
    var signButton = document.createElement("input");
    signButton.id = "wpSign";
    signButton.className = "control-button";
    signButton.value = "Sign";
    signButton.type = "button";
    signButton.name = "wpSign";
    signButton.addEventListener("click", function(){insertTags('~~' + '~~','','');return false;}, false);
    var buttonParent = getElementsByClassName(document, 'nav', 'buttons');
    saveButton = document.getElementById("wpSave");
    saveButton.style.width = "80px";
    signButton.style.width = "80px";
    signButton.style.marginLeft = "6px";
    buttonParent[0].insertBefore(signButton, saveButton);
  }
}
 
addOnloadHook(addSignButton);

It appears between Preview and Publish on the edit form. Of course, it's not that hard to sign with four tildes, however you can also modify the function to make it automatically insert a talkbox. I may look into dropdowns so you can have a list of automatically inserted functions. If you know what you are doing enough, you could potentially use it to store infoboxes or page structures and immediately insert them into the page, I suspect. I haven't looked into the syntax requirements much though. JBed (talk) 15:51, March 9, 2013 (UTC)