User:INoMed/common.js

From SmashWiki, the Super Smash Bros. wiki
< User:INoMed
Revision as of 09:19, November 27, 2015 by INoMed (talk | contribs)
Jump to navigationJump 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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Text replacement
$( '#siteSub' ).text( 'SmashWiki, skinned by INoMeds CSS' );
$( '#ca-history a' ).text( 'Page history' );
$( '#ca-nstab-user a' ).text( 'Userspace' );
$( '#ca-talk a' ).text( 'Talk page' );
$( '#ca-view a' ).text( 'View' );
$( function () {
    var tab, tablink;

    tab = document.getElementById('ca-addsection');
    if ( !tab ) {
        return;
    }

    tablink = tab.getElementsByTagName('a')[0];
    if ( !tablink ) {
        return;
    }

    tablink.firstChild.nodeValue = 'New topic';
    if ( mw.config.get( 'skin' ) === 'monobook' ) {
      tablink.style.paddingLeft = ".4em";
      tablink.style.paddingRight = ".4em";
    }
});
mw.loader.load( '//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript' );
$.fx.off = true;
var CommentsInLocalTime, runScript;

CommentsInLocalTime = (function() {
  var LocalComments, language;

  function CommentsInLocalTime() {}

  language = '';

  LocalComments = {};

  CommentsInLocalTime.settings = function() {
    if (window.LocalComments != null) {
      LocalComments = window.LocalComments;
    }

    /*
      Language
    
      LOCALIZING THIS SCRIPT
      To localize this script, change the terms below,
      to the RIGHT of the colons, to the correct term used in that language.
    
      For example, in the French language,
    
      'Today' : 'Today',
    
      would be
    
      'Today' : "Aujourd'hui",
     */
    return LocalComments.language = {

      /* relative terms */
      'Today': 'Today',
      'Yesterday': 'Yesterday',
      'Tomorrow': 'Tomorrow',
      'last': 'last',
      'this': 'this',

      /* days of the week */
      'Sunday': 'Sunday',
      'Monday': 'Monday',
      'Tuesday': 'Tuesday',
      'Wednesday': 'Wednesday',
      'Thursday': 'Thursday',
      'Friday': 'Friday',
      'Saturday': 'Saturday',

      /* months of the year */
      'January': 'January',
      'February': 'February',
      'March': 'March',
      'April': 'April',
      'May': 'May',
      'June': 'June',
      'July': 'July',
      'August': 'August',
      'September': 'September',
      'October': 'October',
      'November': 'November',
      'December': 'December',

      /* difference words */
      'ago': 'ago',
      'from now': 'from now',

      /* date phrases */
      'year': 'year',
      'years': 'years',
      'month': 'month',
      'months': 'months',
      'day': 'day',
      'days': 'days'
    };
  };


  /*
    APPLICATION
   */

  CommentsInLocalTime.init = function() {

    /*
      Settings
     */
    var contentText, namespace, pageAction;
    this.settings();
    if (LocalComments.language == null) {
      return false;
    }
    language = this.setDefaultSetting('language', LocalComments.language);
    this.setDefaultSetting({
      'dateDifference': true,
      'dateFormat': 'dmy',
      'dayOfWeek': true,
      'dropDays': 0,
      'dropMonths': 0,
      'timeFirst': true,
      'twentyFourHours': false
    });

    /*
      End Settings
     */
    namespace = mw.config.get('wgCanonicalNamespace');
    pageAction = mw.config.get('wgAction');
    if (['', 'MediaWiki', 'Special'].indexOf(namespace) > -1 || pageAction === 'history') {
      return false;
    }
    contentText = document.getElementById('mw-content-text');
    if (mw.config.get('wgAction') !== 'view' || (contentText == null)) {
      return false;
    }
    return this.replaceText(contentText, /(\d{1,2}):(\d{2}), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/);
  };

  CommentsInLocalTime.replaceText = function(node, search) {
    var after, afterMatch, before, beforeMatch, child, children, length, match, matches, parent, parentNodeName, position, span, timeArray, timestamp, value, _i, _len, _results;
    if (!node) {
      return false;
    }
    if (node.nodeType === 3) {
      parent = node.parentNode;
      parentNodeName = parent.nodeName;
      if (['CODE', 'PRE'].indexOf(parentNodeName) > -1) {
        return false;
      }
      value = node.nodeValue;
      matches = value.match(search);
      if (matches != null) {
        match = matches[0];
        position = value.search(search);
        length = match.toString().length;
        beforeMatch = value.substring(0, position);
        afterMatch = value.substring(position + length);
        timeArray = this.adjustTime(match.toString(), search);
        timestamp = timeArray[1] ? timeArray[1].getTime() : '';
        span = document.createElement('span');
        span.className = 'localcomments';
        span.style.fontSize = '95%';
        span.style.whiteSpace = 'nowrap';
        span.setAttribute('timestamp', timestamp);
        span.title = match;
        span.appendChild(document.createTextNode(timeArray[0]));
        parent = node.parentNode;
        parent.replaceChild(span, node);
        before = document.createElement('span');
        before.className = 'before-localcomments';
        before.appendChild(document.createTextNode(beforeMatch));
        after = document.createElement('span');
        after.className = 'after-localcomments';
        after.appendChild(document.createTextNode(afterMatch));
        parent.insertBefore(before, span);
        return parent.insertBefore(after, span.nextSibling);
      }
    } else {
      children = [];
      child = node.childNodes[0];
      while (child) {
        children.push(child);
        child = child.nextSibling;
      }
      _results = [];
      for (_i = 0, _len = children.length; _i < _len; _i++) {
        child = children[_i];
        _results.push(this.replaceText(child, search));
      }
      return _results;
    }
  };

  CommentsInLocalTime.adjustTime = function(originalTimestamp, search) {
    var ampm, date, day, dayNames, dayOfTheWeek, descriptiveDifference, finalTime, formattedDate, formattedDayOfTheWeek, hour, last, minute, month, monthName, oldDay, oldHour, oldMinute, oldMonth, oldYear, returnDate, time, today, tomorrow, utcOffset, year, yesterday, _ref, _ref1;
    time = originalTimestamp.match(search);
    _ref = [time[1], time[2], time[3], time[4], time[5]], oldHour = _ref[0], oldMinute = _ref[1], oldDay = _ref[2], oldMonth = _ref[3], oldYear = _ref[4];
    today = new Date();
    yesterday = new Date();
    tomorrow = new Date();
    yesterday.setDate(yesterday.getDate() - 1);
    tomorrow.setDate(tomorrow.getDate() + 1);
    time = new Date();
    time.setUTCFullYear(oldYear, this.convertMonthToNumber(oldMonth), oldDay);
    time.setUTCHours(oldHour);
    time.setUTCMinutes(oldMinute);
    if (isNaN(time)) {
      return [originalTimestamp, ''];
    }
    utcOffset = -1 * time.getTimezoneOffset() / 60;
    utcOffset = utcOffset >= 0 ? '+' + utcOffset : '−' + Math.abs(utcOffset);
    year = time.getFullYear();
    month = this.addLeadingZero(time.getMonth() + 1);
    day = time.getDate();
    hour = parseInt(time.getHours());
    minute = this.addLeadingZero(time.getMinutes());
    ampm = '';
    if (LocalComments.twentyFourHours) {
      hour = this.addLeadingZero(hour);
    } else {
      ampm = hour <= 11 ? ' am' : ' pm';
      if (hour > 12) {
        hour -= 12;
      } else if (hour === 0) {
        hour = 12;
      }
    }
    if (year === today.getFullYear() && month === this.addLeadingZero(today.getMonth() + 1) && day === today.getDate()) {
      date = language['Today'];
    } else if (year === yesterday.getFullYear() && month === this.addLeadingZero(yesterday.getMonth() + 1) && day === yesterday.getDate()) {
      date = language['Yesterday'];
    } else if (year === tomorrow.getFullYear() && month === this.addLeadingZero(tomorrow.getMonth() + 1) && day === tomorrow.getDate()) {
      date = language['Tomorrow'];
    } else {
      dayNames = [language['Sunday'], language['Monday'], language['Tuesday'], language['Wednesday'], language['Thursday'], language['Friday'], language['Saturday']];
      dayOfTheWeek = dayNames[time.getDay()];
      descriptiveDifference = '';
      last = '';
      if (LocalComments.dateDifference) {
        _ref1 = this.createRelativeDate(today, time), descriptiveDifference = _ref1.descriptiveDifference, last = _ref1.last;
      }
      formattedDate = '';
      monthName = this.convertNumberToMonth(time.getMonth());
      formattedDate = (function() {
        switch (LocalComments.dateFormat.toLowerCase()) {
          case 'dmy':
            return day + ' ' + monthName + ' ' + year;
          case 'mdy':
            return monthName + ' ' + day + ', ' + year;
          default:
            return year + '-' + month + '-' + this.addLeadingZero(day);
        }
      }).call(this);
      formattedDayOfTheWeek = '';
      if (LocalComments.dayOfWeek) {
        formattedDayOfTheWeek = ', ' + last + dayOfTheWeek;
      }
      date = formattedDate + formattedDayOfTheWeek + descriptiveDifference;
    }
    finalTime = hour + ':' + minute + ampm;
    if (LocalComments.timeFirst) {
      returnDate = finalTime + ', ' + date + ' (UTC' + utcOffset + ')';
    } else {
      returnDate = date + ', ' + finalTime + ' (UTC' + utcOffset + ')';
    }
    return [returnDate, time];
  };

  CommentsInLocalTime.createRelativeDate = function(today, time) {
    var daysAgo, descriptiveParts, differenceWord, fmtDays, fmtMonths, fmtYears, last, millisecondsAgo, monthsAgo, totalMonthsAgo, yearsAgo;
    millisecondsAgo = today.getTime() - time.getTime();
    daysAgo = Math.abs(Math.round(millisecondsAgo / 1000 / 60 / 60 / 24));
    differenceWord = '';
    last = '';
    if (millisecondsAgo >= 0) {
      differenceWord = language['ago'];
      if (daysAgo <= 7) {
        last = language['last'] + ' ';
      }
    } else {
      differenceWord = language['from now'];
      if (daysAgo <= 7) {
        last = language['this'] + ' ';
      }
    }
    monthsAgo = Math.floor(daysAgo / 365 * 12);
    totalMonthsAgo = monthsAgo;
    yearsAgo = Math.floor(monthsAgo / 12);
    if (monthsAgo < LocalComments.dropMonths) {
      yearsAgo = 0;
    } else if (LocalComments.dropMonths > 0) {
      monthsAgo = 0;
    } else {
      monthsAgo = monthsAgo - yearsAgo * 12;
    }
    if (daysAgo < LocalComments.dropDays) {
      monthsAgo = 0;
      yearsAgo = 0;
    } else if (LocalComments.dropDays > 0) {
      daysAgo = 0;
    } else {
      daysAgo = daysAgo - Math.floor(totalMonthsAgo * 365 / 12);
    }
    descriptiveParts = [];
    if (yearsAgo > 0) {
      fmtYears = yearsAgo + ' ' + this.pluralize(language['year'], yearsAgo, language['years']);
      descriptiveParts.push(fmtYears);
    }
    if (monthsAgo > 0) {
      fmtMonths = monthsAgo + ' ' + this.pluralize(language['month'], monthsAgo, language['months']);
      descriptiveParts.push(fmtMonths);
    }
    if (daysAgo > 0) {
      fmtDays = daysAgo + ' ' + this.pluralize(language['day'], daysAgo, language['days']);
      descriptiveParts.push(fmtDays);
    }
    return {
      descriptiveDifference: ' (' + descriptiveParts.join(', ') + ' ' + differenceWord + ')',
      last: last
    };
  };


  /*
    HELPERS
   */

  CommentsInLocalTime.addLeadingZero = function(number) {
    if (number < 10) {
      number = '0' + number;
    }
    return number;
  };

  CommentsInLocalTime.convertMonthToNumber = function(month) {
    return (new Date(month + ' 1, 2001')).getMonth();
  };

  CommentsInLocalTime.convertNumberToMonth = function(number) {
    return [language['January'], language['February'], language['March'], language['April'], language['May'], language['June'], language['July'], language['August'], language['September'], language['October'], language['November'], language['December']][number];
  };

  CommentsInLocalTime.pluralize = function(term, count, plural) {
    if (plural === null) {
      plural = term + 's';
    }
    if (count === 1) {
      return term;
    } else {
      return plural;
    }
  };

  CommentsInLocalTime.setDefaultSetting = function() {
    var defaultSetting, name, settings;
    if (!arguments.length) {
      return false;
    }
    if (typeof arguments[0] === 'object') {
      settings = arguments[0];
      for (name in settings) {
        defaultSetting = settings[name];
        if (LocalComments[name] == null) {
          LocalComments[name] = defaultSetting;
        }
      }
      return settings;
    } else if (typeof arguments[0] === 'string') {
      name = arguments[0];
      defaultSetting = arguments[1];
      if (LocalComments[name] == null) {
        LocalComments[name] = defaultSetting;
      }
      return LocalComments[name];
    }
  };

  return CommentsInLocalTime;

})();

