মিডিয়াউইকি:Gadget-TemplatePreloader.js: সংশোধিত সংস্করণের মধ্যে পার্থক্য

বিষয়বস্তু বিয়োগ হয়েছে বিষয়বস্তু যোগ হয়েছে
Phe (আলোচনা | অবদান)
typo
Phe (আলোচনা | অবদান)
better handling of Author Name (birth-death) and a few special case, von, van, de and le, Van or Von not handled
২০৫ নং লাইন:
}
 
// When creating an author page try to fill somefield. fieldAlways iffilled, anlastname,
// firstname, lastinitial, wikipedia_link, birth/year filled if an
// article is available on wp:en
function author_fill_cb(data)
২৩৮ ⟶ ২৩৯ নং লাইন:
}
 
function split_title()
/* Preload Template:Author when starting an author page */
function preloadAuthorTemplate()
{
return wgTitle.replace(/ \(.*\)/, "").split(" ");
var wpTextbox1 = document.getElementById("wpTextbox1")
}
if (wpTextbox1.value != "") return;
 
function get_special_word_pos(words)
// try to figure out what value we can fill, broken in some case because
{
// it's difficult to handle name like Tom Van Moore
var words = wgTitle.split(" ")i;
for (i = 0; i < words.length; ++i) {
if (words[i] == 'van' || words[i] == 'von' ||
words[i] == 'le' || words[i] == 'de') {
return i;
}
}
return -1;
}
 
function get_first_name(words)
{
return words.slice(0, get_special_word_pos(words)).join(" ");
}
 
function get_last_name(words)
{
return words.slice(get_special_word_pos(words)).join(" ");
}
 
function get_last_initial(words)
{
// get_last_name() can't be used here, we want the last word or the next
// word following a special word
var lastname = words[words.length - 1];
wordsvar pos = get_special_word_pos(words.slice(0, -1);
varif firstname(pos != -1 && pos < words.join("length - "1);
lastname = words[pos + 1];
 
var last_initial = lastname.slice(0, 2);
// O'Donnel --> Od
if (lastname.length > 2 && last_initial.charAt(1) == "'")
last_initial = last_initial.charAt(0) + lastname.charAt(2).toLowerCase();
return last_initial;
}
 
/* Preload Template:Author when starting an author page, derived from [[User:Remember the dot]] code */
function preloadAuthorTemplate()
{
var wpTextbox1 = document.getElementById("wpTextbox1")
if (wpTextbox1.value != "") return;
 
// try to figure out what value we can fill, broken in some case because
// it's difficult to handle name like Tom Van Moore but Tom van Moore is
// handled correctly.
var words = split_title();
var lastname = get_last_name(words);
var firstname = get_first_name(words);
var last_initial = get_last_initial(words);
 
wpTextbox1.value = "{{" + "{author\n" +
" | firstname = " + firstname + "\n" +
" | lastname = " + lastname + "\n" +