User:Writ Keeper/Scripts/refTooltips.js

$(document).ready(addRefTitles);

function addRefTitles {	var refs = $('.reference'); var reflist = $('li[id^="cite_note"]'); var i;	for(i =0; i < refs.length; i++) {		var match = findMatches(refs[i], reflist); if(match != null) {                       var newTitle = $('#' + match.id + ' > span.reference-text').text refs[i].title = newTitle; refs[i].children[0].title = newTitle; }	} }

function findMatches(ref, reflist) {	var i;	var refId = ref.id.slice(9); if(refId.search("_") != -1) {		refId = refId.slice(0, refId.lastIndexOf('_')) + '-' + refId.slice(refId.lastIndexOf("_")+1, refId.lastIndexOf("-")); }	for(i=0; i < reflist.length; i++) {		var reflistId = reflist[i].id.slice(10); if(refId == reflistId) {			return reflist[i]; }	}	return null; }