User:Senvaikis/global.js

var wpTb1 var btnArt var btnAlb var request = false; var _timer; var btnBusyImage var btnArtImage var btnAlbImage

var wpSumm var oreg var resultSpan

function init{ if (_timer) clearInterval(_timer); var tlbr=window.document.getElementById("toolbar"); if (wgNamespaceNumber==6){ btnBusyImage = "http://images3.wikia.nocookie.net/__cb20100126184912/lyricwiki/images/7/76/LW_btn_busy.gif" btnArtImage = "http://images1.wikia.nocookie.net/__cb20101206073518/lyricwiki/images/d/d8/Lw_btn_user.png"; btnAlbImage ="http://images3.wikia.nocookie.net/__cb20101206073617/lyricwiki/images/d/d1/Lw_btn_disc.png" btnAlb=window.document.getElementById("mw-editbutton-headline"); var objImage = new Image; objImage.src=btnBusyImage; btnAlb.src = btnAlbImage; btnAlb.title = "Set AlbumCover"; btnAlb.onclick=CheckAlbum1; btnArt=window.document.getElementById("mw-editbutton-image"); btnArt.src = btnArtImage; btnArt.title = "Set ArtistPhoto"; btnArt.style.opacity=0.8; btnArt.style.filter = "alpha(opacity=80)" //alert(btnArt);not null btnArt.onclick=CheckArtist; request = new XMLHttpRequest; //alert(request); object created, not null //but this line throws an error (unspecified): //request.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); } }

//********Image page edit stuff********* function CheckAlbum1 { if (btnAlb.src == btnAlbImage) { btnAlb.src=btnBusyImage; GetAlbum; } } function CheckArtist { if (btnArt.src == btnArtImage) { btnArt.src=btnBusyImage; GetArtist; } } function GetAlbum { var urlstr = "/api.php?action=query&generator=imageusage&prop=categories&clcategories=Category:Album&format=xml&giutitle=" + encodeURIComponent(wgPageName).replace('.','%2E'); request.open("GET", urlstr, true); request.onreadystatechange = parseAlbum; request.send(null); return false; } function parseAlbum { if (request.readyState == 4) { if (request.status == 200) { var oreg =/:]+?):([^>]+?) \((\d+)\))"><categories/; var m= oreg.exec(request.responseText); if (m) { wpTb1.value=""; } else wpTb1.value=""; btnAlb.src = btnAlbImage; } } } function GetArtist { var urlstr = "http://lyrics.wikia.com/api.php?action=query&generator=imageusage&prop=categories&clcategories=Category:Artist&format=xml&giutitle=" + encodeURIComponent(wgPageName).replace('.','%2E'); request.open("GET", urlstr, true); request.onreadystatechange = parseArtist; request.send(null); return false; } function parseArtist { if (request.readyState == 4) { //alert(request.status); // Found a reason- 403 in IE! (that's definitelly related to '.' in title   if (request.status == 200) {      var oreg =/]+?)"><categories/;      var m =oreg.exec(request.responseText);      var art=(m) ? m[1] : '';      wpTb1.value="";      btnArt.src = btnArtImage;     }  } }

/* kill image popups */ function changeimagelinks { $('#WikiaArticle, .LatestPhotosModule, #article-comments').unbind('click.lightbox'); var a = document.getElementsByTagName('a'); for(var t = 0; t < a.length; ++t) { var a2 = a[t]; var img = a2.getElementsByTagName('img'); if(img[0] != null && a2.href.indexOf('/revision/latest') != -1) { var link = a2.href.substring(0,a2.href.indexOf('/revision/latest')); link = wgServer + '/wiki/File:' + link.substring(link.lastIndexOf('/') + 1); a2.setAttribute('href',link); }	} } if(skin == 'oasis') {addOnloadHook(changeimagelinks);}

//********Song page view stuff********* function getLyricsBoxElement { node = document.getElementById("WikiaArticle"); var a = null; var re = new RegExp('\\blyricbox\\b'); var els = node.getElementsByTagName("div"); for(var i=0,j=els.length; i<j; i++) if(re.test(els[i].className)) { a=els[i]; break; }	return a; }

function LoadAudioIfExists{ if (wgCategories){ var cats= wgCategories.toString; if (cats.match(/Spotify\/Song/i)){ var m =window.document.body.innerHTML.match(/"https:\/\/play\.spotify\.com\/track\/(.+?)"/i); if (m) { var gpl = document.createElement("div"); var lb=getLyricsBoxElement; gpl.style.cssText="FLOAT: right; CLEAR: both; margin:0px;height:80px;"; gpl.innerHTML=' '; lb.parentNode.insertBefore(gpl,lb); }		}	} }

function CheckPage { if (wgAction=="edit"){ wpTb1 = window.document.getElementById("wpTextbox1"); wpSumm=document.getElementById("wpSummary"); if (isIE) _timer = setInterval(init, 300); else init; } else if ((wgAction=="view") && (wgNamespaceNumber==0)) LoadAudioIfExists; window.wgEnableImageLightboxExt = false; changeimagelinks; } var isIE = /*@cc_on!@*/false; //alert(isIE); if (isIE) window.attachEvent('onload', CheckPage); else window.addEventListener('load', CheckPage, false);