_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:BrandonXLF/SubpageMover.js

In article User:BrandonXLF/SubpageMover.js we are going to delve into a topic that concerns us all in one way or another. Regardless of our age, profession or personal interests, this topic is relevant to everyone. Along these lines we will explore different aspects, data and opinions related to User:BrandonXLF/SubpageMover.js, with the aim of providing a broad and complete vision of the subject. Whether we are familiar with User:BrandonXLF/SubpageMover.js or it is the first time we are hearing about it, this article invites us to reflect, learn and question our own understanding of User:BrandonXLF/SubpageMover.js.
/*** Subpage Mover ***/

// Easily move the subpages of a page with a single click
// Documentation at ]
// By ]

$(function() {
	function Log() {
		$('#moveSubpages-log').remove();

		this.el = $('<div>')
			.appendTo($('#movepage'))
			.append('<br><hr>')
			.attr('id', 'moveSubpages-log');
	}

	Log.prototype.log = function(html, color) {
		this.el.append($('<p>').append(html).css('color', color));
	};

	Log.prototype.createLink = function(page) {
		return $('<a>').attr('href', mw.util.getUrl(page)).text(page);
	};

	Log.prototype.logError = function(html) {
		this.log(html, '#d33');
	};

	Log.prototype.logSuccess = function(html) {
		this.log(html, '#14866d');
	};

	Log.prototype.logMoveError = function(from, to, reasonHtml) {
		this.logError();
	};

	Log.prototype.logMoveSuccess = function(from, to) {
		this.logSuccess();
	};

	function movePage(from, to, params, log, onSuccess) {
		$.post(mw.config.get('wgScriptPath') + '/api.php', $.extend({
			action: 'move',
			from: from,
			to: to,
			token: mw.user.tokens.get('csrfToken'),
			format: 'json',
			formatversion: '2',
			uselang: 'user',
			errorformat: 'html',
			errorlang: 'uselang'
		}, params)).done(function(response) {
			if (response.errors) {
				log.logMoveError(from, to, response.errors.html);
				return;
			}

			log.logMoveSuccess(response.move.from, response.move.to);

			if (response.move) {
				var talkFrom = (from.match(':') ? from.replace(':', ' talk:') : 'Talk:') + from,
					talkTo = (to.match(':') ? to.replace(':', ' talk:') : 'Talk:') + to;

				log.logMoveError(talkFrom, talkTo, response.move.html);
				return;
			}

			if (response.move.talkfrom) {
				log.logMoveSuccess(response.move.talkfrom, response.move.talkto);
			}

			onSuccess && onSuccess();
		});
	}

	function moveSubpages() {
		$('#moveSubpages-log').remove();

		var log = new Log();

		if (mw.config.get('wgUserGroups').indexOf('extendedconfirmed') === -1) {
			log.log('You must be at least extended confirmed.', 'red');
			return;
		}

		var fromTitle = new mw.Title($('input').val()),
			toTitle = mw.Title.makeTitle($('select').val(), $('input').val()),
			params = {
				reason: $('input').val(),
				movetalk: $('input').prop('checked') ? true : undefined,
				noredirect: $('').prop('checked') === false ? true : undefined,
				watchlist: $('input').prop('checked') ? 'watch' : 'nochange',
			};

		if (!toTitle) {
			log.logError('New title is an invalid page!');
			return;
		}

		$.get(mw.config.get('wgScriptPath') + '/api.php', {
			action: 'query',
			list: 'allpages',
			apprefix: fromTitle.getMainText() + '/',
			apnamespace: fromTitle.getNamespaceId(),
			pslimit: '500',
			format: 'json',
			formatversion: '2'
		}).done(function(res) {
			movePage(fromTitle.getPrefixedText(), toTitle.getPrefixedText(), params, log, function() {
				var prefixRegex = new RegExp('^' + mw.util.escapeRegExp(fromTitle.getPrefixedText()));

				res.query.allpages.forEach(function(info) {
					if (info.title === fromTitle) return;

					movePage(info.title, info.title.replace(prefixRegex, toTitle.getPrefixedText()), params, log);
				});
			});
		});
	}

	if (window.location.href.match('Special:MovePage') && !$('p:contains(\'This page has no subpages.\')')) {
		new OO.ui.ButtonWidget({
			label: 'Move page and subpages',
			flags: 
		}).$element
			.on('click', moveSubpages)
			.appendTo($('button').parent().parent());
	}
});