Jump to content

User:Pekaje/moretabs.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Ladsgroup (talk | contribs) at 07:43, 29 November 2021 (Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
function addImageTagger()
{
 if(wgCanonicalNamespace == "Image" && wgAction == "edit")
 {
   mw.util.addPortletLink("p-interaction", "javascript:tagReduce()", "Q. Rescale Image", "pekaje-id1", "Needs rescaling", "q", document.getElementById("n-About-Wikipedia"));
   mw.util.addPortletLink("p-interaction", "javascript:tagReduced()", "A. Mark as rescaled", "pekaje-id2", "Is rescaled", "a", document.getElementById("n-About-Wikipedia"));
   mw.util.addPortletLink("p-interaction", "javascript:rationaleBoilerplate()", "Z. Fair use template", "pekaje-id3", "Adds the fair use rationale template", "z", document.getElementById("n-About-Wikipedia"));
   mw.util.addPortletLink("p-tb", "http://en.wikipedia.org/wiki/User:Pekaje/rationales", "Standard rationale content", "pekaje-id4", "", "", document.getElementById("t-whatlinkshere"));
 }
}

function rationaleBoilerplate()
{
 var tl1="{"+"{";
 var tl2="}"+"}";
 var nl="\n";
 var text = document.editform.wpTextbox1;
 text.value = text.value + nl + "== Fair use rationale for [[]] ==";
 text.value = text.value + nl + tl1 + "Non-free media rationale";
 text.value = text.value + nl + "|Description=";
 text.value = text.value + nl + "|Source=";
 text.value = text.value + nl + "|Portion=";
 text.value = text.value + nl + "|Resolution=";
 text.value = text.value + nl + "|Purpose=";
 text.value = text.value + nl + "|Replaceability=";
 text.value = text.value + nl + "|other_information=";
 text.value = text.value + nl + tl2;
 document.editform.wpSummary.value = "Fair use rationale added";
}

function tagReduced()
{
 replaceTag("Non-free reduce","subst:furd");
 replaceTag("FairUseReduce","subst:furd");
 replaceTag("Fairusereduce","subst:furd");
 replaceTag("Fair Use Reduce","subst:furd");
 replaceTag("Fair use reduce","subst:furd");
 replaceTag("Reduce size","subst:furd");
 replaceTag("Reduce","subst:furd");
// Case insensitive on first letter ... Must fix this with regex later
 replaceTag("non-free reduce","subst:furd");
 replaceTag("fairUseReduce","subst:furd");
 replaceTag("fairusereduce","subst:furd");
 replaceTag("fair Use Reduce","subst:furd");
 replaceTag("fair use reduce","subst:furd");
 replaceTag("reduce size","subst:furd");
 replaceTag("reduce","subst:furd");

 document.editform.wpSummary.value = "Rescaled for fair use";
 document.editform.wpMinoredit.checked = true;
 document.editform.wpWatchthis.checked = true;
}

function tagReduce()
{
 addTag("non-free reduce", "top");
 document.editform.wpSummary.value = "Needs to be rescaled for fair use";
 document.editform.wpMinoredit.checked = true;
}

function addTag(tag, place)
{
 var text = document.editform.wpTextbox1;
 if(place == "top")
 {
  text.value = "{" + "{" + tag + "}" + "}\n" + text.value;
 }
 else
 {
  text.value = text.value + "\n{" + "{" + tag + "}" + "}";
 }
}

function replaceTag(oldtag, newtag)
{
 var tl1="{"+"{";
 var tl2="}"+"}\n";
 var fulloldtag=tl1+oldtag+tl2;
 var fullnewtag=tl1+newtag+tl2;
 document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(fulloldtag,fullnewtag);
}

$(addImageTagger);