wgAjaxWatch.imgBasePath = ""; // base img path derived from icons on load
wgAjaxWatch.setLinkText = function(newText) {
- if(wgAjaxWatch.iconMode){
- for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) {
+ if( wgAjaxWatch.iconMode ) {
+ for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) {
wgAjaxWatch.watchLinks[i].firstChild.alt = newText;
- if(newText==wgAjaxWatch.watchingMsg||newText==wgAjaxWatch.unwatchingMsg){
- wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/common/images/spinner.gif";
- }else if(newText==wgAjaxWatch.watchMsg){
- wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/vector/images/watch_off.gif";
- }else if(newText==wgAjaxWatch.unwatchMsg){
- wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/vector/images/watch_on.gif";
+ if( newText==wgAjaxWatch.watchingMsg || newText==wgAjaxWatch.unwatchingMsg ) {
+ wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath
+ + "/common/images/spinner.gif";
+ } else if( newText==wgAjaxWatch.watchMsg ) {
+ wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath
+ + "/vector/images/watch_off.gif";
+ } else if( newText==wgAjaxWatch.unwatchMsg ) {
+ wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath
+ + "/vector/images/watch_on.gif";
}
}
- }else{
- for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) {
- changeText(wgAjaxWatch.watchLinks[i], newText);
+ } else{
+ for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) {
+ changeText( wgAjaxWatch.watchLinks[i], newText );
}
}
};
wgAjaxWatch.setLinkID = function(newId) {
// We can only set the first one
- wgAjaxWatch.watchLinks[0].setAttribute( 'id', newId );
+ wgAjaxWatch.watchLinks[0].parentNode.setAttribute( 'id', newId );
akeytt(newId); // update tooltips for Monobook
};
var el1 = document.getElementById("ca-unwatch");
var el2 = null;
- if (!el1) {
+ if ( !el1 ) {
el1 = document.getElementById("mw-unwatch-link1");
el2 = document.getElementById("mw-unwatch-link2");
}
- if(el1) {
+ if( el1 ) {
wgAjaxWatch.watching = true;
} else {
wgAjaxWatch.watching = false;
el1 = document.getElementById("ca-watch");
- if (!el1) {
+ if ( !el1 ) {
el1 = document.getElementById("mw-watch-link1");
el2 = document.getElementById("mw-watch-link2");
}
- if(!el1) {
+ if( !el1 ) {
wgAjaxWatch.supported = false;
return;
}
// If we're using the icon, add rollover affects
try{
- if(el1.firstChild.firstChild.tagName.match(/img/i)){
- wgAjaxWatch.iconMode = true;
- wgAjaxWatch.imgBasePath = el1.firstChild.firstChild.src.replace(/\/skins\/vector\/images\/watch_(off|on).gif/, "");
- el1.firstChild.onmouseover = function(e){
- this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_on/, "_off") : this.firstChild.src.replace(/_off/, "_on"));
+ if( el1.firstChild.firstChild.tagName.match( /img/i ) ) {
+ wgAjaxWatch.iconMode = true;
+ wgAjaxWatch.imgBasePath = el1.firstChild.firstChild.src
+ .replace( /\/vector\/images\/watch_(off|on).gif/, "" );
+ el1.firstChild.onmouseover = function( e ) {
+ this.firstChild.src = wgAjaxWatch.imgBasePath
+ + "/vector/images/watch_over.gif";
}
- el1.firstChild.onmouseout = function(e){
- this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_off/, "_on") : this.firstChild.src.replace(/_on/, "_off"));
+ el1.firstChild.onmouseout = function( e ) {
+ this.firstChild.src = wgAjaxWatch.imgBasePath
+ + "/vector/images/watch_" + ( wgAjaxWatch.watching ? "on.gif" : "off.gif");
}
}
- }catch(e){
+ } catch( e ) {
// not using the icon
}