MediaWiki:RefToolbarConfig.js

De la Viquipèdia, l'enciclopèdia lliure

Nota: Després de desar, heu de netejar la memòria cau del navegador per veure els canvis. En la majoria de navegadors amb Windows o Linux, premeu Ctrl+F5 o bé premeu Shift i cliqueu el botó "Actualitza" (Ctrl i "Actualitza" amb Internet Explorer). Vegeu més informació i instruccions per a cada navegador a Viquipèdia:Neteja de la memòria cau.

//<nowiki>
/* Importat de en:MediaWiki:RefToolbarConfig.js, oldid=690202938 at 23:22, 11 November 2015
*  traduït i adaptat al format local
*
* Sitewide options for the the Cite toolbar button:
* All options should be specified
*
* "date format" sets the date format used for the function to insert the current date
* Current available options:
* date - the day of the month
* zdate - day of the month, zero padded to 2 digits
* monthname - The month name
* month - The numberic month (1-12)
* zmonth - numeric month, zero padded to 2 digits
* year - The full year (4 digits)
*
* "autodate fields" is a list of template fields that should have a button to insert the current date
* 
* "months" is a list of localized month names
*
* "modal" - if true, the dialogs will be modal windows, blocking access to the rest of the window.
* See http://en.wikipedia.org/wiki/Modal_window
* All dialogs in the toolbar are modal by default
*
* "autoparse" - if true, previewing a ref will automatically trigger a preview of the parsed wikitext.
* It is not recommended to set this to true as a global setting as it may slow the script down for
* people with slow connections.
*
* "expandtemplates" - if true, templates and parser functions will be expanded when getting page text
* (templates inside of ref tags will not be expanded). This will allow references inside of templates or
* references using {{#tag:ref}} to be listed in the named refs dialog and searched by error checks.
* This may slow loading the named refs and error check dialogs.
*/

CiteTB.Options = {
"date format" : "<date> <monthname> <year>",
"autodate fields" : ['consulta'],
"months" : ['gener', 'febrer', 'març', 'abril', 'maig', 'juny', 'juliol', 'agost', 'setembre', 'octubre', 'novembre', 'desembre'],
"modal" : true,
"autoparse" : true,
"expandtemplates" : false
};

