לדלג לתוכן

מדיה ויקי:Gadget-UserMessages.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
shorten comment lines for better readability
major update: now 30 templates supported, including templates that require parameters
שורה 5: שורה 5:
'Please link'. Clicking any of the buttons will add one of the following templates to
'Please link'. Clicking any of the buttons will add one of the following templates to
the user's talk page, signed by you:
the user's talk page, signed by you:
*{{tl|welcome}}
*{{tl|attackimage}}*
*{{tl|test}}, {{tl|test2}}, {{tl|test3}}, and {{tl|test4}}
*{{tl|attackpage}}*
*{{tl|be civil final}}
*{{tl|be civil}}
*{{tl|blocked user}}
*{{tl|copyvionote}}*
*{{tl|do not overwrite}}*
*{{tl|dont recreate}}*
*{{tl|dont remove delete}}
*{{tl|dont remove nsd or nld}}
*{{tl|dont remove nsd or nld}}
*{{tl|dont remove speedy}}
*{{tl|dont remove speedy}}
*{{tl|dont remove warnings}}
*{{tl|dont remove warnings}}
*{{tl|end of copyvios}}
*{{tl|end of copyvios}}
*{{tl|imposter}}*
*{{tl|inappropriate username}}
*{{tl|off topic}}
*{{tl|please describe images}}
*{{tl|please describe images}}
*{{tl|please link images}}
*{{tl|please name images}}
*{{tl|please tag images}}
*{{tl|please tag images}}
*{{tl|please name images}}
*{{tl|please link images}}
*{{tl|be civil}}
*{{tl|be civil final}}
*{{tl|project scope}}
*{{tl|project scope}}
*{{tl|inappropriate username}}
*{{tl|Provide better quality}}*
*{{tl|sockpuppet}}*
*{{tl|test}}
*{{tl|test2}}
*{{tl|test3}}
*{{tl|test4}}
*{{tl|unfree}}*
*{{tl|welcome}}


Alternatively you can place a template in a user's language. Click the link 'lang' and
Alternatively you can place some templates in a user's language. Templates marked
fill in a language code to have a localised version of the template put on the talk
with an asterisk (*) use a parameter and can be translated, but cannot be localised
page.
on the user page with the script. Click the link 'lang' and fill in a language code
to have a localised version of the template put on the talk page.


Main code by [[User:Siebrand]], derived from [[MediaWiki:Quick-delete.js]] by
Main code by [[User:Siebrand]], derived from [[MediaWiki:Quick-delete.js]] by
שורה 29: שורה 45:


===TODO===
===TODO===
* Add parameter support (required for templates that cannot currently be supported because
* Add remaining templates from[[Commons:Message templates]]:
  they need an additional parameter to work)
* Add remaining templates from[[Commons:Message templates]] not requiring an additional parameter:
**{{tl|dont remove delete}}
**{{tl|do not overwrite}} (also accepts a parameter; how to solve?)
**{{tl|Provide better quality}} (also accepts a parameter; how to solve?)
 
* Add remaining templates from[[Commons:Message templates]] requiring an additional parameter:
**{{tl|dont recreate}}
**{{tl|blocked user}}
**{{tl|sockpuppet}}
**{{tl|speedywhat}}
**{{tl|speedywhat}}
**{{tl|copyvionote}}
**{{tl|unfree}}
**{{tl|attackpage}}
**{{tl|attackimage}}
**{{tl|imposter}}
<pre>
<pre>
*/
*/
שורה 53: שורה 54:
if(window.template_autosave == false){}else{ template_autosave = true; }
if(window.template_autosave == false){}else{ template_autosave = true; }


// String constants
// String constants
var uTemplate = new Array(17)
var uTemplate = new Array(29)
uTemplate[0] = 'Please describe images'
uTemplate[0] = 'Please describe images'
uTemplate[1] = 'Dont remove nsd or nld'
uTemplate[1] = 'Dont remove nsd or nld'
שורה 72: שורה 73:
uTemplate[15] = 'Project scope'
uTemplate[15] = 'Project scope'
uTemplate[16] = 'Inappropriate username'
uTemplate[16] = 'Inappropriate username'
uTemplate[17] = 'Copyvionote'
uTemplate[18] = 'Attackpage'
uTemplate[19] = 'Attackimage'
uTemplate[20] = 'Dont remove delete'
uTemplate[21] = 'Provide better quality'
uTemplate[22] = 'Dont recreate'
uTemplate[23] = 'Blocked User'
uTemplate[24] = 'Sockpuppet'
uTemplate[25] = 'Unfree'
uTemplate[26] = 'Imposter'
uTemplate[27] = 'Do not overwrite'
uTemplate[28] = 'Off topic'


