(function($) { // eslint-disable-line no-unused-vars

/*

Twinkle.shared = function friendlyshared {
	/* 기능 비활성화 : 아직 준비 안 됨 (2020-08-12) */
	if (true) {
		return;

	if (mw.config.get('wgNamespaceNumber') === 3 && mw.util.isIPAddress(mw.config.get('wgTitle'))) {
		var username = mw.config.get('wgRelevantUserName');
		Twinkle.addPortletLink(function {
			Twinkle.shared.callback(username);

Twinkle.shared.callback = function friendlysharedCallback {
	var Window = new Morebits.simpleWindow;
	Window.setTitle('Shared IP address tagging');
	Window.setScriptName('Twinkle');
	Window.addFooterLink;

	var form = new Morebits.quickForm(Twinkle.shared.callback.evaluate);

	var div = form.append;
	div.append;
	div.append({ type: 'radio', name: 'template', list: Twinkle.shared.standardList,
		event: function(e) {
			Twinkle.shared.callback.change_shared(e);
			e.stopPropagation;

	var org = form.append({ type: 'field', label: 'Fill in other details (optional) and click "Submit"' });
	org.append;
	org.append({
		type: 'input',
		name: 'host',
		label: 'Host name (optional)',
		disabled: true,
		tooltip: 'The host name  can be optionally entered here and will be linked by the template.'
	);
	org.append({
		type: 'input',
		name: 'contact',
		label: 'Contact information (only if requested)',
		disabled: true,
		tooltip: 'You can optionally enter some contact details for the organization. Use this parameter only if the organization has specifically requested that it be added. You can use wikimarkup if necessary.'
	);

	form.append({ type: 'submit' });

	var result = form.render;
	Window.setContent(result);
	Window.display;

Twinkle.shared.standardList = [
		label: ': standard shared IP address template',
		value: 'Shared IP',
		tooltip: 'IP user talk page template that shows helpful information to IP users and those wishing to warn, block or ban them'
		label: ': shared IP address template modified for educational institutions',
		value: 'Shared IP edu'
		label: ': shared IP address template modified for businesses',
		value: 'Shared IP corp'
		label: ': shared IP address template modified for public terminals',
		value: 'Shared IP public'
		label: ': shared IP address template modified for government agencies or facilities',
		value: 'Shared IP gov'
		label: ': shared IP address template modified for organizations with dynamic addressing',
		value: 'Dynamic IP'
		label: ': shared IP address template modified for static IP addresses',
		value: 'Static IP'
		label: ': shared IP address template modified for ISP organizations (specifically proxies)',
		value: 'ISP'
		label: ': shared IP address template modified for mobile phone companies and their customers',
		value: 'Mobile IP'
		label: ': template for IP addresses in need of monitoring, but unknown whether static, dynamic or shared',
		value: 'Whois'
];

Twinkle.shared.callback.change_shared = function friendlysharedCallbackChangeShared(e) {
	e.target.form.contact.disabled = e.target.value !== 'Shared IP edu'; // only supported by 
	e.target.form.organization.disabled = false;
	e.target.form.host.disabled = e.target.value === 'Whois'; // host= not supported by 

Twinkle.shared.callbacks = {
	main: function(pageobj) {
		var params = pageobj.getCallbackParameters;
		var pageText = pageobj.getPageText;
		var found = false;

		for (var i = 0; i < Twinkle.shared.standardList.length; i++) {
			var tagRe = new RegExp('(\\{\\{' + Twinkle.shared.standardList[i].value + '(\\||\\}\\}))', 'im');
			if (tagRe.exec(pageText)) {
				Morebits.status.warn;
				found = true;

		if (found) {
			return;

		Morebits.status.info;
		var text = '\n\n';

		var summaryText = 'Added template.';
		pageobj.setPageText(text + pageText);
		pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
		pageobj.setMinorEdit(Twinkle.getPref('markSharedIPAsMinor'));
		pageobj.setCreateOption('recreate');
		pageobj.save;

Twinkle.shared.callback.evaluate = function friendlysharedCallbackEvaluate(e) {
	var params = Morebits.quickForm.getInputData(e.target);
	if (!params.template) {
		alert('You must select a shared IP address template to use!');
		return;
	if (!params.organization) {
		alert('You must input an organization for the template!');
		return;

	Morebits.simpleWindow.setButtonsEnabled(false);
	Morebits.status.init(e.target);

	Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
	Morebits.wiki.actionCompleted.notice = 'Tagging complete, reloading talk page in a few seconds';

	var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'User talk page modification');
	wikipedia_page.setFollowRedirect(true);
	wikipedia_page.setCallbackParameters(params);
	wikipedia_page.load(Twinkle.shared.callbacks.main);

Twinkle.addInitCallback;