Kontent qismiga oʻtish

MediaWiki:Gadget-Adiutor-OPT.js

Vikipediya, ochiq ensiklopediya

Eʼtibor bering: Oʻzgartirishlaringizni koʻrish uchun, yangi moslamalaringizning saqlashdan keyin, brauzer keshini tozalash kerak:
Mozilla / Firefox: Ctrl+Shift+R, IE: Ctrl+F5, Safari: Cmd+Shift+R, Konqueror: F5, Opera: Tools → Preferences orqali keshni tozalang.

/* 
 * Adiutor: A gadget to assist various user actions
 * Author: Vikipolimer
 * Licencing and attribution: [[VP:Adiutor#Lisanslama ve atıf]]
 * Module: Adiutor options
 */
/* <nowiki> */
$.when(mw.loader.using(["mediawiki.user", "oojs-ui-core", "oojs-ui-windows", ]), $.ready).then(function() {
	var mwConfig = mw.config.get(["wgAction", "wgPageName", "wgTitle", "wgUserGroups", "wgUserName", "wgCanonicalNamespace", "wgNamespaceNumber"]);
	var api = new mw.Api();
	var prdSendMessageToCreator = localStorage.getItem("prdSendMessageToCreator") == "true";

	function AdiutorOptionsDialog(config) {
		AdiutorOptionsDialog.super.call(this, config);
	}
	OO.inheritClass(AdiutorOptionsDialog, OO.ui.ProcessDialog);
	AdiutorOptionsDialog.static.name = 'AdiutorOptionsDialog';
	AdiutorOptionsDialog.static.title = 'Adiutor — Moslamalar';
	AdiutorOptionsDialog.static.actions = [{
		action: 'save',
		label: 'Yangilash',
		flags: ['primary', 'progressive']
	}, {
		label: 'Yopish',
		flags: 'safe'
	}];
	AdiutorOptionsDialog.prototype.initialize = function() {
		AdiutorOptionsDialog.super.prototype.initialize.apply(this, arguments);
		this.content = new OO.ui.PanelLayout({
			padded: true,
			expanded: false
		});
		AdiutorSettings = new OO.ui.FieldsetLayout({
			label: 'Moslamalar',
		});
		AdiutorSettings.addItems([
			csdSendMessageToCreator = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
				selected: localStorage.getItem("csdSendMessageToCreator") == "true"
			}), {
				align: 'inline',
				label: 'Sahifani tezda oʻchirishga nomzod oʻlaroq koʻrsatganimda, har doim sahifa muallifi bu haqda ogohlantirilsin',
				help: ''
			}),
			afdSendMessageToCreator = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
				selected: localStorage.getItem("afdSendMessageToCreator") == "true"
			}), {
				align: 'inline',
				label: 'Sahifani oʻchirishga nomzod oʻlaroq koʻrsatganimda, har doim sahifa muallifi bu haqda ogohlantirilsin',
				help: ''
			}),
			csdLogNominatedPages = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
				selected: localStorage.getItem("csdLogNominatedPages") == "true"
			}), {
				align: 'inline',
				label: 'Tezda oʻchirishga nomzod oʻlaroq koʻrsatgan sahifalarim qaydlari olib borilsin',
				help: ''
			}),
			csdLogPageName = new OO.ui.FieldLayout(new OO.ui.TextInputWidget({
				value: localStorage.getItem("csdLogPageName"),
			}), {
				label: 'TOʻ qaydlari nomi',
				help: ''
			}),
			afdLogNominatedPages = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
				selected: localStorage.getItem("afdLogNominatedPages") == "true"
			}), {
				align: 'inline',
				label: 'Oʻchirishga nomzod oʻlaroq koʻrsatgan sahifalarim qaydlari olib borilsin',
				help: ''
			}),
			afdLogPageName = new OO.ui.FieldLayout(new OO.ui.TextInputWidget({
				value: localStorage.getItem("afdLogPageName")
			}), {
				label: 'Oʻ qaydlari nomi',
				help: ''
			}),
			showMyStatus = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
				selected: localStorage.getItem("showMyStatus") == "true"
			}), {
				align: 'inline',
				label: 'Foydalanuvchilarning faolligi holati koʻrsatilsin',
				help: 'Bu opsiya faollashtirilganda, biror foydalanuvchining foydalanuvchi sahifasiga tashrif buyurganingizda, uning faollik holati koʻrsatiladi (masalan, Faol, deb).'
			}),
		]);
		this.content.$element.append(AdiutorSettings.$element);
		this.$body.append(this.content.$element);
	};
	AdiutorOptionsDialog.prototype.getActionProcess = function(action) {
		var dialog = this;
		if(action) {
			return new OO.ui.Process(function() {
				UpdatedOptions = JSON.stringify([{
					"name": "csdSendMessageToCreator",
					"value": csdSendMessageToCreator.fieldWidget.selected
				}, {
					"name": "csdLogNominatedPages",
					"value": csdLogNominatedPages.fieldWidget.selected
				}, {
					"name": "csdLogPageName",
					"value": csdLogPageName.fieldWidget.value
				}, {
					"name": "afdSendMessageToCreator",
					"value": afdSendMessageToCreator.fieldWidget.selected
				}, {
					"name": "afdLogNominatedPages",
					"value": afdLogNominatedPages.fieldWidget.selected
				}, {
					"name": "afdLogPageName",
					"value": afdLogPageName.fieldWidget.value
				}, {
					"name": "prdSendMessageToCreator",
					"value": prdSendMessageToCreator.fieldWidget.selected
				}, {
					"name": "prdLogNominatedPages",
					"value": prdLogNominatedPages.fieldWidget.selected
				}, {
					"name": "prdLogPageName",
					"value": prdLogPageName.fieldWidget.value
				}, {
					"name": "afdNominateOpinionsLog",
					"value": afdNominateOpinionsLog.fieldWidget.selected
				}, {
					"name": "afdOpinionLogPageName",
					"value": afdOpinionLogPageName.fieldWidget.value
				}, {
					"name": "showMyStatus",
					"value": showMyStatus.fieldWidget.selected
				}, {
					"name": "MyStatus",
					"value": "active"
				}]);
				updateOptions(UpdatedOptions);
				dialog.close({
					action: action
				});
			});
		}
		return AdiutorOptionsDialog.super.prototype.getActionProcess.call(this, action);
	};
	var windowManager = new OO.ui.WindowManager();
	$(document.body).append(windowManager.$element);
	var dialog = new AdiutorOptionsDialog();
	windowManager.addWindows([dialog]);
	windowManager.openWindow(dialog);

	function updateOptions(UpdatedOptions) {
		api.postWithToken('csrf', {
			action: 'edit',
			title: 'Kullanıcı:' + mwConfig.wgUserName + '/Adiutor-options.js',
			text: UpdatedOptions,
			tags: 'Adiutor',
			summary: '[[VP:Adiutor|Adiutor]] moslamalari yangilandi',
			format: 'json'
		}).done(function() {
			var Notification = new OO.ui.MessageWidget({
				type: 'success',
				label: 'Adiutor moslamalaringiz yangilandi',
				classes: ['afd-helper-notification'],
				showClose: true
			});
			$('.mw-page-container-inner').append(Notification.$element);
			setTimeout(function() {
				$(".afd-helper-notification").hide('blind', {}, 500);
			}, 5000);
		});
	}
});
/* </nowiki> */