مدیاویکی:Gadget-AncreTitres.js: تفاوت میان نسخهها
ظاهر
imported>Dalba AncreTitres.afficheP |
imported>Dalba بهروزرسانی با کمک https://fr.wikipedia.org/wiki/MediaWiki:Gadget-AncreTitres.js، جیکوئری، در حالت ویرایش نیز کار میکند. مشکل تداخلش حل شد، به همراه کد پیوند پایدار |
||
| خط ۱: | خط ۱: | ||
// ==UserScript== | |||
// @name AncreTitres | |||
// @namespace https://fa.wikipedia.org/ | |||
// @description مدیاویکی:Gadget-AncreTitres.js | |||
// @include https://fa.wikipedia.org/* | |||
// @version 1 | |||
// @grant none | |||
// ==/UserScript== | |||
/*jslint browser:true */ | /*jslint browser:true */ | ||
/*global $, wgServer, wgScript, wgPageName */ | /*global $, wgServer, wgScript, wgPageName */ | ||
| خط ۱۱: | خط ۱۹: | ||
* {{Projet:JavaScript/Script|AncreTitres}} | * {{Projet:JavaScript/Script|AncreTitres}} | ||
*/ | */ | ||
var | /** | ||
* AncreTitres | |||
* | |||
* Cette fonction fournit un lien vers une section de page en cliquant | |||
* sur le lien [URL] ou [[lien]] à droite du titre de section. | |||
* | |||
* Auteurs : Pabix, Phe, Bayo, Chphe, Arkanosis et Dalba | |||
* {{Projet:JavaScript/Script|AncreTitres}} | |||
*/ | |||
/*global alert, jQuery, mediaWiki, window */ | |||
/*jslint vars: true, plusplus: true */ | |||
// <nowiki> | |||
(function (mw, $) { | |||
'use strict'; | |||
$(function () { | |||
var _option = { | |||
nom_permalink: '[پایاپیوند]', | |||
nom_ancre: '[URL]', | |||
nom_lien_interne: '[[ویکیپیوند]]', | |||
} | description_pl: 'نمایش پیوند پایدار به این بخش', | ||
description: 'نمایش یوآرال این بخش', | |||
descinterne: 'نمایش پیوند ویکیپدیایی این بخش', | |||
linkcolor: '', | |||
fontSize: 'xx-small', | |||
fontWeight: 'normal', | |||
afficheE: true, | |||
afficheI: true, | |||
if ( | afficheP: true | ||
}; | |||
if (typeof window.AncreTitres !== 'undefined') { | |||
$.extend(_option, window.AncreTitres); | |||
} | } | ||
if (!$('#content').length || (!_option.afficheI && !_option.afficheE)) { | |||
return; | |||
} | } | ||
} | $.each($('span.mw-headline'), function (_, headline) { | ||
$( | var anchor = headline.getAttribute('id'); | ||
var $span = $('<span class="noprint ancretitres" style="' + | |||
'font-size: ' + _option.fontSize + '; ' + | |||
'font-weight: ' + _option.fontWeight + '; ' + (_option.linkcolor !== '' ? 'color: ' + _option.linkcolor + ';' : '') + | |||
'"></span>'); | |||
if (_option.afficheP && $('#t-permalink a').length) { | |||
$span.append(' '); | |||
$('<a href="#" title="' + _option.descinterne + '">' + _option.nom_permalink + '</a>').click(function () { | |||
window.prompt('پایاپیوند:', $('#t-permalink a') [0].href + '#' + anchor | |||
); | |||
return false; | |||
}).appendTo($span); | |||
} | |||
if (_option.afficheE) { | |||
$span.append(' '); | |||
$('<a href="#" title="' + _option.description + '">' + _option.nom_ancre + '</a>').click(function () { | |||
window.prompt('نشانی وب معمولی:', 'https:' + mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '#' + anchor | |||
); | |||
return false; | |||
}).appendTo($span); | |||
} | |||
if (_option.afficheI) { | |||
$span.append(' '); | |||
$('<a href="#" title="' + _option.descinterne + '">' + _option.nom_lien_interne + '</a>').click(function () { | |||
window.prompt('ویکیپیوند:', '[[' + mw.config.get('wgPageName') + '#' + anchor + ']]' | |||
); | |||
return false; | |||
}).appendTo($span); | |||
} | |||
$(headline).parent().append($span); | |||
}); | |||
}); | |||
}(mediaWiki, jQuery)); | |||
// </nowiki> | |||
نسخهٔ ۲۶ اکتبر ۲۰۱۴، ساعت ۰۴:۱۸
// ==UserScript==
// @name AncreTitres
// @namespace https://fa.wikipedia.org/
// @description مدیاویکی:Gadget-AncreTitres.js
// @include https://fa.wikipedia.org/*
// @version 1
// @grant none
// ==/UserScript==
/*jslint browser:true */
/*global $, wgServer, wgScript, wgPageName */
/**
* AncreTitres
*
* Cette fonction fournit un lien vers une section de page en cliquant
* sur le lien [ancre] à droite du titre de section.
*
* Auteurs : Pabix, Phe, Bayo, Dalba -- Correctif apporté par Chphe
* Date de dernière révision : 16 October 2014
* {{Projet:JavaScript/Script|AncreTitres}}
*/
/**
* AncreTitres
*
* Cette fonction fournit un lien vers une section de page en cliquant
* sur le lien [URL] ou [[lien]] à droite du titre de section.
*
* Auteurs : Pabix, Phe, Bayo, Chphe, Arkanosis et Dalba
* {{Projet:JavaScript/Script|AncreTitres}}
*/
/*global alert, jQuery, mediaWiki, window */
/*jslint vars: true, plusplus: true */
// <nowiki>
(function (mw, $) {
'use strict';
$(function () {
var _option = {
nom_permalink: '[پایاپیوند]',
nom_ancre: '[URL]',
nom_lien_interne: '[[ویکیپیوند]]',
description_pl: 'نمایش پیوند پایدار به این بخش',
description: 'نمایش یوآرال این بخش',
descinterne: 'نمایش پیوند ویکیپدیایی این بخش',
linkcolor: '',
fontSize: 'xx-small',
fontWeight: 'normal',
afficheE: true,
afficheI: true,
afficheP: true
};
if (typeof window.AncreTitres !== 'undefined') {
$.extend(_option, window.AncreTitres);
}
if (!$('#content').length || (!_option.afficheI && !_option.afficheE)) {
return;
}
$.each($('span.mw-headline'), function (_, headline) {
var anchor = headline.getAttribute('id');
var $span = $('<span class="noprint ancretitres" style="' +
'font-size: ' + _option.fontSize + '; ' +
'font-weight: ' + _option.fontWeight + '; ' + (_option.linkcolor !== '' ? 'color: ' + _option.linkcolor + ';' : '') +
'"></span>');
if (_option.afficheP && $('#t-permalink a').length) {
$span.append(' ');
$('<a href="#" title="' + _option.descinterne + '">' + _option.nom_permalink + '</a>').click(function () {
window.prompt('پایاپیوند:', $('#t-permalink a') [0].href + '#' + anchor
);
return false;
}).appendTo($span);
}
if (_option.afficheE) {
$span.append(' ');
$('<a href="#" title="' + _option.description + '">' + _option.nom_ancre + '</a>').click(function () {
window.prompt('نشانی وب معمولی:', 'https:' + mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '#' + anchor
);
return false;
}).appendTo($span);
}
if (_option.afficheI) {
$span.append(' ');
$('<a href="#" title="' + _option.descinterne + '">' + _option.nom_lien_interne + '</a>').click(function () {
window.prompt('ویکیپیوند:', '[[' + mw.config.get('wgPageName') + '#' + anchor + ']]'
);
return false;
}).appendTo($span);
}
$(headline).parent().append($span);
});
});
}(mediaWiki, jQuery));
// </nowiki>