// Cite template definitions
new citeTemplate('ref-llibre', 'book',
[ // Basic fields
{"field": "cognom", "autofillprop":"last1"},
{"field": "nom", "autofillprop":"first1"}, 
{"field": "títol", "autofillprop":"title"},
{"field": "pàgines", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
{"field": "lloc", "autofillprop":"location"},
{"field": "editorial", "autofillprop":"publisher"},
{"field": "data", "autofillprop":"year"},
{"field": "isbn", "autofillid":"isbn"},
{"field": "url"},
{"field": "consulta"}
],
[ // Expanded fields
{"field": "autor"},
{"field": "enllaçautor", "tooltip":"cite-authorlink-tooltip"},
{"field": "coautors", "autofillprop":"coauthors"},
{"field": "editor"},
{"field": "capítol"},
{"field": "llengua", "tooltip":"cite-language-tooltip"},
{"field": "edició", "autofillprop":"edition"},
{"field": "format"},
{"field": "citació"},
{"field": "ref", "tooltip":"cite-ref-tooltip"}
]);

new citeTemplate('ref-publicació', 'journal',
[ // Basic fields
{"field": "cognom", "autofillprop":"last1"},
{"field": "nom", "autofillprop":"first1"},
{"field": "títol", "autofillprop":"title"},
{"field": "publicació", "autofillprop":"journal"},
{"field": "data", "autofillprop":"date"},
{"field": "pàgines", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
{"field": "volum", "autofillprop":"volume"},
{"field": "exemplar", "autofillprop":"issue"},
{"field": "doi", "autofillid":"doi"},
{"field": "pmid", "autofillid":"pmid"},
{"field": "url"},
{"field": "consulta"}
],
[ // Expanded fields
{"field": "autor"},
{"field": "enllaçautor", "tooltip":"cite-authorlink-tooltip"},
{"field": "coautors", "autofillprop":"coauthors"},
{"field": "llengua", "tooltip":"cite-language-tooltip"},
{"field": "lloc"},
{"field": "editorial"},
{"field": "format"},
{"field": "issn"},
{"field": "id"},
{"field": "citació"},
{"field": "ref", "tooltip":"cite-ref-tooltip"}
]);

new citeTemplate('ref-web', 'web',
[ // Basic fields
{"field": "cognom", "autofillprop":"last1"},
{"field": "nom", "autofillprop":"first1"}, 
{"field": "url"},
{"field": "consulta"},
{"field": "títol", "autofillprop":"title"},
{"field": "obra", "tooltip": "cite-work-tooltip", "autofillprop":"journal"},
{"field": "editor"}
],
[ // Expanded fields
{"field": "autor"},
{"field": "enllaçautor", "tooltip":"cite-authorlink-tooltip"},
{"field": "coautors", "autofillprop":"coauthors"},
{"field": "data", "autofillprop":"date"},
{"field": "arxiuurl"},
{"field": "arxiudata"},
{"field": "lloc"},
{"field": "pàgines", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
{"field": "llengua", "tooltip":"cite-language-tooltip"},
{"field": "format"},
{"field": "doi", "autofillid":"doi"},
{"field": "citació"},
{"field": "ref", "tooltip":"cite-ref-tooltip"}
]);

new citeTemplate('ref-notícia', 'news',
[ // Basic fields
{"field": "cognom"},
{"field": "nom"}, 
{"field": "títol"},
{"field": "publicació"},
{"field": "url"},
{"field": "consulta"},
{"field": "data"}
],
[ // Expanded fields
{"field": "autor"},
{"field": "enllaçautor", "tooltip":"cite-authorlink-tooltip"},
{"field": "agència"},
{"field": "pàgines", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
{"field": "llengua"},
{"field": "format"},
{"field": "citació"},
{"field": "ref", "tooltip":"cite-ref-tooltip"}
]);

new citeErrorCheck({'type':'reflist', 'testname':'samecontent', 'desc': 'cite-samecontent-desc',
'func': function(reflist) {
  var errors = [];
  var refs2 = [];
  for(var i=0; i<reflist.length; i++) {
    if (!reflist[i].shorttag) {
      if ($.inArray(reflist[i].content, refs2) != -1) {
        if ($.inArray(reflist[i].content, errors) == -1) {
          errors.push(reflist[i].content);
        }
      } else {
        refs2.push(reflist[i].content);
      }
    }
  }
  ret = [];
  for(var j=0; j<errors.length; j++) {
    ret.push({'msg':'cite-samecontent-error', 'err':errors[j]});
  }
  return ret;
}}
);

new citeErrorCheck({'type':'reflist', 'testname':'repeated', 'desc':'cite-repeated-desc',
'func': function(reflist) {
  var errors = [];
  var refs2 = [];
  for(var i=0; i<reflist.length; i++) {
    if (!reflist[i].shorttag && reflist[i].refname) {
      if ($.inArray(reflist[i].refname, refs2) != -1) {
        if ($.inArray(reflist[i].refname, errors) == -1) {
          errors.push(reflist[i].refname);
        }
      } else {
        refs2.push(reflist[i].refname);
      }
    }
  }
  ret = [];
  for(var j=0; j<errors.length; j++) {
    ret.push({'msg':'cite-repeated-error', 'err':errors[j]});
  }
  return ret;
}}
);

new citeErrorCheck({'type':'reflist', 'testname':'undefined', 'desc':'cite-undefined-desc',
'func': function(reflist) {
  var errors = [];
  var longrefs = [];
  for(var i=0; i<reflist.length; i++) {
    if (!reflist[i].shorttag && reflist[i].refname) {
      longrefs.push(reflist[i].refname);
    }
  }
  for(var j=0; i<reflist.length; j++) {
    if (reflist[i].shorttag && $.inArray(reflist[i].refname, errors) == -1 && $.inArray(reflist[i].refname, longrefs) == -1) {
      errors.push(reflist[i].refname);
    }
  }
  ret = [];
  for(var j=0; j<errors.length; j++) {
    ret.push({'msg':'cite-undefined-error', 'err':errors[j]});
  }
  return ret;
}}
);

CiteTB.init();
//</nowiki>