var uText = new Array(17)
var uText = new Array(29)
uText[0] = "Please describe"
uText[0] = "Please describe"
uText[1] = "Rem.n(slp)d"
uText[1] = "Rem.n(slp)d"
שורה 90: שורה 103:
uText[14] = "Be civil final"
uText[14] = "Be civil final"
uText[15] = "Project scope"
uText[15] = "Project scope"
uText[16] = "Inappropriate username"
uText[16] = "Inapp.username"
uText[17] = "Copyvionote"
uText[18] = "Attackpage"
uText[19] = "Attackimage"
uText[20] = "Rem.Delete"
uText[21] = "Better quality"
uText[22] = "Don\'t recreate"
uText[23] = "Blocked"
uText[24] = "Sockpuppet"
uText[25] = "Unfree"
uText[26] = "Imposter"
uText[27] = "Dont overwrite"
uText[28] = "Off topic"


var uHelp = new Array(17)
var uHelp = new Array(29)
uHelp[0] = "Request user to please describe his images"
uHelp[0] = "Request user to please describe his images"
uHelp[1] = "Reminder to not remove deletion templates unless all information is complete. Notifying user has reverted removal somewhere"
uHelp[1] = "Reminder to not remove deletion templates unless all information is complete. Notifying user has reverted removal somewhere"
שורה 110: שורה 135:
uHelp[15] = "Inform user on project scope after deleting out of scope contributions"
uHelp[15] = "Inform user on project scope after deleting out of scope contributions"
uHelp[16] = "Inform user about his inappropriate username and block"
uHelp[16] = "Inform user about his inappropriate username and block"
uHelp[17] = "Inform user about speedy deletion of uploaded media"
uHelp[18] = "Please do not create attack pages"
uHelp[19] = "Please do not upload attack images"
uHelp[20] = "Please do not remove deletion requests"
uHelp[21] = "Do you have a better version of media"
uHelp[22] = "Please do not recreate deleted images"
uHelp[23] = "This user has been blocked - without parameters - use manual version for more paras"
uHelp[24] = "It is suspected that this user may be a sock puppet or impersonator"
uHelp[25] = "Image deletion notification"
uHelp[26] = "This account has been blocked indefinitely, because it exists solely to impersonate or attack"
uHelp[27] = "Please do not overwrite images"
uHelp[28] = "Please stay on topic in Commons"


template_lang = "lang?";
template_lang = "lang?";
template_langquery = "In which language should the message be given? "+
template_langquery = "In which language should the message be given? " +
"Example: en for English, de for German, es for Spanish, etc. " +
"Example: en for English, de for German, es for Spanish, etc. " +
"If the language does not exist for the template, a red link will be inserted. ";
"If the language does not exist for the template, a red link will be inserted. ";
template_mediaquery = "Which media is this message about? " +
"Example: \\'Image Name.ext\\' - omit namespace.";
template_mediaquery2 = "Which media is this message about? " +
"Example: \\'Image Name.ext\\' - omit namespace. Leave empty to not specify";
template_pagequery = "Which page is this message about? " +
"Example: \\'Page_Name\\'.";
template_usernamequery = "Which user should the message refer to?";