runScript = function() {
  return $(window).load(function() {
    if (window.location.href.indexOf('&disable=loco') === -1) {
      return CommentsInLocalTime.init();
    }
  });
};

if (typeof waitForScripts === 'function') {
  waitForScripts(runScript);
} else {
  runScript();
};
// <source lang="javascript">
// License: PD
// rollback "in place", using API
"use strict";
if (
	mw.config.get( 'wgAction' ) === 'history'
	|| ( $.inArray( mw.config.get( 'wgCanonicalSpecialPageName' ), ['Recentchanges', 'Watchlist', 'Contributions'] ) + 1 )
	|| mw.util.getParamValue( 'diff' )
	)
mw.loader.using( [ 'jquery.ui.dialog', 'jquery.jStorage', 'mediawiki.api', 'mediawiki.user' ], function() { $(function() {
	var	summaryStorageKey = 'rollback summary',
		userTalkStorageKey = 'rollback user talk message',
		historyDepth = 20,
		api = new mw.Api(),
		onRollbackClick = function(e) {
			var $this = $(this),
				href = $this.attr( 'href' ),
				token = decodeURIComponent( href.replace( /.*[&\?]token=/, '' ).replace( /&.*/, '' ) ),
				title = decodeURIComponent( href.replace( /.*[&\?]title=/, '' ).replace( /&.*/, '' ).replace(/_/g, ' ') ),
				from = decodeURIComponent( href.replace( /.*[&\?]from=/, '' ).replace( /&.*/, '' ).replace( /\+/g, ' ' ) ),
				talkPageMessage,
				rbParams = { action: 'rollback', token: token, title: title, user: from },
				replaceTokens = function( str ) {
					return str.replace( /\$1/g, title ).replace( /\$2/g, from ).replace( /\$3/g, $this.text() );
				},
				rollback = function( watchArticle, watchTalk ) {
					if ( watchArticle )
						rbParams.watchlist = 'watch';
					api.post( rbParams, function() {
						var match = $this.text().match( /:(.*)/ ),
							edits = ( match && match.length > 1 ) ? match[1] : $this.text(),
							userLink = $this.closest('span').parent().find( '.mw-usertoollinks' ),
							talkPageLink = $this.closest( 'span' ).parent()
								.find( '.mw-usertoollinks a' )
								.filter( function() { return $( this ).text() == "Talk" } ),
							talkHref = talkPageLink.attr( 'href' ),
							vanarticle = 'vanarticle=' + mw.util.rawurlencode( title );

						talkPageLink
							.attr( 'href',  talkHref + ( /\?/.test( talkHref ) ? '&' : '?' ) + vanarticle )
							.css( 'font-weight', 'bold' );

						mw.util.jsMessage( i18n( 'success', edits, from ) );
						$this.remove();
						if ( talkPageMessage )
							api.post(
								{ action: 'edit',
									token: mw.user.tokens.get( 'editToken' ),
									appendtext: talkPageMessage,
									title: i18n('user talk', from),
									summary: replaceTokens( talkPageSummaryInputbox.val() ),
									watchlist: watchTalk ? 'watch' : 'preferences'
								},
								function() { mw.util.jsMessage( i18n( 'talk success', talkPageMessage, from ) ); }
							);
					} );
				};

			e.preventDefault();

			if ( e.type == 'click' ) // left click
				rollback( mw.config.get( 'watchOnRollback' ) );
			else { // right click.
				var dialog,
					summary,
					summaries = $.jStorage.get( summaryStorageKey ) || [],
					talkPageMessages = $.jStorage.get( userTalkStorageKey ) || {},
					summaryInputbox = $( '<input>', { width: '40em' } ),
					summarySelector = $( '<select>' ).append( $( '<option>' ) ).change( function() { summaryInputbox.val( this.value ); } ),
					watchArticleCheckbox = $( '<input>', { type: 'checkbox' } ).prop( 'checked', mw.config.get( 'watchOnRollback' ) ),
					talkPageInputbox = $( '<input>', { width: '40em' } ),
					talkPageTextbox = $( '<textarea>', { rows: 5 } ),
					talkPageSummaryInputbox = $( '<input>', { width: '40em' } ),
					talkPageSelector = $( '<select>' ).change( function() {
						talkPageInputbox.val( this.value );
						talkPageTextbox.val( talkPageMessages[this.value].m || '' );
						talkPageSummaryInputbox.val( talkPageMessages[this.value].s || '' );
						
					} ),
					watchTalkpageCheckbox = $( '<input>', { type: 'checkbox' }).prop( 'checked', mw.config.get( 'watchTalkpageOnRollbackMessage' ) ),
					prepareTalkpageSelector = function() {
						talkPageSelector.find( '*' ).remove();
						talkPageSelector.append( $( '<option>' ) );
						for ( var talkMessageName in talkPageMessages ) {
							var option = $( '<option>', { value: talkMessageName, text: talkMessageName} );
							if ( /^=/.test( talkMessageName ) )
								option.attr( 'disabled', 'diabled' );
							talkPageSelector.append( option );
						}
						talkPageInputbox.val( '' );
						talkPageTextbox.val( '' );
					};
				
				$( summaries ).each( function( index, item ) { summarySelector.append( $( '<option>', { value: item, text: item } ) ); } );
				prepareTalkpageSelector();
				dialog = $( '<div>' ).dialog( {
					title: i18n( 'dialogtitle' ),
					modal: true,
					buttons: [
						{ text: i18n('ok'), click: function() {
							summary = $.trim( summaryInputbox.val() );
							talkPageMessage = $.trim( talkPageTextbox.val() );
							if ( !summary && !talkPageMessage )
								return;
							if ( summary ) {
								var old = $.inArray( summary, summaries );
								if ( old + 1 )
									summaries.splice( old, 1 );
								summaries.splice( 1, 0, summary );
								if ( summaries.length > 20 )
									summaries.pop();
								$.jStorage.set( summaryStorageKey, summaries );
								rbParams.summary = replaceTokens( summary );
							}
							var talkPageMessageName = $.trim( talkPageInputbox.val() ),
								talkPageSummary = $.trim( talkPageSummaryInputbox.val() );
							if ( talkPageMessageName ) {
								if ( talkPageMessage ) {
									talkPageMessages[ talkPageMessageName ] = { m: talkPageMessage, s: talkPageSummary };
								} else
									delete talkPageMessages[ talkPageMessageName ];
								$.jStorage.set( userTalkStorageKey, talkPageMessages );
							}
							if ( talkPageMessage )
								talkPageMessage = '\n' + replaceTokens( talkPageMessage );
							rollback( watchArticleCheckbox.prop( 'checked' ), watchTalkpageCheckbox.prop( 'checked' ) );
							$(this).dialog( 'close' );
						} },
						{ text: i18n( 'read boilerplate button' ), click: function() {
							var source = prompt( i18n( 'enter boilerplate source' ), i18n( 'default boilerplate page') );
							if ( source ) {
								$.ajax( {
									url: mw.util.wikiScript(),
									cache: false,
									data: {title: source, action: 'raw', ctype: 'text/x-wiki'},
									success: function( data ) {
										try {
											eval( 'talkPageMessages = ' + data );
											prepareTalkpageSelector();
											$.jStorage.set( userTalkStorageKey, talkPageMessages );
										} catch(e) {
											alert( i18n( 'exception reading boilerplates', source, e ) );
										}
									}
								} );
							}
						} },
						{ text: i18n( 'cancel' ), click: function() { $( this ).dialog( 'close' ); } }
					]
				} )
					.append( $( '<p>' ).html( i18n( 'description', title, from, $this.text() ) ) )
					.append( $( '<table>' )
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'summary' ) } ) )
							.append( summaryInputbox )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'summaryhist' ) } ) )
							.append( summarySelector )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'watch article', title ) } ) )
							.append( watchArticleCheckbox )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'talkpagename' ) } ) )
							.append( talkPageInputbox )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'talkpagemessage', from ) } ) )
							.append( talkPageTextbox )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'talkpagesummary', from ) } ) )
							.append( talkPageSummaryInputbox )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', {text: i18n( 'talkpagemessagehist' ) } ) )
							.append( talkPageSelector )
						)
						.append( $( '<tr>' )
							.append( $( '<td>', { text: i18n( 'watch talkpage', from ) } ) )
							.append( watchTalkpageCheckbox )
						)
					);
				dialog.dialog( 'option', { width: 'auto', height: 'auto' } );
				dialog.dialog( 'option', { position: { my: 'center', at: 'center', of: window } } );
				dialog.dialog( 'option', { width: '100', height: '100' } ); // this perversion is for rtl: we need to force a redraw.
				dialog.dialog( 'option', { width: 'auto', height: 'auto' } );
				dialog.dialog( 'option', { position: { my: 'center', at: 'center', of: window } } ); // ditto.
			} // e.type == contextmenu
		}, // onRollbackClick

		i18n = function () {
			var str = arguments[0];
			switch ( mw.config.get( 'wgUserLanguage' ) ) {
				case 'he':
					switch ( str ) {
						case 'description':
							str = 'ניתן (אין חובה) להזין תקציר עריכה לשחזור, ו/או הודעה שתישמר בדף השיחה של %2.<br />'
								+ '$1 יוחלף בשם הדף (%1),<br />'
								+ '$2 יוחלף בשם המשתמש (%2)<br />'
								+ '$3 יוחלף בכותרת הקישור (%3)'

							break;
						case 'dialogtitle':
							return 'שחזור עריכה';
						case 'success':
							str = '%1 של %2 בוצע';
							break;
						case 'ok':
							return 'אישור';
						case 'cancel':
							return 'ביטול';
						case 'rightclick':
							return 'לחיצה בכפתור ימני מאפשרת להוסיף תקציר.'
						case 'summary':
							return 'תקציר עריכה:';
						case 'summaryhist':
							return 'תקצירים קודמים:';
						case 'talkpagename':
							return 'שם ההודעה בדף שיחה:';
						case 'talkpagemessagehist':
							return 'הודעות דף שיחה קודמות:';
						case 'talkpagemessage':
							str = 'הודעה לדף השיחה של %1:';
							break;
						case 'read boilerplate button':
							return 'קריאת ההודעות מדף';
						case 'enter boilerplate source':
							return 'הזינו את שם הדף בו נמצאות ההודעות המוכנות';
						case 'default boilerplate page':
							return 'משתמש:Neukoln/msgs.js';
						case 'exception reading boilerplates':
							str = 'שגיאה בניסיון לקריאת תבניות מדף "%1". השגיאה היא: %2';
							break;
						case 'watch article':
							str = 'הוסף את הדף %1 לרשימת המעקב';
							break;
						case 'watch talkpage':
							str = 'הוסף את דף השיחה של משתמש:%1 לרשימת המעקב';
							break;
						case 'user talk':
							str = 'שיחת משתמש:%1';
							break;
						case 'talkpagesummary':
							return  'תקציר להודעה בשיחת משתמש';
						case 'talk success':
							str = 'ההודעה:<br />%1<br />נשמרה בהצלחה בדף "שיחת משתמש:%2"';
							break;
					}
					break;
				default:
					switch ( str ) {
						case 'description':
							str = 'You can enter a summary for the rollback instead of the default, '
								+ 'and an optional message to be added to %2 talk page<br />'
								+ '$1 will be replaced by page name (%1),<br />'
								+ '$2 will be replaced by user name (%2),<br />'
								+ '$3 will be replaced by rollover text (%3).';
							break;
						case 'dialogtitle' :
							return 'Rollback summary';
						case 'success':
							str = 'Successfully rolled back %1 by %2';
							break;
						case 'ok':
							return 'OK';
						case 'cancel':
							return 'Cancel';
						case 'rightclick':
							return 'Use right mouse button to add summary.'
						case 'summary':
							return 'Summary:';
						case 'summaryhist':
							return 'Summary history:';
						case 'talkpagename':
							return 'Talk page message name:';
						case 'talkpagemessagehist':
							return 'Talk page message name history:';
						case 'talkpagemessage':
							return 'Talk page message:';
						case 'talk success':
							str = 'Message %1 was successfuly saved in %2 talkpage';
							break;
						case 'read boilerplate button':
							return 'Read messages';
						case 'enter boilerplate source':
							return 'Please enter page name from which to read boilerplate messages';
						case 'default boilerplate page':
							return '';
						case 'exception reading boilerplates':
							str = 'Exception trying to interpret Page "%1". Exception is: %2';
							break;
						case 'watch article':
							str = 'Add page "%1" to your watchlist';
							break;
						case 'watch talkpage':
							str = 'Add "User talk:%1" to your watchlist';
							break;
						case 'user talk':
							str = 'User talk:%1';
							break;
						case 'talkpagesummary':
							return 'Summary for talk page message';
						case 'talk success':
							str = 'Successfuly added<br />%1<br />To page User talk:%2';
							break;
					}
					break;
			}
			for ( var arg = 1; arg < arguments.length; arg++ )
				str = str.replace( new RegExp( '%' + arg, 'g' ), arguments[ arg ] );
			return str;
		};

	$( 'a[href *= "action=rollback"]' ).on( 'click contextmenu', onRollbackClick );
	var tries = 0,
		timer = setInterval( function() {
			if ( window.removeTooltip ) {
				$( 'a[href *= "action=rollback"]' ).each( function() {
					window.removeTooltip( this );
					this.title += " \n" + i18n( 'rightclick' );
				})
				clearInterval( timer );
			} else if ( tries++ > 30 )
				clearInterval( timer );
		}, 100 );
} ); // document ready
} ); // using </source>