User:Thetrick/tfd helper/userfy.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. |
Documentation for this user script can be added at User:Thetrick/tfd helper/userfy. |
//<pre><nowiki>
/**************** Userfy ****************/
/* userfication of templates - advanced */
importScript("User:Thetrick/tfd_helper/automodtfdh.js");
/* this function runs at load */
function userfy_helper() {
/* call auto mod first, exit if it did processing */
if (auto_mod_tfdh())
return;
if (wgCanonicalNamespace == 'Template' && wgIsArticle == true) {
amtfdh_add_li('tb', 'javascript:userfy_template("req")', 'Userfy: request', 'usrf1', 'Request that a user move this template into their user pages');
amtfdh_add_li('tb', 'javascript:userfy_template("not")', 'Userfy: notify', 'usrf2', 'Notify a user that this template has been userfied');
//amtfdh_add_li('tb', 'javascript:userfy_template("do")', 'Userfy: perform', 'usrf3', 'Userfy this template and notify user');
}
}
/* usrf1, usrf2, usrf3 - deal with userfication */
function userfy_template(userfy) {
var userfy_name = window.prompt("Enter the name of the user (e.g. Fred or PunkerDude999)", "");
if (!userfy_name)
return;
if (userfy == "req") {
window.location.href = amtfdh_make_url('User_talk:' + userfy_name, '', '\n\n{{subst:User:Thetrick/Userfy-request|' + wgTitle + '|' + userfy_name + '}}', 'Request for template move');
} else if (userfy == "not") {
var userfy_page = window.prompt("Enter the name of the new page (e.g. Yourtemplate or Sandbox/Templatehere)");
if (!userfy_page)
return;
window.location.href = amtfdh_make_url('User_talk:' + userfy_name, '', '\n\n{{subst:User:Thetrick/Userfied|' + wgTitle + '|' + userfy_name + '/' + userfy_page + '}}', 'Notification of template move');
} else if (userfy == "do") {
var userfy_page = window.prompt("Enter the name of the new page (e.g. Yourtemplate or Sandbox/Templatehere)");
if (!userfy_page)
return;
var movewindow = window.open("http://en.wikipedia.org/wiki/Special:MovePage/" + wgPageName, "usrfy1");
//movewindow.setfocus;
movewindow.getElementById('wpNewTitle').value = 'User:/' + userfy_name + '/' + userfy_page;
//window.location.href = amtfdh_make_url('User_talk:' + userfy_name, '', '\n\n{{subst:User:Thetrick/Userfied|' + wgTitle + '|' + userfy_name + '/' + userfy_page + '}}' + "&tfdpreview=true", 'Notification of template move');
}
}
/* run a register function */
$(userfy_helper);
//bits of test code sit here
// var yes_no = window.prompt('Here is the url', am_make_url(here, here, here, here));
// return;
//</nowiki></pre>