Misplaced Pages

User:Lupin/popups.js

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

This is an old revision of this page, as edited by Lupin (talk | contribs) at 03:20, 2 August 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Revision as of 03:20, 2 August 2005 by Lupin (talk | contribs)(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.
This user script seems to have a documentation page at User:Lupin/popups.
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 Misplaced Pages:Bypass your cache.
////////////////////////////////////////////////////////////////////
// Popup stuff
////////////////////////////////////////////////////////////////////

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

// we're not set up for interwiki stuff yet - only affect en links

var re=/*:\/\/en\.wikipedia\.org\/w(iki\/|\/index\.php\?title=)(*)/
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) {
  base = titlebase +  article;
  url = base + '&action=' + action;
  hint = myDecodeURI(article + '&action=' + action);
  return '<a href="' + url + '" title="' + hint + '">' + text + '</a>';
}

function specialLink(article, specialpage, text) {
  base = titlebase +  'Special:'+specialpage;
  url = base + '&target=' + article;
  hint = myDecodeURI(specialpage+':'+article) ;
  return '<a href="' + url + '" title="' + hint + '">' + text + '</a>';
}

function talkPage(article) {
  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;
}

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;
  }

  html='<b>'+wikiLink(article, 'view', myDecodeURI(article))+'</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, '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');
  overlib(html, STICKY, MOUSEOFF, WRAP, CELLPAD, 5, 
	  OFFSETX, 2, OFFSETY, 2, DELAY, 2000);
}

function setupTooltips() {
  var anchors=document.getElementsByTagName('A');
  var s='';
  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(); }
    }
  }
}

////////////////////////////////////////////////////////////////////
// Run things
////////////////////////////////////////////////////////////////////

if (window.addEventListener)
  window.addEventListener("load",setupTooltips,false);
else if (window.attachEvent) 
  window.attachEvent("onload",setupTooltips);
else {
  window._old_ABCD_onload = window.onload;
  window.onload = function() {
    window._old_ABCD_onload();
    setupTooltips();
  }
}