コンテンツにスキップ

「MediaWiki:Common.js」の版間の差分

提供: Vikipedia
Vikipedia (トーク) による版 4981 を取り消し
編集の要約なし
4行目: 4行目:
  */
  */
importScript('MediaWiki:EnhancedCollapsibleElements.js');
importScript('MediaWiki:EnhancedCollapsibleElements.js');
/*
*  Reference Pop Up
*
*      This script is under public domain, and comes with ABSOLUTELY NO WARRANTY.
*      You can use/modify/redistribute without any permission.
*/
//  for WIkipedia user script
//
//  How to use:
//  * write "importScript('User:Mizusumashi/Script/ReferencePopUp.js');"
//    in "User:_ACOUNT_/monobook.js"("_ACOUNT_" is your WIki acount).
//  * This script need addOnloadHook()
//    in http://upload.wikimedia.org/skins/common/wikibits.js.
// for Firefox extension "Greasemonkey"
//
// ==UserScript==
// @name          WikipediaReferencePopUp
// @namespace      mizusumashi
// @include        http://*.wikipedia.org/*
// ==/UserScript==
hrefregex= new RegExp('');
hrefregex.compile('http://([^#]+)#(.+)');
refregex1 = new RegExp('');
refregex1.compile('^(<span [^>]+>)?(<b><a [^>]+>\\^</a></b>|\\^( <a [^>]+><sup><i><b>[^<]+</b></i></sup></a>)+) ', 'i');
refregex2 = new RegExp('');
refregex2.compile('<[^>]+>', 'g');
refregex3 = new RegExp('');
refregex3.compile('<span [^>]+>(<a [^>]+><b>.+</b></a></span>&nbsp;)+', 'i');
templateregex = new RegExp('');
templateregex.compile('^<a [^>]+><b>.+</b></a>$', 'i');
function isTemplate(foot)
{
    var ret = templateregex.test(foot.innerHTML);
    return ret;
}
function referencePopUp()
{
    if(navigator.appName == "Microsoft Internet Explorer"){
        return;
    }
    var arrayOfReference = document.getElementsByClassName('reference');
    for( var i = 0; i < arrayOfReference.length; i++){
        arrayOfReference[i].firstChild.href.match(hrefregex);
       
        var foot = document.getElementById(RegExp.$2);
        if(foot){
            if(! isTemplate(foot)){
                text = foot.innerHTML;
                text = text.replace(refregex1, '');
                text = text.replace(refregex2, '');
            } else { // [[Template:Note label]]
                text = foot.parentNode.innerHTML;
                text = text.replace(refregex3, '');
                text = text.replace(refregex2, '');
            }
        } else {
            text = 'ERROR: There is no footnote.';
        }
        arrayOfReference[i].firstChild.title = text;
    }
}
addOnloadHook(referencePopUp); // in Wikipedia user script
// referencePopUp(); // in Firefox extension "Greasemonkey"


/**
/**
127行目: 54行目:
     for ( i = 0; i < Tables.length; i++ ) {
     for ( i = 0; i < Tables.length; i++ ) {
         if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
         if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
// ==UserScript==
// -*- mode:JScript; Encoding:utf8n -*-
// @name          Wikipedia.citePopup
// @namespace      http://d.hatena.ne.jp/p-arai/
// @description    Add pop-up on reference to footnote
// @include        http://ja.wikipedia.org/wiki/*
// @grant          none
//
// @author        p-arai, yuuAn
// @version        2012.11.10
// ==/UserScript==
(function () {
  // retrive array of cites
  var cites = new Array();
  var lis = document.getElementsByTagName("li");
  for (var i=0; i < lis.length; i++){
    var li = lis[i];
    if (li.id.match(/^cite_note(?:-[\w\.]+){0,}-(\d+)$/)){
      var index = RegExp.$1;
      cites[index] = li;
    }
  }
  // retrive and modify reference element
  var hrefs = document.getElementsByTagName("a");
  for (var i=0; i < hrefs.length; i++){
    var a = hrefs[i];
    if (a.href.match(/#cite_note(?:-[\w\.]+){0,}-(\d+)$/)){
      var index = RegExp.$1;
      if (typeof a.textContent != "undefined") {
        a.title = cites[index].textContent.replace(/^[^]\s*/, "");
      } else {
        a.title = cites[index].innerText.replace(/^[^]\s*/, "");
      }
    }
  }
})();

2015年12月22日 (火) 15:32時点における版

/*
 * 拡張型折りたたみ要素(EnhancedCollapsibleElements)
 * 説明書:https://ja.wikipedia.org/wiki/Help:拡張型折りたたみ可能要素
 */
importScript('MediaWiki:EnhancedCollapsibleElements.js');

/**
 * Collapsible tables *********************************************************
 *
 * Description: Allows tables to be collapsed, showing only the header. See
 *              [[Vikipedia:NavFrame]].
 * Maintainers: [[User:SupernovaT]]
 */
 
window.autoCollapse = 2;
window.collapseCaption = "隠す";
window.expandCaption = "表示";
 
window.collapseTable = function ( tableIndex ) {
    var Button = document.getElementById( 'collapseButton' + tableIndex );
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
    var i;
 
    if ( Button.firstChild.data === collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = 'none';
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
};
 
window.createCollapseButtons = function() {
    var tableIndex = 0;
    var NavigationBoxes = {};
    var Tables = document.getElementsByTagName( 'table' );
    var i;
 
    function handleButtonLink( index, e ) {
        window.collapseTable( index );
        e.preventDefault();
    }
 
    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {

// ==UserScript==
// -*- mode:JScript; Encoding:utf8n -*-
// @name           Wikipedia.citePopup
// @namespace      http://d.hatena.ne.jp/p-arai/
// @description    Add pop-up on reference to footnote
// @include        http://ja.wikipedia.org/wiki/*
// @grant          none
// 
// @author         p-arai, yuuAn
// @version        2012.11.10
// ==/UserScript==

(function () {

  // retrive array of cites
  var cites = new Array();
  var lis = document.getElementsByTagName("li");
  for (var i=0; i < lis.length; i++){
    var li = lis[i];
    if (li.id.match(/^cite_note(?:-[\w\.]+){0,}-(\d+)$/)){
      var index = RegExp.$1;
      cites[index] = li;
    }
  }

  // retrive and modify reference element
  var hrefs = document.getElementsByTagName("a");
  for (var i=0; i < hrefs.length; i++){
    var a = hrefs[i];
    if (a.href.match(/#cite_note(?:-[\w\.]+){0,}-(\d+)$/)){
      var index = RegExp.$1;
      if (typeof a.textContent != "undefined") {
        a.title = cites[index].textContent.replace(/^[^]\s*/, "");
      } else {
        a.title = cites[index].innerText.replace(/^[^]\s*/, "");
      }
    }
  }

})();
Cookieは私達のサービスを提供するのに役立ちます。このサービスを使用することにより、お客様はCookieの使用に同意するものとします。