پرش به محتوا

مدیاویکی: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 = {
/**
    nom_permalink: "[پایاپیوند]",
* AncreTitres
    nom_ancre: '[URL]',
*
    nom_lien_interne: '[[ویکی\u200Cپیوند]]',
* Cette fonction fournit un lien vers une section de page en cliquant
    description_pl: 'نمایش پیوند پایدار به این بخش',
* sur le lien [URL] ou [[lien]] à droite du titre de section.
    description: 'نمایش یو\u200Cآر\u200Cال این بخش',
*
    descinterne: 'نمایش پیوند ویکی\u200Cپدیایی این بخش',
* Auteurs : Pabix, Phe, Bayo, Chphe, Arkanosis et Dalba
    linkcolor: '',
* {{Projet:JavaScript/Script|AncreTitres}}
    fontSize: 'xx-small',
*/
    fontWeight: 'normal',
/*global alert, jQuery, mediaWiki, window */
    afficheE: true,
/*jslint vars: true, plusplus: true */
    afficheI: true,
// <nowiki>
    afficheP: true
(function (mw, $) {
};
  'use strict';
 
  $(function () {
function ancrer() {
    var _option = {
    'use strict';
      nom_permalink: '[پایاپیوند]',
    if (!document.getElementById('content')) {
      nom_ancre: '[URL]',
        return;
      nom_lien_interne: '[[ویکی‌پیوند]]',
     }
      description_pl: 'نمایش پیوند پایدار به این بخش',
    var titres = document.getElementsByTagName('span'),
      description: 'نمایش یو‌آر‌ال این بخش',
        i = 0,
      descinterne: 'نمایش پیوند ویکی‌پدیایی این بخش',
        titre_courant,
      linkcolor: '',
        ancre_nom,
      fontSize: 'xx-small',
        span,
      fontWeight: 'normal',
        link,
      afficheE: true,
        prefixedServer;
      afficheI: true,
     if (!AncreTitres.afficheI && !AncreTitres.afficheE && !AncreTitres.afficheP) {
      afficheP: true
        return;
     };
    }
     if (typeof window.AncreTitres !== 'undefined') {
    prefixedServer = wgServer;
      $.extend(_option, window.AncreTitres);
    if (wgServer.substr(0, 2) === '//') {
        if (document.URL.substr(0, 5) === 'http:') {
            prefixedServer = 'http:' + wgServer;
        } else if (document.URL.substr(0, 6) === 'https:') {
            prefixedServer = 'https:' + wgServer;
        }
     }
     }
     for (i = 0; i < titres.length; i += 1) {
     if (!$('#content').length || (!_option.afficheI && !_option.afficheE)) {
        titre_courant = titres[i].parentNode;
      return;
        if ((titres[i].className.match(/mw-headline/gi))) {
            ancre_nom = titres[i].id;
            span = document.createElement('span');
            if (AncreTitres.linkcolor !== '') {
                span.style.color = AncreTitres.linkcolor;
            }
            span.style.fontSize = AncreTitres.fontSize;
            span.style.fontWeight = AncreTitres.fontWeight;
            span.className = 'noprint ancretitres';
            if (AncreTitres.afficheP) {
                link = document.createElement('a');
                link.innerHTML = AncreTitres.nom_permalink;
                link.title = AncreTitres.description_pl;
                link.setAttribute('ancre', $('#t-permalink a')[0].href + '#' + ancre_nom);
                link.setAttribute('onclick', 'window.prompt(' + '\'پایاپیوند: \', this.getAttribute(\'ancre\'));');
                span.appendChild(document.createTextNode(' '));
                span.appendChild(link);
            }
            if (AncreTitres.afficheE) {
                link = document.createElement('a');
                link.innerHTML = AncreTitres.nom_ancre;
                link.title = AncreTitres.description;
                link.setAttribute('ancre', prefixedServer + wgScript + '?title=' + wgPageName + '#' + ancre_nom);
                link.setAttribute('onclick', 'window.prompt(' + '\'نشانی وب معمولی: \', this.getAttribute(\'ancre\'));');
                span.appendChild(document.createTextNode(' '));
                span.appendChild(link);
            }
            if (AncreTitres.afficheI) {
                link = document.createElement('a');
                link.innerHTML = AncreTitres.nom_lien_interne;
                link.title = AncreTitres.descinterne;
                link.setAttribute('ancre', '[[' + wgPageName + '#' + ancre_nom + ']]');
                link.setAttribute('onclick', 'window.prompt(' + '\'ویکی‌پیوند: \', this.getAttribute(\'ancre\'));');
                span.appendChild(document.createTextNode(' '));
                span.appendChild(link);
            }
            titre_courant.appendChild(span);
        }
     }
     }
}
    $.each($('span.mw-headline'), function (_, headline) {
$(ancrer);
      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>