User:Sksiwiwiwiwoww/vector.js

/** $( function {	'use strict';
 * Install a rotatelink
 * This piece of script is jshint-valid. See commons:MediaWiki:JSValidator.js.
 * Maintainer: User:Rillke

var ext, $fileinfo, i18n, title = new mw.Title( mw.config.get( 'wgPageName' ) );

if (		!title ||		// Only logged in users		mw.user.isAnon ||		// Only File pages		title.getNamespaceId !== mw.config.get( 'wgNamespaceIds' ).file ||		// Ignore these extensions		[ 'ogg', 'oga', 'ogv', 'opus', 'webm', 'mid', 'svg', 'pdf', 'djvu', 'stl' ]			.indexOf( ext = title.getExtension && title.getExtension.toLowerCase ) !== -1 ||		// User-ignored extensions		( Array.isArray( title = window.rotateFileTypes ) && title.indexOf( ext ) === -1 ) ||		// Protected pages		( ( ext = mw.config.get( 'wgRestrictionEdit' ) ) && ext.length && mw.config.get( 'wgUserGroups' ).indexOf( ext[ 0 ] ) === -1 ) ||		// Prevent accidental misuse (not on own uploads)		( mw.config.get( 'wgUserEditCount' ) < 16 && $( '#mw-imagepage-section-filehistory tr:last > td:last' ) .prev( 'td' ).find( 'a' ).eq( 0 ).text !== mw.config.get( 'wgUserName' ) )	) { return; }

function loadAndStart( e ) { e.preventDefault; if ( window.rRot ) { $( document ).triggerHandler( 'rotaterequest', [ 'start' ] ); } else { $( document ).on( 'scriptLoaded', function ( evt, d ) {				if ( d && d === 'rotaterequest' ) {					$( this ).triggerHandler( d, [ 'start' ] );				}			} ); mw.loader.load( '/w/index.php?title=MediaWiki:RotateRequest.js&action=raw&ctype=text/javascript' ); }	}

if ( ( ext = mw.config.get( 'wgCategories', [] ) ).indexOf( 'Images requiring rotation' ) !== -1 ||		ext.indexOf( 'Images requiring rotation by bot' ) !== -1 ) { $( '#rotateChangeAngle' ).show.on( 'click', 'a', loadAndStart ); return; }

$fileinfo = $( '#mw-content-text .fileInfo' ); if ( !$fileinfo.length ) { return; }

i18n = { ar: 'طلب تدوير', ca: 'demana girar-la', cs: 'vyžádat otočení', da: 'Anmod om rotation', de: 'Bild drehen', el: 'θέλει περιστροφή;', en: 'request rotation', es: 'solicitar la rotación', fa: 'درخواست چرخش', fi: 'pyydä kiertoa', fr: 'demander la rotation', gl: 'solicitar a rotación', hr: 'zahtjev za okretanjem slike', it: 'richiedi rotazione', ja: '画像の回転を依頼', mk: 'побарај свртување', ml: 'തിരിക്കാൻ നിർദ്ദേശിക്കുക', nl: 'Rotatie aanvragen', pl: 'Obróć grafikę', pt: 'Solicitar rotação', ro: 'Cerere de rotaţie', ru: 'запросить поворот', sl: 'zahteva za zasuk', sr: 'захтевање ротације', sv: 'Begär rotation', uk: 'запит на обертання', zh: '请求旋转', // also correct for zh-hans, zh-cn, zh-my, zh-sg 'zh-hant': '請求旋轉', 'zh-hk': '請求旋轉', 'zh-mo': '請求旋轉', 'zh-tw': '請求旋轉' };	ext = mw.config.get( 'wgUserLanguage' ); $fileinfo.append(		'; ',		$( '' ).attr( { href: '#', style: 'white-space:nowrap; display:inline-block;', title: 'Request a (permanent) correction of the rotation if the thumbnails display in the wrong orientation. Please try to purge the server’s and client’s cache before if this file is an upload before middle of October 2011.' } ).on( 'click', loadAndStart ).append( '(',			$( ' ' ).prop( 'src', '//upload.wikimedia.org/wikipedia/commons/7/70/Silk_arrow_rotate_clockwise.png' ),			i18n[ ext ] || i18n[ ext.split( '-' )[ 0 ] ] || i18n.en,			')' )	); } ); /* * Adiutor: Provides versatile editing options and modules to assist a variety of user actions to enhance the Wikipedia editing experience. * Author: Vikipolimer * Learn more at: https://meta.wikimedia.org/wiki/Adiutor * Licensing and Attribution: Licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) * Module: Initial loader */ /* */ // Initialize the MediaWiki API var api = new mw.Api; var wikiId = mw.config.get('wgWikiID'); var wikiOptions = 'userjs-adiutor-' + wikiId; // Function to update user options function updateOptions(options) {	api.postWithEditToken({ action: 'globalpreferences', format: 'json', optionname: 'userjs-adiutor-' + wikiId, optionvalue: JSON.stringify(options), formatversion: 2, }, function {}); } // Function to update translations function updateTranslations {	api.get({ action: 'query', prop: 'revisions', titles: 'MediaWiki:Gadget-Adiutor-i18.json', rvprop: 'content', formatversion: 2 }).done(function(data) { var page = data.query.pages[0]; if(page && page.revisions && page.revisions[0]) { var jsonData = JSON.parse(page.revisions[0].content); // Check if jsonData is an object if(typeof jsonData === 'object') { for(var langCode in jsonData) { if(jsonData.hasOwnProperty(langCode) && langCode !== '@metadata') { // Pass necessary data as arguments to the function processTranslation(langCode, jsonData[langCode]); }				}			} else { console.error('JSON content is not an object:', jsonData); }		} else { console.error('No valid revision data found in the response.'); }	}).fail(function(err) { console.error('Failed to fetch translation data:', err); }); }

