MediaWiki:RefToolbar.js: Versiyalar orasidagi farq
Kontent oʻchirildi Kontent qoʻshildi
Maintenance: mw:RL/MGU / mw:RL/JD - phab:T169385 - deprecated in jQuery 3.0 |
Tahrir izohi yoʻq |
||
Qator 1:
/*jshint smarttabs:true, loopfunc:true,forin:false*/
/*global mw, $, importScript */
// ____________________________________________________________________________________________
// | |
// | refToolbar.js gadjetining 632049119 versiyasiga asoslangan |
// | (https://en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbar.js&oldid=795320777) |
// |____________________________________________________________________________________________|
// TODO: make autodate an option in the CiteTemplate object, not a preference
Qator 265 ⟶ 270:
$(document).ready( function() {
switch( mw.config.get('wgUserLanguage') ) {
case '
importScript('MediaWiki:RefToolbarMessages-en.js');
break;
default:
importScript('MediaWiki:RefToolbarMessages-ru.js');
}
});
Qator 438 ⟶ 443:
// Function to get the page text
CiteTB.getPageText = function(callback) {
if (CiteTB.getOption('expandtemplates')) {
CiteTB.expandtemplates($('#wpTextbox1').wikiEditor('getContents').text(), callback);
Qator 458 ⟶ 448:
callback($('#wpTextbox1').wikiEditor('getContents').text());
}
};
// Autofill a template from an ID (ISBN, DOI, PMID, URL)
CiteTB.initAutofill = function() {
var elemid = $(this).attr('id');
Qator 488 ⟶ 477:
var i,j, coauthors;
$('.'+cl+'title').val(data.title);
// Fill in authors
if (data.authors && data.authors.length > 0) {
if ($('.'+cl+'last-incr-1').length != 0) {
var group = false;
if (patt.exec(classes[c])) {
group = patt.exec(classes[c])[1];
break;
}
}
$('.'+cl+'last-incr-1').val(data.authors[0][0])
elemid = '#cite-incr-'+template+'-'+group;
$('.'+cl+' $('.'+cl+'first-incr-'+i.toString()).val(data.authors[i-1][1])
}
var classes = $('.'+cl+'author-incr-1').eq(0).attr('class').split(/\s+/);
var group = false;
var patt = /cite-[^-]*?-incr-(.*)/ } else if ($('.'+cl+'last1').length != 0) {
if ($('.'+cl+'last'+(i+1)).length) {
$('.'+cl+'first'+(i+1)).val(data.authors[i][1]);
} else {
coauthors.push(data.authors[j].join(', '));
}
$('.'+cl+'coauthors').val(coauthors.join('; '));
break;
}
}
} else if($('.'+cl+'author1').length !== 0) {
for(i=0; data.authors && i<data.authors.length; i++) {
if ($('.'+cl+'author'+(i+1)).length) {
$('.'+cl+'author'+(i+1)).val(data.authors[i].join(', '));
} else {
coauthors = [];
for(j=i; j<data.authors.length; j++) {
coauthors.push(data.authors[j].join(', '));
}
$('.'+cl+'coauthors').val(coauthors.join('; '));
break;
}
}
} else {
var
}
$('.'+cl+'
}
}
if (type === 'pmid' || type === 'doi') {
if (data.date && (data.fulldate || !$('.'+cl+'month').length)) {
var DT = new Date(data.date);
var useday = /\d{4}-\d{2}-\d{2}/.test(data.date);
Qator 574 ⟶ 567:
$('.'+cl+'issue').val(data.issue);
$('.'+cl+'pages').val(data.pages);
if (type === 'pmid' && data.doi) {
$('.'+cl+'doi').val(data.doi);
}
} else if (type === 'isbn') {
$('.'+cl+'publisher').val(data.publisher);
Qator 579 ⟶ 575:
$('.'+cl+'year').val(data.year);
$('.'+cl+'edition').val(data.edition);
} else if (type === 'url') {
if (data.date) {
var DT = new Date(data.date);
var useday = /\d{4}-\d{2}-\d{2}/.test(data.date) && template !== 'book';
var usemonth = /\d{4}-\d{2}/.test(data.date) && template !== 'book';
var yearOrDate = (template === 'book') ? 'year' : 'date';
$('.'+cl+yearOrDate).val(CiteTB.formatDate(DT, useday, usemonth));
}
$('.'+cl+'journal').val(data.journal);
$('.'+cl+'volume').val(data.volume);
$('.'+cl+'issue').val(data.issue);
$('.'+cl+'pages').val(data.pages);
$('.'+cl+'publisher').val(data.publisher);
$('.'+cl+'edition').val(data.edition);
$('.'+cl+'isbn').val(data.isbn);
$('.'+cl+'issn').val(data.issn);
$('.'+cl+'doi').val(data.doi);
// "en-US" isn't a valid value for the language parameter
if (data.language && data.language !== 'ru-RU' ) {
$('.'+cl+'language').val(data.language);
}
$('.'+cl+'chapter').val(data.chapter);
}
};
Qator 807 ⟶ 825:
// Returns a string quoted as necessary for name/group attributes
CiteTB.getQuotedString = function(s) {
var sq = /\'/.test(s); // single quotes
var dq = /\"/.test(s); // double quotes
if (
return '"'+s+'"';
} else if (!dq) { // Can use double quotes
return '"'+s+'"';
Qator 817 ⟶ 834:
return "'"+s+"'";
} else { // Has double and single quotes
s = s.replace(/\"/g, '\
return '"'+s+'"';
}
|