User:Jmfayard/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:Jmfayard/monobook.css. |
// <pre>
function DefaultTranslationPage(page_name)
{
alert(page_name);
if (
(page_name.indexOf('Wikipedia:Translation/ ') == -1) &&
(page_name.indexOf('Wikipedia:Translation/_')== -1)
) {
var c1 = "";
c1 += "{{subst:Translation/Initialization|{{subst:SUBPAGENAME}}|~~~~|\n" ;
c1 += "<!--\n" ;
c1 += " Follow the instructions below to propose a translation. \n" ;
c1 += "\n" ;
c1 += " WARNING: Do not erase!\n" ;
c1 += "-->\n" ;
c1 += "\n" ;
c1 += "\n" ;
c1 += "1. Indicate the original language of the article here (for example: de fr ja es it pt...)\n" ;
c1 += "|two-letter language code|\n" ;
c1 += "\n" ;
c1 += "2. Type the name of the original article here (for example: Liberté)\n" ;
c1 += "|Original name here|\n" ;
c1 += "\n" ;
c1 += "3. Please briefly explain why this article is worth translating\n" ;
c1 += "|reason here|\n" ;
c1 += "\n" ;
c1 += "4. Please leave a comment if you wish to do so\n" ;
c1 += "|comment here|\n" ;
c1 += "\n" ;
c1 += "| 5. You're done! You may now save this page.\n" ;
c1 += "\n" ;
c1 += "}\n" ;
return c1;
} else {
return "";
}
}
function InitTranslationPage()
{
// TODO, il faut tester l'existence de l'edit box et la longueur
// du texte en dehors de la boucle
ugly_url = 'http://en.wikipedia.org/w/index.php?title=';
var page_name = document.URL;
var page_match = "Wikipedia:Translation/";
var index = page_name.indexOf(ugly_url + page_match);
if (index != -1) {
var text_area = document.editform.wpTextbox1;
if (text_area.value.length == 0) {
page_name = page_name.slice((ugly_url + page_match).length);
page_name = page_name.split('&')[0];
page_name = decodeURI(page_name);
page_name = page_name.replace(/_/g, ' ')
text_area.value = DefaultTranslationPage(page_name);
}
}
}
addOnloadHook( InitTranslationPage )
// </pre>