Jump to content

User:Jmfayard/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jmfayard (talk | contribs) at 00:07, 8 November 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <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>