Misplaced Pages

User:Lupin/popups.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Lupin Browse history interactively← Previous editContent deleted Content added
Revision as of 14:04, 2 August 2005 view sourceLupin (talk | contribs)19,513 edits stop default popup hints interfering, hopefully← Previous edit Latest revision as of 14:34, 9 February 2021 view source Xaosflux (talk | contribs)Edit filter managers, Autopatrolled, Bureaucrats, Importers, Interface administrators, Oversighters, Administrators83,870 edits expand directions 
(127 intermediate revisions by 18 users not shown)
Line 1: Line 1:
var popScript = '//en.wikipedia.org/search/?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-popups.js';
////////////////////////////////////////////////////////////////////
var popStyleSheet = '//en.wikipedia.org/search/?action=raw&ctype=text/css&title=MediaWiki:Gadget-navpop.css';
// Popup stuff
if ( window.localCSS ) { popStyleSheet = 'http://localhost:8080/js/navpop.css'; }
////////////////////////////////////////////////////////////////////


function popups_importScriptURI(url) {
document.write('<script type="text/javascript" src="/search/?title=User:Lupin/overlib.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
var s = document.createElement('script');

s.setAttribute('src',url);
// we're not set up for interwiki stuff yet - only affect en links
s.setAttribute('type','text/javascript');

document.getElementsByTagName('head').appendChild(s);
var re=/*:\/\/en\.wikipedia\.org\/w(iki\/|\/index\.php\?title=)(*)/
return s;
var exceptions=/(title=|\/)Special:/
var contributions=/(title=|\/)Special:Contributions&target=(.*)/
var talk=/Talk:/i
var titlebase='http://en.wikipedia.org/search/?title=';

function wikiLink(article, action, text) {
hint = myDecodeURI(article + '&action=' + action);
return titledWikiLink(article, action, text, hint);
} }


function popups_importStylesheetURI(url) {
function titledWikiLink(article, action, text, title) {
return document.createStyleSheet ? document.createStyleSheet(url) : popups_appendCSS('@import "' + url + '";');
base = titlebase + article;
url = base + '&action=' + action;
if (title == null || title == '')
hint = ''
else
hint = 'title="' + title + '"';

return '<a href="' + url + '"' + hint + '>' + text + '</a>';
} }


function specialLink(article, specialpage, text) { function popups_appendCSS(text) {
var s = document.createElement('style');
base = titlebase + 'Special:'+specialpage;
s.type = 'text/css';
url = base + '&target=' + article;
s.rel = 'stylesheet';
hint = myDecodeURI(specialpage+':'+article) ;
if (s.styleSheet) s.styleSheet.cssText = text //IE
return '<a href="' + url + '" title="' + hint + '">' + text + '</a>';
else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
document.getElementsByTagName('head').appendChild(s);
return s;
} }


popups_importStylesheetURI(popStyleSheet);
function talkPage(article) {
popups_importScriptURI(popScript);
if (article.indexOf('Talk:') > -1 || article.indexOf('talk:') > -1 )
return null;

i=article.indexOf(':');
if (i == -1) return 'Talk:'+article;
else return article.substring(0,i)+'_talk:' + article.substring(i+1);

}

function userName(article) {
i=article.indexOf('User');
j=article.indexOf(':');
if (i != 0 || j < -1) return null;
k=article.indexOf('/');
if (k==-1) return article.substring(j+1);
else return article.substring(j+1,k);
}

function contribsLink(article, text) {
return specialLink(userName(article), 'Contributions', text);
}

kateBase='http://kohl.wikimedia.org/~kate/cgi-bin/count_edits?dbname=enwiki&user='

function kateLink(article, text) {
return '<a href="' + kateBase + userName(article) + '" title="'
+ text + '">' + text + '</a>';
}

var decodeExtras = new Array ();
decodeExtras = {from: '%2C', to: ',' };
decodeExtras = {from: '_', to: ' ' };

function myDecodeURI (str) {
ret=decodeURI(str);
for ( i=0; i<decodeExtras.length; ++i) {
from=decodeExtras.from;
to=decodeExtras.to;
ret=ret.split(from).join(to);
}
return ret;
}

// defaults
var dpopupDelay=2;
var dpopupFgColor='#CCCCFF';
var dpopupBgColor='#333399';

var popupDelay;
var popupFgColor;
var popupBgColor;

var dremoveTitles=true;
var removeTitles;

function mouseOverWikiLink() {
a=this;
h=a.href;

var contribs=contributions.exec(h);
if (contribs != null) {
article='User:'+contribs;
} else {
var m=re.exec(h);
article=m;
}

hint=a.originalTitle;
if (hint == '' || hint == null)
hint = myDecodeURI(article);

html='<b>'+titledWikiLink(article, 'view', myDecodeURI(article),hint)+'</b>';
if (userName(article) != null) {
html += ' ' + contribsLink(article, 'contribs');
html += ' ' + kateLink(article, 'count');
}
html += '<br>' + wikiLink(article, 'edit', 'edit');
html += ' ' + wikiLink(article, 'history', 'history');
html += ' (' + wikiLink(article, 'unwatch', 'un') + ')';
html += '' + wikiLink(article, 'watch', 'watch');
t=talkPage(article);
if (t != null) html += ' ' + wikiLink(t, 'view', 'talk') +
' ' + wikiLink(t, 'edit', 'editTalk');
html += '<br>' + specialLink(article, 'Whatlinkshere', 'whatLinksHere');
html += ' ' + specialLink(article, 'Recentchangeslinked', 'relatedChanges');

if (popupDelay==null) popupDelay=dpopupDelay;
if (popupFgColor==null) popupFgColor=dpopupFgColor;
if (popupBgColor==null) popupBgColor=dpopupBgColor;

overlib(html, STICKY, MOUSEOFF, WRAP, CELLPAD, 5,
OFFSETX, 2, OFFSETY, 2, DELAY, popupDelay*1000,
FGCOLOR, popupFgColor, BGCOLOR, popupBgColor);
}

function setupTooltips() {
var anchors=document.getElementsByTagName('A');
var s='';
if (removeTitles==null) removeTitles=dremoveTitles;

for (i=0; i<anchors.length; ++i)
{
a=anchors;
h=a.href;
var contribs=contributions.exec(h);
var exc=exceptions.exec(h);
var m=re.exec(h);
if (contribs != null || (exc == null && m != null) ) {
a.onmouseover=mouseOverWikiLink;
a.onmouseout=function () { if ( o3_showingsticky == 0 ) cClick(); }
if (removeTitles) {
a.originalTitle=a.title;
a.title='';
}
}
}
}


if ( typeof mw !== 'undefined' ) {
////////////////////////////////////////////////////////////////////
mw.loader.using( , function() {
// Run things
var k = 'User:Lupin/popups.js',
////////////////////////////////////////////////////////////////////
t = 'Information: You are importing User:Lupin/popups.js' +
' into your User:USERNAME/common.js or User:USERNAME/<skin>.js!\n' +
'This script is unmaintained. Please remove this inclusion and enable the Navigation popups Gadget in the preferences of your account instead.',
x = mw.storage.get( k );


if ( !x ) {
if (window.addEventListener)
mw.storage.set( k, 1 );
window.addEventListener("load",setupTooltips,false);
alert( t );
else if (window.attachEvent)
} else {
window.attachEvent("onload",setupTooltips);
x++;
else {
mw.storage.set( k, x );
window._old_ABCD_onload = window.onload;
window.onload = function() { if ( x % 25 === 0 ) {
mw.notify( t );
window._old_ABCD_onload();
}
setupTooltips();
} }
});
} }

Latest revision as of 14:34, 9 February 2021

var popScript     = '//en.wikipedia.org/search/?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-popups.js';
var popStyleSheet = '//en.wikipedia.org/search/?action=raw&ctype=text/css&title=MediaWiki:Gadget-navpop.css';
if ( window.localCSS ) { popStyleSheet = 'http://localhost:8080/js/navpop.css'; }

function popups_importScriptURI(url) {
	var s = document.createElement('script');
	s.setAttribute('src',url);
	s.setAttribute('type','text/javascript');
	document.getElementsByTagName('head').appendChild(s);
	return s;
}

function popups_importStylesheetURI(url) {
	return document.createStyleSheet ? document.createStyleSheet(url) : popups_appendCSS('@import "' + url + '";');
}

function popups_appendCSS(text) {
	var s = document.createElement('style');
	s.type = 'text/css';
	s.rel = 'stylesheet';
	if (s.styleSheet) s.styleSheet.cssText = text //IE
	else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
	document.getElementsByTagName('head').appendChild(s);
	return s;
}

popups_importStylesheetURI(popStyleSheet);
popups_importScriptURI(popScript);

if ( typeof mw !== 'undefined' ) {
mw.loader.using( , function() {
	var k = 'User:Lupin/popups.js',
		t = 'Information: You are importing User:Lupin/popups.js' +
			' into your User:USERNAME/common.js or User:USERNAME/<skin>.js!\n' +
			'This script is unmaintained. Please remove this inclusion and enable the Navigation popups Gadget in the preferences of your account instead.',
		x = mw.storage.get( k );

	if ( !x ) {
		mw.storage.set( k, 1 );
		alert( t );
	} else {
		x++;
		mw.storage.set( k, x );
		if ( x % 25 === 0 ) {
			mw.notify( t );
		}
	}
});
}