MediaWiki:Gadget-twinkleconfig.js: Difference between revisions

m
1 revision imported
m (1 revision imported)
m (1 revision imported)
(One intermediate revision by the same user not shown)
Line 9: Line 9:
  *** twinkleconfig.js: Preferences module
  *** twinkleconfig.js: Preferences module
  ****************************************
  ****************************************
  * Mode of invocation:    Adds configuration form to Sarkarverse:Twinkle/Preferences and user  
  * Mode of invocation:    Adds configuration form to Wikipedia:Twinkle/Preferences and user
                           subpages named "/Twinkle preferences", and adds ad box to the top of user  
                           subpages named "/Twinkle preferences", and adds ad box to the top of user
                           subpages belonging to the currently logged-in user which end in '.js'
                           subpages belonging to the currently logged-in user which end in '.js'
  * Active on:              What I just said.  Yeah.
  * Active on:              What I just said.  Yeah.
Line 33: Line 33:
g1: "G1", g2: "G2", g3: "G3", g4: "G4", g5: "G5", g6: "G6", g7: "G7", g8: "G8", g10: "G10", g11: "G11", g12: "G12", g13: "G13",
g1: "G1", g2: "G2", g3: "G3", g4: "G4", g5: "G5", g6: "G6", g7: "G7", g8: "G8", g10: "G10", g11: "G11", g12: "G12", g13: "G13",
a1: "A1", a2: "A2", a3: "A3", a5: "A5", a7: "A7", a9: "A9", a10: "A10", a11: "A11",
a1: "A1", a2: "A2", a3: "A3", a5: "A5", a7: "A7", a9: "A9", a10: "A10", a11: "A11",
u1: "U1", u2: "U2", u3: "U3",
u1: "U1", u2: "U2", u3: "U3", u5: "U5",
f1: "F1", f2: "F2", f3: "F3", f7: "F7", f8: "F8", f9: "F9", f10: "F10",
f1: "F1", f2: "F2", f3: "F3", f7: "F7", f8: "F8", f9: "F9", f10: "F10",
c1: "C1",
c1: "C1",
Line 44: Line 44:
"g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g10", "g11", "g12", "g13",
"g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g10", "g11", "g12", "g13",
"a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11",
"a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11",
"u1", "u2", "u3",
"u1", "u2", "u3", "u5",
"f1", "f2", "f3", "f7", "f8", "f9", "f10",
"f1", "f2", "f3", "f7", "f8", "f9", "f10",
"c1",
"c1",
Line 56: Line 56:
g10: "G10", g11: "G11", g12: "G12", g13: "G13",
g10: "G10", g11: "G11", g12: "G12", g13: "G13",
a1: "A1", a2: "A2", a3: "A3", a5: "A5", a7: "A7", a9: "A9", a10: "A10", a11: "A11",
a1: "A1", a2: "A2", a3: "A3", a5: "A5", a7: "A7", a9: "A9", a10: "A10", a11: "A11",
u3: "U3",
u3: "U3", u5: "U5",
f1: "F1", f2: "F2", f3: "F3", f7: "F7", f8: "F8", f9: "F9", f10: "F10",
f1: "F1", f2: "F2", f3: "F3", f7: "F7", f8: "F8", f9: "F9", f10: "F10",
c1: "C1",
c1: "C1",
Line 67: Line 67:
"g1", "g2", "g3", "g4", "g6", "g10", "g11", "g12", "g13",
"g1", "g2", "g3", "g4", "g6", "g10", "g11", "g12", "g13",
"a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11",
"a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11",
"u3",
"u3", "u5",
"f1", "f2", "f3", "f7", "f9", "f10",
"f1", "f2", "f3", "f7", "f9", "f10",
"c1",
"c1",
Line 78: Line 78:
g1: "G1", g2: "G2", g3: "G3", g4: "G4", g5: "G5", g6: "G6", g7: "G7", g8: "G8", g10: "G10", g11: "G11", g12: "G12", g13: "G13",
g1: "G1", g2: "G2", g3: "G3", g4: "G4", g5: "G5", g6: "G6", g7: "G7", g8: "G8", g10: "G10", g11: "G11", g12: "G12", g13: "G13",
a1: "A1", a2: "A2", a3: "A3", a5: "A5", a7: "A7", a9: "A9", a10: "A10", a11: "A11",
a1: "A1", a2: "A2", a3: "A3", a5: "A5", a7: "A7", a9: "A9", a10: "A10", a11: "A11",
u1: "U1", u2: "U2", u3: "U3",
u1: "U1", u2: "U2", u3: "U3", u5: "U5",
f1: "F1", f2: "F2", f3: "F3", f4: "F4", f5: "F5", f6: "F6", f7: "F7", f8: "F8", f9: "F9", f10: "F10", f11: "F11",
f1: "F1", f2: "F2", f3: "F3", f4: "F4", f5: "F5", f6: "F6", f7: "F7", f8: "F8", f9: "F9", f10: "F10", f11: "F11",
c1: "C1",
c1: "C1",
Line 89: Line 89:
"g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g10", "g11", "g12", "g13",
"g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g10", "g11", "g12", "g13",
"a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11",
"a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11",
"u1", "u2", "u3",
"u1", "u2", "u3", "u5",
"f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11",
"f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11",
"c1",
"c1",
Line 117: Line 117:
"108": "Book",
"108": "Book",
"109": "Book talk",
"109": "Book talk",
"118": "Draft",
"119": "Draft talk",
"710": "TimedText",
"710": "TimedText",
"711": "TimedText talk",
"711": "TimedText talk",
Line 200: Line 202:
name: "dialogLargeFont",
name: "dialogLargeFont",
label: "Use larger text in Twinkle dialogs",
label: "Use larger text in Twinkle dialogs",
type: "boolean"
}
]
},
{
title: "ARV",
preferences: [
{
name: "spiWatchReport",
label: "Add sockpuppet report pages to watchlist",
type: "enum",
enumValues: Twinkle.config.commonEnums.watchlist
}
]
},
{
title: "Block user",
adminOnly: true,
preferences: [
// TwinkleConfig.blankTalkpageOnIndefBlock (boolean)
// if true, blank the talk page when issuing an indef block notice (per [[WP:UW#Indefinitely blocked users]])
{
name: "blankTalkpageOnIndefBlock",
label: "Blank the talk page when indefinitely blocking users",
helptip: "See <a href=\"" + mw.util.getUrl("WP:UW#Indefinitely blocked users") + "\">WP:UW</a> for more information.",
type: "boolean"
type: "boolean"
}
}
Line 597: Line 626:
"6": "Single-issue notices",
"6": "Single-issue notices",
"7": "Single-issue warnings",
"7": "Single-issue warnings",
"9": "Custom warnings",
"9": "Custom warnings"
"8": "Block (admin only)"
}
}
},
},
Line 620: Line 648:
},
},


