User:Btilm/displaytitle.js: Difference between revisions

Content deleted Content added
me
m Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(3 intermediate revisions by 2 users not shown)
Line 1:
// <nowiki>
addOnloadHook(function()
//created by btilm
addPortletLink(
function adt() {
"p-cactions", //target tab - personal links
var pro2pro = prompt('Enter desiredwanted title.','wgTitle');
javascript:dt(), //link URL
if (pro2 pro==null || pro2pro==wgTitle"" || pro2pro==""wgTitle) {
"dt", //link text
alert('Aborted');
"pt-dt" //id of new button
return};
"dt", //hover text
document.getElementById('editform.wpTextbox1').value = "'{{"DISPLAYTITLE:' + dtpro + "'}}"\n' + document.getElementById('editform.wpTextbox1').value;
"" //???
document.getElementById('editform.wpSummary').value = "'added displaytitle tag"';
));
document.getElementById('editform.wpMinoredit').checked = true;
document.getElementById('editform').submit();
}
addOnloadHook(function() {
if (___location.href.indexOf("&action=edit&dt=") == -1) return;
if (document.editform) {
dtRegExp = /&action=edit&newstatus=(.*)/;
mw.util.addPortletLink("p-cactions", "javascript:adt()", "adt", "ca-adt", "Add Display Title", "");
dt = dtRegExp.exec(___location.href)[1];
}
document.getElementById('wpTextbox1').value = "{{" + dt + "}}" + document.getElementById('wpTextbox1').value;
document.getElementById('wpSummary').value = "added displaytitle tag";
document.getElementById('wpMinoredit').checked = true;
document.getElementById('editform').submit();
});
 
function dtrdt() {
var txt = document.editform.wpTextbox1;
var pro2=prompt('Enter desired title','wgTitle');
txt.value = txt.value.replace(/{{DISPLAYTITLE.*}}\n/gim, "");
if (pro2==null || pro2==wgTitle || pro2=="") {
document.editform.wpSummary.value = 'removed displaytitle tag';
alert('Aborted');
document.editform.wpMinoredit.checked = true;
return};
document.editform.submit();
document.___location=wgServer + wgScript + "?title=" + wgPageName + "&action=edit&dt=" + pro2;
}
addOnloadHook(function() {
if (document.editform) {
mw.util.addPortletLink("p-cactions", "javascript:rdt()", "rdt", "ca-rdt", "Remove Display Title", "");
}
)});
// </nowiki>