Content deleted Content added
Manishearth (talk | contribs) No edit summary |
m Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink) |
||
(20 intermediate revisions by 6 users not shown) | |||
Line 1:
// <nowiki>
/*
===================================================================================================
Go to [[User:Manishearth/OrphanTabs]] to see how this script is used.
[[User:Manishearth]]
===================================================================================================
*/
if(!OrphanTabsConfig){▼
OrphanTabsConfig = {▼
//Support for config template
var undefined; //to check for undefined config template
var OrphanTabsConfig
if(OrphanTabsConfig === undefined){
▲OrphanTabsConfig = {
auto : false,
autoChoice : 3,
showCompleteTab : true,
completeTabText : "de-orphan",
showWikifyTab : true,
wikifyTabText : "Wikify",
showWLHTab : false,
wLHTabText : "WhatLinksHere",
showSearchItTab : false,
searchItTabText : "Search It!",
showGoogleItTab : false,
googleItTabText : "Google It!"
}
}else{
if(OrphanTabsConfig.auto === undefined){
OrphanTabsConfig.auto = new Boolean(true)
}
if(OrphanTabsConfig.autoChoice === undefined){
OrphanTabsConfig.autoChoice = new Number(3)
}
if(OrphanTabsConfig.showCompleteTab === undefined){
OrphanTabsConfig.showCompleteTab = new Boolean(true)
}
if(OrphanTabsConfig.completeTabText === undefined){
OrphanTabsConfig.completeTabText = new String("de-orphan")
}
if(OrphanTabsConfig.showWikifyTab === undefined){
OrphanTabsConfig.showCompleteTab = new Boolean(true)
}
if(OrphanTabsConfig.wikifyTabText === undefined){
OrphanTabsConfig.completeTabText = new String("de-orphan-wikify")
}
if(OrphanTabsConfig.showWLHTab === undefined){
OrphanTabsConfig.showCompleteTab = new Boolean(false)
}
if(OrphanTabsConfig.wLHTabText === undefined){
OrphanTabsConfig.completeTabText = new String("WhatLinksHere")
}
if(OrphanTabsConfig.showSearchItTab === undefined){
OrphanTabsConfig.showCompleteTab = new Boolean(false)
}
if(OrphanTabsConfig.searchItTabText === undefined){
OrphanTabsConfig.completeTabText = new String("Search It!")
}
if(OrphanTabsConfig.showGoogleItTab === undefined){
OrphanTabsConfig.showCompleteTab = new Boolean(false)
}
if(OrphanTabsConfig.googleItTabText === undefined){
OrphanTabsConfig.completeTabText = new String("Google It!")
}
}
var currentLinkWin
var otherOrphanTabs =
var deOrphanDocumentLinkArray = new Array()
var linkACounter=0
Line 22 ⟶ 73:
var deOrphanPgName = ""
var deOrphanProcessFirstCall=false
var gServerPre;
var gServerPost;
gServerPre = "http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENUS255&as_q="
gServerPost="&as_epq=&as_oq=&as_eq=&num=100&lr=&as_filetype=&ft=i&as_sitesearch=" + mw.config.get('wgServer') + "&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=images"
var pgname = encodeURIComponent( mw.config.get('wgTitle') );
if(otherOrphanTabs){
if(OrphanTabsConfig.showWLHTab){
addPortletLink("p-cactions", wgServer + "/wiki/Special:WhatLinksHere/" + pgname, "WhatLinksHere", "ca-parents" , "What links here");▼
mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/wiki/Special:WhatLinksHere/" + pgname,
addPortletLink("p-cactions", gServerPre + pgname + gServerPost, "Google it!", "ca-googleit", "Find all Wikipedia pages with this page name in them"); ▼
}
if(OrphanTabsConfig.showSearchItTab){
addPortletLink("p-cactions","javascript:deOrphanWikify(prompt(\"What page are you de-orphaning?\",\"\"))", "De-orphan-wikify", "ca-de-orphan-wikify", "Wikify to deorphan another page"); ▼
▲mw.util.addPortletLink("p-cactions", mw.config.get('wgServer') + "/wiki/Special:WhatLinksHere/" + pgname,
}
addPortletLink("p-cactions", "javascript:initDeOrphan(prompt(\"What page\?\"\,\""+ ((wgCanonicalNamespace=="")?wgPageName:"")+"\"));", "De-orphan-complete", "ca-de-orphan", "Find all Wikipedia pages with this page name in them"); ▼
if(OrphanTabsConfig.showGoogleItTab){
▲mw.util.addPortletLink("p-cactions", gServerPre + pgname + gServerPost,
}
}
if (document.editform && OrphanTabsConfig.showWikify){
▲mw.util.addPortletLink("p-cactions","javascript:deOrphanWikify(prompt(\"What page are you de-orphaning?\",\"\"))",
}
if(OrphanTabsConfig.showCompleteTab){
▲mw.util.addPortletLink("p-cactions", "javascript:initDeOrphan(prompt(\"What page\?\"\,\""+ ((mw.config.get('wgCanonicalNamespace')=="")?mw.config.get('wgPageName'):"")+"\"));",
});
Line 45 ⟶ 102:
var allLinks = new Array()
function deOrphanWikify(pgName){
if (!document.editform){
alert("Only available on the edit page \(currently\)")
}else{
document.editform.wpTextbox1.value = orphanRawWikify(pgName,document.editform.wpTextbox1.value)
document.editform.wpSummary.value = "Adding link to orphaned [[" + pgName+ "|article]], Wikiproject Orphanage: [[WP:ORPHAN|You can help!]]"
} }
function orphanRawWikify(pgName,text){
Line 55 ⟶ 116:
}
function initDeOrphan(pgName){
sWin = window.open(mw.config.get('wgServer') + "/w/index.php?title=Special:Search&ns0
deOrphanPgName = pgName
deOrphanProcessFirstCall=true
Line 75 ⟶ 137:
for (i=0;i<allLists.length;i++){
if (allLists[i].className == "mw-search-results"){
//alert(allLists[i].innerHTML)
allLinksArray = returnArray(allLists[i].innerHTML)
}
}
deOrphanDocumentLinkArray = allLinksArray
//alert("final a:\n" + deOrphanDocumentLinkArray)
openALinkWin()
Line 105 ⟶ 167:
function openALinkWin(){
currentLinkWin = window.open("about:blank","","")
currentLinkWin.___location.replace(mw.config.get('wgServer')+"/w/index.php?title=" + deOrphanDocumentLinkArray[linkACounter].replace(/\/wiki\//,"") + "&action=edit")
if(!currentLinkWin.
currentLinkWin.onload=function(){
currentLinkWin.
openALInnerFunct()
});
Line 114 ⟶ 176:
}else{
if(!currentLinkWin.document.loaded){
currentLinkWin.
openALInnerFunct()
});
Line 126 ⟶ 188:
function closeTheWindow(){
//alert("closing")
if(!currentLinkWin.
currentLinkWin.onload=function(){
currentLinkWin.
closeTWInnerFunct()
});
Line 134 ⟶ 196:
}else{
if(!currentLinkWin.document.loaded){
currentLinkWin.
closeTWInnerFunct()
});
Line 144 ⟶ 206:
function endOfLinkWins(){
var choice = confirm(linkAlreadyThere + " pages linked to " + deOrphanPgName + " before de-orphaning.\n" + howManyActuallyDeOrphaned + " pages were linked to " + deOrphanPgName + "\n" + (linkAlreadyThere + howManyActuallyDeOrphaned) + " pages link to " + deOrphanPgName + "now\n De-orphan? (Press cancel to tag the page with \'do-attempt\'.")▼
var choice = ((linkAlreadyThere + howManyActuallyDeOrphaned)>OrphanTabsConfig.autoChoice)?true:false;
}else{
▲var choice = confirm(linkAlreadyThere + " pages linked to " + deOrphanPgName + " before de-orphaning.\n" + howManyActuallyDeOrphaned + " pages were linked to " + deOrphanPgName + "\n" + (linkAlreadyThere + howManyActuallyDeOrphaned) + " pages link to " + deOrphanPgName + " now\n De-orphan? (Press cancel to tag the page with \'do-attempt\'.")
currentLinkWin = window.open("about:blank","","")
}
currentLinkWin.___location.replace(mw.config.get('wgServer')+"/w/index.php?title=" + deOrphanPgName + "&action=edit")
if(!currentLinkWin.
currentLinkWin.onload=function(){
currentLinkWin.
addOrphanTag(choice)
});
Line 155 ⟶ 221:
}else{
if(!currentLinkWin.document.loaded){
currentLinkWin.
addOrphanTag(choice)
});
Line 211 ⟶ 277:
rVal = val.replace(/{{orphan\|\wdate=[^\}]*}}/i, "")
// alert(12)
}else if(val.indexOf("{{
rVal=val.replace(/\|\w?orphan=[^\|\}]*/i,"")
rVal=rVal.replace(/\|\w?do-attempt=[^\|\}]*/i,"")
Line 229 ⟶ 295:
rVal = val.replace(/({{do-attempt|date=[^\|\}]*\|att=)[^\|\}]*}}/i, "$1\{\{subst:CURRENTMONTHNAME\}\} \{\{subst:CURRENTYEAR\}\}}}")
}else if(val.indexOf("{{
rVal=rVal.replace(/\|\w?do-attempt=[^\|\}]*/i,"\|do-attempt=\{\{subst:CURRENTMONTHNAME\}\} \{\{subst:CURRENTYEAR\}\}")
// alert(23)
Line 238 ⟶ 304:
return rVal
}
// </nowiki>
|