// TwinkleConfig.blankTalkpageOnIndefBlock (boolean)
// if true, blank the talk page when issuing an indef block notice (per [[WP:UW#Indefinitely blocked users]])
{
name: "blankTalkpageOnIndefBlock",
label: "Blank the talk page when indefinitely blocking users",
helptip: "See <a href=\"" + mw.util.wikiGetlink("WP:UW#Indefinitely blocked users") + "\">WP:UW</a> for more information.",
adminOnly: true,
type: "boolean"
},
{
{
name: "customWarningList",
name: "customWarningList",
Line 837: Line 856:
(mw.config.get("wgNamespaceNumber") === mw.config.get("wgNamespaceIds").user && mw.config.get("wgTitle").lastIndexOf("/Twinkle preferences") === (mw.config.get("wgTitle").length - 20))) &&
(mw.config.get("wgNamespaceNumber") === mw.config.get("wgNamespaceIds").user && mw.config.get("wgTitle").lastIndexOf("/Twinkle preferences") === (mw.config.get("wgTitle").length - 20))) &&
mw.config.get("wgAction") === "view") {
mw.config.get("wgAction") === "view") {
// create the config page at Sarkarverse:Twinkle/Preferences, and at user subpages (for testing purposes)
// create the config page at Wikipedia:Twinkle/Preferences, and at user subpages (for testing purposes)


if (!document.getElementById("twinkle-config")) {
if (!document.getElementById("twinkle-config")) {
Line 853: Line 872:
var contentnotice = document.createElement("p");
var contentnotice = document.createElement("p");
// I hate innerHTML, but this is one thing it *is* good for...
// I hate innerHTML, but this is one thing it *is* good for...
contentnotice.innerHTML = "<b>Before modifying your preferences here,</b> make sure you have removed any old <code>TwinkleConfig</code> and <code>FriendlyConfig</code> settings from your <a href=\"" + mw.util.wikiGetlink("Special:MyPage/skin.js") + "\" title=\"Special:MyPage/skin.js\">user JavaScript file</a>.";
contentnotice.innerHTML = "<b>Before modifying your preferences here,</b> make sure you have removed any old <code>TwinkleConfig</code> and <code>FriendlyConfig</code> settings from your <a href=\"" + mw.util.getUrl("Special:MyPage/skin.js") + "\" title=\"Special:MyPage/skin.js\">user JavaScript file</a>.";
contentdiv.appendChild(contentnotice);
contentdiv.appendChild(contentnotice);


Line 1,118: Line 1,137:
// convert mentions of templates in the helptip to clickable links
// convert mentions of templates in the helptip to clickable links
cell.innerHTML = pref.helptip.replace(/{{(.+?)}}/g,
cell.innerHTML = pref.helptip.replace(/{{(.+?)}}/g,
'{{<a href="' + mw.util.wikiGetlink("Template:") + '$1" target="_blank">$1</a>}}');
'{{<a href="' + mw.util.getUrl("Template:") + '$1" target="_blank">$1</a>}}');
}
}
// add reset link (custom lists don't need this, as their config value isn't displayed on the form)
// add reset link (custom lists don't need this, as their config value isn't displayed on the form)
Line 1,198: Line 1,217:
}
}
link = document.createElement("a");
link = document.createElement("a");
link.setAttribute("href", mw.util.wikiGetlink(mw.config.get("wgFormattedNamespaces")[mw.config.get("wgNamespaceIds").project] + ":Twinkle/Preferences") );
link.setAttribute("href", mw.util.getUrl(mw.config.get("wgFormattedNamespaces")[mw.config.get("wgNamespaceIds").project] + ":Twinkle/Preferences") );
link.appendChild(document.createTextNode("Twinkle preferences panel"));
link.appendChild(document.createTextNode("Twinkle preferences panel"));
box.appendChild(link);
box.appendChild(link);
Line 1,210: Line 1,229:
box.appendChild(document.createTextNode("If you want to set Twinkle preferences, you can use the "));
box.appendChild(document.createTextNode("If you want to set Twinkle preferences, you can use the "));
link = document.createElement("a");
link = document.createElement("a");
link.setAttribute("href", mw.util.wikiGetlink(mw.config.get("wgFormattedNamespaces")[mw.config.get("wgNamespaceIds").project] + ":Twinkle/Preferences") );
link.setAttribute("href", mw.util.getUrl(mw.config.get("wgFormattedNamespaces")[mw.config.get("wgNamespaceIds").project] + ":Twinkle/Preferences") );
link.appendChild(document.createTextNode("Twinkle preferences panel"));
link.appendChild(document.createTextNode("Twinkle preferences panel"));
box.appendChild(link);
box.appendChild(link);
Line 1,747: Line 1,766:
noticebox.style.fontSize = "100%";
noticebox.style.fontSize = "100%";
noticebox.style.marginTop = "2em";
noticebox.style.marginTop = "2em";
noticebox.innerHTML = "<p><b>Your Twinkle preferences have been saved.</b></p><p>To see the changes, you will need to <b>clear your browser cache entirely</b> (see <a href=\"" + mw.util.wikiGetlink("WP:BYPASS") + "\" title=\"WP:BYPASS\">WP:BYPASS</a> for instructions).</p>";
noticebox.innerHTML = "<p><b>Your Twinkle preferences have been saved.</b></p><p>To see the changes, you will need to <b>clear your browser cache entirely</b> (see <a href=\"" + mw.util.getUrl("WP:BYPASS") + "\" title=\"WP:BYPASS\">WP:BYPASS</a> for instructions).</p>";
Morebits.status.root.appendChild(noticebox);
Morebits.status.root.appendChild(noticebox);
var noticeclear = document.createElement("br");
var noticeclear = document.createElement("br");