MediaWiki:Common.js

From Wikimedia District of Columbia
Revision as of 14:47, 26 May 2013 by James Hare (talk | contribs) (Smaller icons for membership buttons)
Jump to navigation Jump to search

Note: After saving, 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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Interface modifications for anonymous users */

function removeSidebarSection(section) {
  try {
    var target = "p-" + section;
    var sidebar = document.getElementById("mw-panel");
    var element = document.getElementById(target);
    sidebar.removeChild(element);
  } catch (e) {
    return;
   }
}

function customizeSidebarForAnon() {
  removeSidebarSection("tb");
}

function customizeTopbarForAnon() {
  mw.util.addPortletLink( 'p-personal', '/wiki/Membership', 'Join now', 'pt-join', 'Join Wikimedia DC and help support our mission!', 'j', '#pt-createaccount' );
}

if (wgUserName == null) {
  addOnloadHook(customizeSidebarForAnon);
  addOnloadHook(customizeTopbarForAnon);
}

/* Add a membership payment button */
if ( ( mw.config.get('wgPageName') == 'Membership' ) ) {
  $('#membershipbutton').html('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="R9RT2GWXZZWXL"><input type="hidden" name="on0" value="Donation Options"><input type="hidden" name="currency_code" value="USD"><div style="padding-bottom:0.3em;"><span style="padding-right:0.5em;"><input type="image" src="http://wikimediadc.org/w/images/thumb/3/38/Payment_button_-_10.png/75px-Payment_button_-_10.png" border="0" name="os0" value="Regular Membership" alt="Member dues: $10 per year"></span><span><input type="image" src="http://wikimediadc.org/w/images/thumb/9/99/Payment_button_-_25.png/75px-Payment_button_-_25.png" border="0" name="os0" value="Bronze Sponsor" alt="Member dues with Bronze Sponsorship: $25 per year"></span></div><div style="padding-bottom:0.3em;"><span style="padding-right:0.5em;"><input type="image" src="http://wikimediadc.org/w/images/thumb/e/ec/Payment_button_-_50.png/75px-Payment_button_-_50.png" border="0" name="os0" value="Silver Sponsor" alt="Member dues with Silver Sponsorship: $50 per year"></span><span><input type="image" src="http://wikimediadc.org/w/images/thumb/1/1d/Payment_button_-_100.png/75px-Payment_button_-_100.png" border="0" name="os0" value="Gold Sponsor" alt="Member dues with Gold Sponsorship: $100 per year"></span></div></form>');
}

/* Add a donate button */
if ( ( mw.config.get('wgPageName') == 'Donate' ) && ( wgNamespaceNumber == 0 ) ) {
  $('#donatebutton').html('<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="PSCZL9L3NKNRQ"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>');
}

/* Add a few links to the toolbox */
addOnloadHook(function() {
  mw.util.addPortletLink( 'p-tb', '/wiki/Internal:Dashboard', 'Dashboard', 't-dashboard', 'Dashboard ', 'r', '#t-whatlinkshere' );
  mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' );
  mw.util.addPortletLink( 'p-tb', '/wiki/Special:AllPages', 'All pages', 't-allpages', 'All pages ', 'p', '#t-recentchanges' );
});