function processTranslation(langCode, translationData) { var optionValue = JSON.stringify(translationData); api.postWithEditToken({		action: 'globalpreferences',		format: 'json',		optionname: 'userjs-adiutor-i18-' + langCode,		optionvalue: optionValue,		formatversion: 2	}).done(function(response) {		console.log('Updated translation for langCode: ' + langCode);	}).fail(function(err) {		console.error('Failed to update translation for langCode: ' + langCode, err);	}); } // Define default user options for the Adiutor gadget var adiutorUserOptionsDefault = { "myWorks": [], "myCustomSummaries": [], "speedyDeletion": { "csdSendMessageToCreator": true, "csdLogNominatedPages": true, "csdLogPageName": "CSD Log", },	"articlesForDeletion": { "afdSendMessageToCreator": true, "afdLogNominatedPages": true, "afdLogPageName": "DEL Log", "afdNominateOpinionsLog": true, "afdOpinionLogPageName": "DEL Opinion Log" },	"proposedDeletion": { "prdSendMessageToCreator": true, "prdLogNominatedPages": true, "prdLogPageName": "PROD Log" },	"status": { "showMyStatus": true, "myStatus": "active" },	"stats": { "csdRequests": 0, "afdRequests": 0, "prodRequests": 0, "blockRequests": 0, "userWarnings": 0, "pageTags": 0, },	"inlinePageInfo": true, "showEditSummaries": true, "adiutorVersion": "v1.2.7" }; // Get user options related to the Adiutor gadget var adiutorUserOptions = JSON.parse(mw.user.options.get(wikiOptions)); // Check if user options are not present or empty if(!adiutorUserOptions || Object.keys(adiutorUserOptions).length === 0) { // Send default user options to the server using API updateOptions(adiutorUserOptionsDefault); // Retrieve default translation data updateTranslations; } else { var hasNewOptions = false; // Flag to check if there are new options // Loop through the properties in adiutorUserOptionsDefault for(var key in adiutorUserOptionsDefault) { if(adiutorUserOptionsDefault.hasOwnProperty(key)) { // Check if the property exists in adiutorUserOptions if(!adiutorUserOptions.hasOwnProperty(key)) { // New setting found, set the flag hasNewOptions = true; adiutorUserOptions[key] = adiutorUserOptionsDefault[key]; // Add the new option }		}	}	// Update user options if new settings are found if(hasNewOptions) { updateOptions(adiutorUserOptions); updateTranslations; } } try { var userLanguage = mw.config.get('wgUserLanguage'); // Get user's language var adiutorUserInterfaceTranslations = mw.user.options.get('userjs-adiutor-i18-' + userLanguage); // Get translation for user's language // If there is no translation, use English as a fallback. if(!adiutorUserInterfaceTranslations) { adiutorUserInterfaceTranslations = mw.user.options.get('userjs-adiutor-i18-en'); }	// Ensure messages is an object with valid translations. var messages = JSON.parse(adiutorUserInterfaceTranslations); if(typeof messages !== 'object' || Object.keys(messages).length === 0) { throw new Error('Invalid or empty translations'); }	// If so, work with the messages object. mw.messages.set(messages); // Load the Gadget-Adiutor-Loader.js file mw.loader.load(mw.util.getUrl('MediaWiki:Gadget-Adiutor-Loader.js', { action: 'raw' }) + '&ctype=text/javascript', 'text/javascript'); } catch(error) { console.error('Error fetching and processing translations:', error); } /* */