// Site info
// Site info
שורה 189: שורה 233:
   if (getParamValue('template_lang')) {
   if (getParamValue('template_lang')) {
           template = template + '/' + getParamValue('template_lang');
           template = template + '/' + getParamValue('template_lang');
  }
  var txt = '{{subst:' + template + '}}';
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + ' ~~~~';
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'Adding template \"' + template + '\" to inform user.';
  if (template_autosave) document.editform.wpSave.click();
}
// Add the template
function template_mark2(talkpage_fakeaction, media_name, can_handle_empty_parameter) {
  if (media_name == null) return; // User pressed cancel
  if (media_name == '' && can_handle_empty_parameter != 1) return; //User did not supply parameter and template cannot handle that
  // Parameter handling for special cases
  if ((talkpage_fakeaction == '21' || talkpage_fakeaction == '27') && media_name != '') media_name = 'Image:' + media_name;
  var pagename = encodeURIComponent(wgPageName);
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&media_name=' + media_name;
}
// Add template to user talk page
function template_addTemplate2(template) {
  if (getParamValue('media_name')) {
          template = template + '|' + getParamValue('media_name');
   }
   }


שורה 200: שורה 269:
function template_onload() {
function template_onload() {
   if (wgNamespaceNumber == 3) { //NS_USERTALK
   if (wgNamespaceNumber == 3) { //NS_USERTALK
    addLink('p-tb', 'javascript:template_mark(\'0\', \'en\')', uText[0], 'mark-please', uHelp[0], null, null, 'javascript:template_mark(\'0\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'3\', \'en\')', uText[3], 'mark-please', uHelp[3], null, null, 'javascript:template_mark(\'3\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'3\', \'en\')', uText[3], 'mark-please', uHelp[3], null, null, 'javascript:template_mark(\'3\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'4\', \'en\')', uText[4], 'mark-please', uHelp[4], null, null, 'javascript:template_mark(\'4\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'4\', \'en\')', uText[4], 'mark-please', uHelp[4], null, null, 'javascript:template_mark(\'4\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'5\', \'en\')', uText[5], 'mark-please', uHelp[5], null, null, 'javascript:template_mark(\'5\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'5\', \'en\')', uText[5], 'mark-please', uHelp[5], null, null, 'javascript:template_mark(\'5\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'1\', \'en\')', uText[1], 'mark-warn',   uHelp[1], null, null, 'javascript:template_mark(\'1\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'0\', \'en\')', uText[0], 'mark-please', uHelp[0], null, null, 'javascript:template_mark(\'0\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'15\', \'en\')', uText[15], 'mark-please', uHelp[15], null, null, 'javascript:template_mark(\'15\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'10\', \'en\')', uText[10], 'mark-welcome', uHelp[10], null, null, 'javascript:template_mark(\'10\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'2\', \'en\')', uText[2], 'mark-warn',  uHelp[2], null, null, 'javascript:template_mark(\'2\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'2\', \'en\')', uText[2], 'mark-warn',  uHelp[2], null, null, 'javascript:template_mark(\'2\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'28\', \'en\')', uText[28], 'mark-warn', uHelp[28], null, null, 'javascript:template_mark(\'28\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'6\', \'en\')', uText[6], 'mark-warn',  uHelp[6], null, null, 'javascript:template_mark(\'6\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'6\', \'en\')', uText[6], 'mark-warn',  uHelp[6], null, null, 'javascript:template_mark(\'6\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'7\', \'en\')', uText[7], 'mark-warn',  uHelp[7], null, null, 'javascript:template_mark(\'7\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'7\', \'en\')', uText[7], 'mark-warn',  uHelp[7], null, null, 'javascript:template_mark(\'7\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'8\', \'en\')', uText[8], 'mark-warn',  uHelp[8], null, null, 'javascript:template_mark(\'8\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'8\', \'en\')', uText[8], 'mark-warn',  uHelp[8], null, null, 'javascript:template_mark(\'8\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'9\', \'en\')', uText[9], 'mark-warn',  uHelp[9], null, null, 'javascript:template_mark(\'9\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'9\', \'en\')', uText[9], 'mark-warn',  uHelp[9], null, null, 'javascript:template_mark(\'9\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'10\', \'en\')', uText[10], 'mark-welcome', uHelp[10], null, null, 'javascript:template_mark(\'10\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'20\', \'en\')', uText[20], 'mark-warn', uHelp[20], null, null, 'javascript:template_mark(\'20\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'1\', \'en\')', uText[1], 'mark-warn',  uHelp[1], null, null, 'javascript:template_mark(\'1\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'11\', \'en\')', uText[11], 'mark-warn', uHelp[11], null, null, 'javascript:template_mark(\'11\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'11\', \'en\')', uText[11], 'mark-warn', uHelp[11], null, null, 'javascript:template_mark(\'11\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'12\', \'en\')', uText[12], 'mark-warn', uHelp[12], null, null, 'javascript:template_mark(\'12\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'12\', \'en\')', uText[12], 'mark-warn', uHelp[12], null, null, 'javascript:template_mark(\'12\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'13\', \'en\')', uText[13], 'mark-warn', uHelp[13], null, null, 'javascript:template_mark(\'13\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'13\', \'en\')', uText[13], 'mark-warn', uHelp[13], null, null, 'javascript:template_mark(\'13\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'14\', \'en\')', uText[14], 'mark-warn', uHelp[14], null, null, 'javascript:template_mark(\'14\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'14\', \'en\')', uText[14], 'mark-warn', uHelp[14], null, null, 'javascript:template_mark(\'14\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'15\', \'en\')', uText[15], 'mark-please', uHelp[15], null, null, 'javascript:template_mark(\'15\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'23\', \'en\')', uText[23], 'mark-warn', uHelp[23], null, null, 'javascript:template_mark(\'23\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'16\', \'en\')', uText[16], 'mark-warn', uHelp[16], null, null, 'javascript:template_mark(\'16\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
     addLink('p-tb', 'javascript:template_mark(\'16\', \'en\')', uText[16], 'mark-warn', uHelp[16], null, null, 'javascript:template_mark(\'16\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark2(\'17\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[17], 'mark-warn', uHelp[17]);
    addLink('p-tb', 'javascript:template_mark2(\'21\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[21], 'mark-warn', uHelp[21]);
    addLink('p-tb', 'javascript:template_mark2(\'25\', prompt(\'' + template_mediaquery2 + '\', \'\'), 1)', uText[25], 'mark-warn', uHelp[25]);
    addLink('p-tb', 'javascript:template_mark2(\'19\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[19], 'mark-warn', uHelp[19]);
    addLink('p-tb', 'javascript:template_mark2(\'18\', prompt(\'' + template_langquery + '\', \'\'), 0)', uText[18], 'mark-warn', uHelp[18]);
    addLink('p-tb', 'javascript:template_mark2(\'27\', prompt(\'' + template_mediaquery2 + '\', \'\'), 1)', uText[27], 'mark-warn', uHelp[27]);
    addLink('p-tb', 'javascript:template_mark2(\'22\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[22], 'mark-warn', uHelp[22]);
    addLink('p-tb', 'javascript:template_mark2(\'26\', prompt(\'' + template_usernamequery + '\', \'\'), 0)', uText[26], 'mark-warn', uHelp[26]);
    addLink('p-tb', 'javascript:template_mark2(\'24\', prompt(\'' + template_usernamequery + '\', \'\'), 0)', uText[24], 'mark-warn', uHelp[24]);
   }
   }


שורה 239: שורה 320:
   if (fakeaction == '15'){ template_addTemplate( uTemplate[15] ); }
   if (fakeaction == '15'){ template_addTemplate( uTemplate[15] ); }
   if (fakeaction == '16'){ template_addTemplate( uTemplate[16] ); }
   if (fakeaction == '16'){ template_addTemplate( uTemplate[16] ); }
  if (fakeaction == '17'){ template_addTemplate2( uTemplate[17] ); }
  if (fakeaction == '18'){ template_addTemplate2( uTemplate[18] ); }
  if (fakeaction == '19'){ template_addTemplate2( uTemplate[19] ); }
  if (fakeaction == '20'){ template_addTemplate( uTemplate[20] ); }
  if (fakeaction == '21'){ template_addTemplate2( uTemplate[21] ); }
  if (fakeaction == '22'){ template_addTemplate2( uTemplate[22] ); }
  if (fakeaction == '23'){ template_addTemplate( uTemplate[23] ); }
  if (fakeaction == '24'){ template_addTemplate2( uTemplate[24] ); }
  if (fakeaction == '25'){ template_addTemplate2( uTemplate[25] ); }
  if (fakeaction == '26'){ template_addTemplate2( uTemplate[26] ); }
  if (fakeaction == '27'){ template_addTemplate2( uTemplate[27] ); }
  if (fakeaction == '28'){ template_addTemplate( uTemplate[28] ); }
  }
  }


addOnloadHook(template_onload);
addOnloadHook(template_onload);
// </pre>
// </pre>

גרסה מ־13:21, 4 ביולי 2007

/*
==Automatic user messages ==
Installing this script as described on the talk page will give you links in the toolbox
for all pages in the User talk: namespace, that say 'Please tag', 'Please name', and
'Please link'. Clicking any of the buttons will add one of the following templates to
the user's talk page, signed by you:
*{{tl|attackimage}}*
*{{tl|attackpage}}*
*{{tl|be civil final}}
*{{tl|be civil}}
*{{tl|blocked user}}
*{{tl|copyvionote}}*
*{{tl|do not overwrite}}*
*{{tl|dont recreate}}*
*{{tl|dont remove delete}}
*{{tl|dont remove nsd or nld}}
*{{tl|dont remove speedy}}
*{{tl|dont remove warnings}}
*{{tl|end of copyvios}}
*{{tl|imposter}}*
*{{tl|inappropriate username}}
*{{tl|off topic}}
*{{tl|please describe images}}
*{{tl|please link images}}
*{{tl|please name images}}
*{{tl|please tag images}}
*{{tl|project scope}}
*{{tl|Provide better quality}}*
*{{tl|sockpuppet}}*
*{{tl|test}}
*{{tl|test2}}
*{{tl|test3}}
*{{tl|test4}}
*{{tl|unfree}}*
*{{tl|welcome}}

Alternatively you can place some templates in a user's language. Templates marked
with an asterisk (*) use a parameter and can be translated, but cannot be localised
on the user page with the script. Click the link 'lang' and fill in a language code
to have a localised version of the template put on the talk page.

Main code by [[User:Siebrand]], derived from [[MediaWiki:Quick-delete.js]] by
[[:en:User:Jietse Niesen|Jietse Niesen]], [[User:pfctdayelise|pfctdayelise]] and
[[User:Alphax|Alphax]]

===TODO===
* Add remaining templates from[[Commons:Message templates]]:
**{{tl|speedywhat}}
<pre>
*/
// Configuration

// Should the edits be saved automatically?
if(window.template_autosave == false){}else{ template_autosave = true; }

// String constants
var uTemplate = new Array(29)
uTemplate[0] = 'Please describe images'
uTemplate[1] = 'Dont remove nsd or nld'
uTemplate[2] = 'End of copyvios'
uTemplate[3] = 'Please link images'
uTemplate[4] = 'Please name images'
uTemplate[5] = 'Please tag images'
uTemplate[6] = 'Test'
uTemplate[7] = 'Test2'
uTemplate[8] = 'Test3'
uTemplate[9] = 'Test4'
uTemplate[10] = 'Welcome'
uTemplate[11] = 'Dont remove speedy'
uTemplate[12] = 'Dont remove warnings'
uTemplate[13] = 'Be civil'
uTemplate[14] = 'Be civil final'
uTemplate[15] = 'Project scope'
uTemplate[16] = 'Inappropriate username'
uTemplate[17] = 'Copyvionote'
uTemplate[18] = 'Attackpage'
uTemplate[19] = 'Attackimage'
uTemplate[20] = 'Dont remove delete'
uTemplate[21] = 'Provide better quality'
uTemplate[22] = 'Dont recreate'
uTemplate[23] = 'Blocked User'
uTemplate[24] = 'Sockpuppet'
uTemplate[25] = 'Unfree'
uTemplate[26] = 'Imposter'
uTemplate[27] = 'Do not overwrite'
uTemplate[28] = 'Off topic'

var uText = new Array(29)
uText[0] = "Please describe"
uText[1] = "Rem.n(slp)d"
uText[2] = "End copyvio"
uText[3] = "Please link"
uText[4] = "Please name"
uText[5] = "Please tag"
uText[6] = "Sandboxing"
uText[7] = "Vandalism"
uText[8] = "Vandalism 2"
uText[9] = "Vandalism 3"
uText[10] = "Welcome"
uText[11] = "Rem.speedy"
uText[12] = "Rem.warning"
uText[13] = "Be civil"
uText[14] = "Be civil final"
uText[15] = "Project scope"
uText[16] = "Inapp.username"
uText[17] = "Copyvionote"
uText[18] = "Attackpage"
uText[19] = "Attackimage"
uText[20] = "Rem.Delete"
uText[21] = "Better quality"
uText[22] = "Don\'t recreate"
uText[23] = "Blocked"
uText[24] = "Sockpuppet"
uText[25] = "Unfree"
uText[26] = "Imposter"
uText[27] = "Dont overwrite"
uText[28] = "Off topic"

var uHelp = new Array(29)
uHelp[0] = "Request user to please describe his images"
uHelp[1] = "Reminder to not remove deletion templates unless all information is complete. Notifying user has reverted removal somewhere"
uHelp[2] = "Give user a final warning because of previous copyright violations"
uHelp[3] = "Request user to please link his images through categories or galleries"
uHelp[4] = "Request user to please name his images correctly"
uHelp[5] = "Request user to please tag his images"
uHelp[6] = "Referral to sandbox for conducting experiments"
uHelp[7] = "Warning or vandalism and request to cease"
uHelp[8] = "Second warning for vandalism and announcement of block if it continues"
uHelp[9] = "Last warning for vandalism and annoument of block on next violation"
uHelp[10] = "Welcome a new user or a user who has not yet recieved a welcome message"
uHelp[11] = "Warn a user about having removed a speedy tag from an image and inform him about proper process"
uHelp[12] = "Warn a user about removing valid warning templates from his talk page and inform him about proper process"
uHelp[13] = "Ask a user to remain civil, even if he or his contributions are being attacked"
uHelp[14] = "Last request to user to remain civil. Will be blocked next time"
uHelp[15] = "Inform user on project scope after deleting out of scope contributions"
uHelp[16] = "Inform user about his inappropriate username and block"
uHelp[17] = "Inform user about speedy deletion of uploaded media"
uHelp[18] = "Please do not create attack pages"
uHelp[19] = "Please do not upload attack images"
uHelp[20] = "Please do not remove deletion requests"
uHelp[21] = "Do you have a better version of media"
uHelp[22] = "Please do not recreate deleted images"
uHelp[23] = "This user has been blocked - without parameters - use manual version for more paras"
uHelp[24] = "It is suspected that this user may be a sock puppet or impersonator"
uHelp[25] = "Image deletion notification"
uHelp[26] = "This account has been blocked indefinitely, because it exists solely to impersonate or attack"
uHelp[27] = "Please do not overwrite images"
uHelp[28] = "Please stay on topic in Commons"

template_lang = "lang?";
template_langquery = "In which language should the message be given? " +
"Example: en for English, de for German, es for Spanish, etc. " +
"If the language does not exist for the template, a red link will be inserted. ";
template_mediaquery = "Which media is this message about? " +
"Example: \\'Image Name.ext\\' - omit namespace.";
template_mediaquery2 = "Which media is this message about? " +
"Example: \\'Image Name.ext\\' - omit namespace. Leave empty to not specify";
template_pagequery = "Which page is this message about? " +
"Example: \\'Page_Name\\'.";
template_usernamequery = "Which user should the message refer to?";

// Site info
scriptPath = "/w/index.php";
prettyPath = "/wiki/";
wikiHostname = "commons.wikimedia.org";

// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
function addLink(where, url1, name1, id, title, key, after, url2, name2)
{
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url1 is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name1 is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    //* url2 is a second url to add. Optional
    //
    //*name2 is the name of the second url; defaults to name1. Optional
    var na = document.createElement('a');
    na.href = url1;
    na.appendChild(document.createTextNode(name1));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);

    if (url2) { //Another link, brother of the previous.
       var na = document.createElement('a');
       na.href = url2;
       na.appendChild(document.createTextNode(name2 ? name2 : name1));
       li.appendChild(document.createTextNode(" · ")); //separate them a bit
       li.appendChild(na);
    }

    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];}
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

// Add the template
function template_mark(talkpage_fakeaction, message_lang) {
  if (!message_lang) return; //User pressed cancel

  var pagename = encodeURIComponent(wgPageName);
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&template_lang=' + message_lang;
}

// Add template to user talk page
function template_addTemplate(template) {		
  if (getParamValue('template_lang')) {
          template = template + '/' + getParamValue('template_lang');
  }

  var txt = '{{subst:' + template + '}}';
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + ' ~~~~';
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'Adding template \"' + template + '\" to inform user.';
  if (template_autosave) document.editform.wpSave.click();
}

// Add the template
function template_mark2(talkpage_fakeaction, media_name, can_handle_empty_parameter) {
  if (media_name == null) return; // User pressed cancel
  if (media_name == '' && can_handle_empty_parameter != 1) return; //User did not supply parameter and template cannot handle that
  // Parameter handling for special cases
  if ((talkpage_fakeaction == '21' || talkpage_fakeaction == '27') && media_name != '') media_name = 'Image:' + media_name;

  var pagename = encodeURIComponent(wgPageName);
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  document.location = editlk + '&fakeaction=' + talkpage_fakeaction + '&media_name=' + media_name;
}

// Add template to user talk page
function template_addTemplate2(template) {		
  if (getParamValue('media_name')) {
          template = template + '|' + getParamValue('media_name');
  }

  var txt = '{{subst:' + template + '}}';
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n' + txt + ' ~~~~';
  //  the edit summary for when you mark the image. You can change it if you want.
  document.editform.wpSummary.value = 'Adding template \"' + template + '\" to inform user.';
  if (template_autosave) document.editform.wpSave.click();
}

function template_onload() {
  if (wgNamespaceNumber == 3) { //NS_USERTALK
    addLink('p-tb', 'javascript:template_mark(\'3\', \'en\')', uText[3], 'mark-please', uHelp[3], null, null, 'javascript:template_mark(\'3\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'4\', \'en\')', uText[4], 'mark-please', uHelp[4], null, null, 'javascript:template_mark(\'4\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'5\', \'en\')', uText[5], 'mark-please', uHelp[5], null, null, 'javascript:template_mark(\'5\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'0\', \'en\')', uText[0], 'mark-please', uHelp[0], null, null, 'javascript:template_mark(\'0\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'15\', \'en\')', uText[15], 'mark-please', uHelp[15], null, null, 'javascript:template_mark(\'15\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'10\', \'en\')', uText[10], 'mark-welcome', uHelp[10], null, null, 'javascript:template_mark(\'10\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'2\', \'en\')', uText[2], 'mark-warn',   uHelp[2], null, null, 'javascript:template_mark(\'2\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'28\', \'en\')', uText[28], 'mark-warn', uHelp[28], null, null, 'javascript:template_mark(\'28\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'6\', \'en\')', uText[6], 'mark-warn',   uHelp[6], null, null, 'javascript:template_mark(\'6\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'7\', \'en\')', uText[7], 'mark-warn',   uHelp[7], null, null, 'javascript:template_mark(\'7\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'8\', \'en\')', uText[8], 'mark-warn',   uHelp[8], null, null, 'javascript:template_mark(\'8\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'9\', \'en\')', uText[9], 'mark-warn',   uHelp[9], null, null, 'javascript:template_mark(\'9\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'20\', \'en\')', uText[20], 'mark-warn', uHelp[20], null, null, 'javascript:template_mark(\'20\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'1\', \'en\')', uText[1], 'mark-warn',   uHelp[1], null, null, 'javascript:template_mark(\'1\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'11\', \'en\')', uText[11], 'mark-warn', uHelp[11], null, null, 'javascript:template_mark(\'11\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'12\', \'en\')', uText[12], 'mark-warn', uHelp[12], null, null, 'javascript:template_mark(\'12\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'13\', \'en\')', uText[13], 'mark-warn', uHelp[13], null, null, 'javascript:template_mark(\'13\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'14\', \'en\')', uText[14], 'mark-warn', uHelp[14], null, null, 'javascript:template_mark(\'14\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'23\', \'en\')', uText[23], 'mark-warn', uHelp[23], null, null, 'javascript:template_mark(\'23\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark(\'16\', \'en\')', uText[16], 'mark-warn', uHelp[16], null, null, 'javascript:template_mark(\'16\', prompt(\'' + template_langquery + '\', wgUserLanguage))', template_lang);
    addLink('p-tb', 'javascript:template_mark2(\'17\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[17], 'mark-warn', uHelp[17]);
    addLink('p-tb', 'javascript:template_mark2(\'21\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[21], 'mark-warn', uHelp[21]);
    addLink('p-tb', 'javascript:template_mark2(\'25\', prompt(\'' + template_mediaquery2 + '\', \'\'), 1)', uText[25], 'mark-warn', uHelp[25]);
    addLink('p-tb', 'javascript:template_mark2(\'19\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[19], 'mark-warn', uHelp[19]);
    addLink('p-tb', 'javascript:template_mark2(\'18\', prompt(\'' + template_langquery + '\', \'\'), 0)', uText[18], 'mark-warn', uHelp[18]);
    addLink('p-tb', 'javascript:template_mark2(\'27\', prompt(\'' + template_mediaquery2 + '\', \'\'), 1)', uText[27], 'mark-warn', uHelp[27]);
    addLink('p-tb', 'javascript:template_mark2(\'22\', prompt(\'' + template_mediaquery + '\', \'\'), 0)', uText[22], 'mark-warn', uHelp[22]);
    addLink('p-tb', 'javascript:template_mark2(\'26\', prompt(\'' + template_usernamequery + '\', \'\'), 0)', uText[26], 'mark-warn', uHelp[26]);
    addLink('p-tb', 'javascript:template_mark2(\'24\', prompt(\'' + template_usernamequery + '\', \'\'), 0)', uText[24], 'mark-warn', uHelp[24]);
  }

  var fakeaction = getParamValue('fakeaction');
  var template_type = getParamValue('template_type');	// Fetch what template to add

  if (fakeaction == '0'){ template_addTemplate( uTemplate[0] ); }
  if (fakeaction == '1'){ template_addTemplate( uTemplate[1] ); }
  if (fakeaction == '2'){ template_addTemplate( uTemplate[2] ); }
  if (fakeaction == '3'){ template_addTemplate( uTemplate[3] ); }
  if (fakeaction == '4'){ template_addTemplate( uTemplate[4] ); }
  if (fakeaction == '5'){ template_addTemplate( uTemplate[5] ); }
  if (fakeaction == '6'){ template_addTemplate( uTemplate[6] ); }
  if (fakeaction == '7'){ template_addTemplate( uTemplate[7] ); }
  if (fakeaction == '8'){ template_addTemplate( uTemplate[8] ); }
  if (fakeaction == '9'){ template_addTemplate( uTemplate[9] ); }
  if (fakeaction == '10'){ template_addTemplate( uTemplate[10] ); }
  if (fakeaction == '11'){ template_addTemplate( uTemplate[11] ); }
  if (fakeaction == '12'){ template_addTemplate( uTemplate[12] ); }
  if (fakeaction == '13'){ template_addTemplate( uTemplate[13] ); }
  if (fakeaction == '14'){ template_addTemplate( uTemplate[14] ); }
  if (fakeaction == '15'){ template_addTemplate( uTemplate[15] ); }
  if (fakeaction == '16'){ template_addTemplate( uTemplate[16] ); }
  if (fakeaction == '17'){ template_addTemplate2( uTemplate[17] ); }
  if (fakeaction == '18'){ template_addTemplate2( uTemplate[18] ); }
  if (fakeaction == '19'){ template_addTemplate2( uTemplate[19] ); }
  if (fakeaction == '20'){ template_addTemplate( uTemplate[20] ); }
  if (fakeaction == '21'){ template_addTemplate2( uTemplate[21] ); }
  if (fakeaction == '22'){ template_addTemplate2( uTemplate[22] ); }
  if (fakeaction == '23'){ template_addTemplate( uTemplate[23] ); }
  if (fakeaction == '24'){ template_addTemplate2( uTemplate[24] ); }
  if (fakeaction == '25'){ template_addTemplate2( uTemplate[25] ); }
  if (fakeaction == '26'){ template_addTemplate2( uTemplate[26] ); }
  if (fakeaction == '27'){ template_addTemplate2( uTemplate[27] ); }
  if (fakeaction == '28'){ template_addTemplate( uTemplate[28] ); }
 }

addOnloadHook(template_onload);
// </pre>