Jump to content
Wikimedia Commons

MediaWiki:Gadget-RotateLink.js

From Wikimedia Commons, the free media repository
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
This user script seems to have a documentation page at MediaWiki:Gadget-RotateLink.
 /**
 * Install a rotatelink
 * This piece of script is jshint-valid. See [[:commons:MediaWiki:JSValidator.js]].
 * Maintainer: [[User:Rillke]]
 */
 $(function(){
 'use strict';

 varext,$fileinfo,i18n,
 title=newmw.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','flac','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;}

 functionloadAndStart(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(
 '; ',
 $('<a>').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(
 '(',
 $('<img>').prop('src','//upload.wikimedia.org/wikipedia/commons/7/70/Silk_arrow_rotate_clockwise.png'),
 i18n[ext]||i18n[ext.split('-')[0]]||i18n.en,
 ')'
 )
 );
 });

AltStyle によって変換されたページ (->オリジナル) /