User:Koavf/common.js

From Wikisource
Jump to navigation Jump 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.
mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:Gadget-massdelete.js&action=raw&ctype=text/javascript')
$(document).ready ( function () {
  function findLij() {
    $.getJSON("https://lij.wikisource.org/w/api.php?callback=?", {
      action: 'query',
      prop: 'pageprops',
      format: 'json',
      titles: mw.config.get('wgPageName')
    }, function ( a ) {
      $.each( a.query.pages, function (k, v) {
        if ( k != -1 ) {
          $("#bodyContent").prepend('<div class="error" style="color:green;">This page exists in the Ligurian Wikisource. <a href="https://wikisource.org/w/index.php?title=' + encodeURI(mw.config.get("wgPageName")) + '&action=delete&wpReason=Moved+to+[[:lij:' + mw.config.get('wgPageName') + ']]">Delete now</a></div>');        } else {
        }
      });
    });
  }
  findLij();
});


//<nowiki>
/* Cat-a-lot - changes category of multiple files */
mw.loader.using(['jquery.ui', 'mediawiki.util'], function(){
	mw.loader.load('//commons.wikimedia.org/w/load.php?modules=ext.gadget.Cat-a-lot');
});
////////// Cat-a-lot user preferences //////////
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":true,"docleanup":false,"subcatcount":10};
////////////////////////////////////catALotEnd//
//</nowiki>
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:GoogleOCR.js&action=raw&ctype=text/javascript');

$(document).ready ( function () {
  function replaceNumerals(digits) {
  	var conversionTable = {
	    "0": "०",
	    "1": "१",
	    "2": "२",
	    "3": "३",
	    "4": "४",
	    "5": "५",
	    "6": "६",
	    "7": "७",
	    "8": "८",
	    "9": "९"
    };
    var indicDigits ="";
    digits.split("").forEach(function(dig) {
    	indicDigits += conversionTable[dig];
    });
    return indicDigits;
  }
  var title = mw.config.get('wgPageName');
  if (title.startsWith("Page:")) {
  	var match = title.match(/\/\d+$/).toString().substring(1);
  	title = title.replace("/" + match, "/" + replaceNumerals(match));
  }
  function findNap() {
    $.getJSON("https://hi.wikisource.org/w/api.php?callback=?", {
      action: 'query',
      prop: 'pageprops',
      format: 'json',
      titles: mw.config.get('wgPageName') + '|' + title
    }, function ( a ) {
      $.each( a.query.pages, function (k, v) {
        if ( k != -1 ) {
        	window.location.replace("https://wikisource.org/w/index.php?title=" + encodeURI(mw.config.get("wgPageName")) + "&action=delete&wpReason=Moved+to+[[:hi:" + title + "]]");
        } else {
        	$("#bodyContent").prepend("<div class='error'><big>This page doesn't exist in the Hindi Wikisource yet!</big></div>");
        }
      });
    });
  }
  if (mw.config.get("wgRevisionId") !== 0 && mw.config.get("wgCategories").includes("हिन्दी")) {
	  findNap();
  }
  $("#wpConfirmB").click();
  $.getJSON("https://wikisource.org/w/api.php?callback=?", {
  	action: 'query',
  	list: 'logevents',
  	letype: 'delete',
  	format: 'json',
  	letitle: mw.config.get("wgPageName")
  }, function ( b ) {
  	$.each( b.query.logevents, function ( k, v ) {
  		if (mw.config.get("wgNamespaceNumber") == 104) {
	  		var newtitle = mw.config.get("wgPageName");
	  		var match2 = parseInt(newtitle.match(/\/\d+$/).toString().substring(1));
	  		var match3 = match2+1;
	  		newtitle = newtitle.replace("/" + match2.toString(), "/" + match3.toString());
	  		window.location.replace("https://wikisource.org/w/index.php?title=" + encodeURI(newtitle));
  		}
  	});
  });
});