User:Equazcion/LiveDiffLink.js

if (mw.config.get('wgAction') == 'history') { // Don't do anything unless we're on a History page. // Grab the Compare buttons, creat…

if (mw.config.get('wgAction') == 'history') {   // Don't do anything unless we're on a History page.

// Grab the Compare buttons, create an empty link after each, and grab the empty links
   var submitButton = $('.historysubmit:submit');
   submitButton.after("<a class='diffURL' style='border:#999 1px dashed; padding:2px 4px 2px 4px;'></a>");
   var displayDiffField = $('.diffURL');

// Grab the initial revision selections
   var displayDiffNew = $('[name="diff"]:checked').slice(0,1).attr('value');
   var displayDiffOld = $('[name="oldid"]:checked').slice(0,1).attr('value');

// Set the initial main diff link URL, text, & tooltip, add arrow between Compare button and link
   displayDiffField.text("http://en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&diff=" + displayDiffNew + "&oldid=" + displayDiffOld);
   displayDiffField.attr("href", "http://en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&diff=" + displayDiffNew + "&oldid=" + displayDiffOld);
   displayDiffField.attr('title', 'http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld);
   displayDiffField.before("<b> → </b>");

// Grab initial revision size fields
   var displayDiffSizeNew = $('[name="diff"]:checked').slice(0,1).parent('li').find('.history-size');
   var displayDiffSizeOld = $('[name="oldid"]:checked').slice(0,1).parent('li').find('.history-size');

// Add diff link before initial revision sizes. Using a link contained in a <span> allows us to refer back to the entire added text using its class.
   var displayDiffMobileNew = displayDiffSizeNew.before('<span class="historyDiffLink">(<a href="http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + 
                              '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld + '">DIFF</a>‎) . . </span>');
   var displayDiffMobileOld = displayDiffSizeOld.before('<span class="historyDiffLink">(<a href="http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + 
                              '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld + '">DIFF</a>‎) . . </span>');

// Set tooltip for the size diff link
   $('.historyDiffLink').find('a').attr('title', 'http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld);

// Set the Click event function for radio buttons
   $(":radio").click(function(){   

   // Clear existing revision size links
      $('.historyDiffLink').remove();

   // Grab the revision selection, place in appropriate var
      if ($(this).attr('name') == 'oldid') displayDiffOld = $(this).attr('value');
      if ($(this).attr('name') == 'diff') displayDiffNew = $(this).attr('value');

   // Update the main diff link URL, text, & tooltip
      displayDiffField.attr("href", "http://en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&diff=" + displayDiffNew + "&oldid=" + displayDiffOld);
      displayDiffField.text("http://en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&diff=" + displayDiffNew + "&oldid=" + displayDiffOld);
      displayDiffField.attr('title', 'http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld);

   // Grab new revision size fields
      displayDiffSizeNew = $('[name="diff"]:checked').slice(0,1).parent('li').find('.history-size');
      displayDiffSizeOld = $('[name="oldid"]:checked').slice(0,1).parent('li').find('.history-size');

   // Add diff link before revision sizes
      var displayDiffMobileNew = displayDiffSizeNew.before('<span class="historyDiffLink">(<a href="http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + 
                              '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld + '">DIFF</a>)‎ . . </span>');
      var displayDiffMobileOld = displayDiffSizeOld.before('<span class="historyDiffLink">(<a href="http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + 
                              '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld + '">DIFF</a>) . . </span>');

   // Set tooltip for the size diff link
      $('.historyDiffLink').find('a').attr('title', 'http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgPageName') + '&diff=' + displayDiffNew + '&oldid=' + displayDiffOld);

   });

}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.