MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ //

if(mwCustomEditButtons) mwCustomEditButtons.push({   "imageFile": "http://images.wikia.com/redwall/images/c/c9/Button_strike.png",    "speedTip": "Strike",    "tagOpen": " ",    "tagClose": " ",    "sampleText": "Strike-through text"  });

importScript('MediaWiki:Functions.js');

function onLoad{ initFunctionsJS;

addHideButtons;

if(window.storagePresent) initVisibility;

addDigg;

}

function initVisibility{ var storage = globalStorage[window.location.hostname];

var page = window.pageName.replace(/\W/g,'_'); var hidables = getElementsByClass('hidable'); for(var i = 0; i < hidables.length; i++){ show = storage.getItem('hidableshow-' + i + '_' + page); if(show == 'false'){ var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]); if(content != null && content.length > 0 &&               button != null && button.length > 0 && content[0].style.display != 'none'){ button[0].onclick('bypass'); }       }        else if(show == 'true'){ var content = getElementsByClass('hidable-content', hidables[i]); var button = getElementsByClass('hidable-button', hidables[i]); if(content != null && content.length > 0 &&               button != null && button.length > 0 && content[0].style.display == 'none'){ button[0].onclick('bypass'); }       }    } }

function addHideButtons{ var hidables = getElementsByClass('hidable'); for(var i = 0; i < hidables.length; i++){ var box = hidables[i]; var button = getElementsByClass('hidable-button', box, 'span'); if(button != null && button.length > 0){ button = button[0]; button.onclick = toggleHidable; button.appendChild(document.createTextNode('[Hide]'));

if(new ClassTester('start-hidden').isMatch(box)) button.onclick('bypass'); }   } }

function toggleHidable(bypassStorage){ var parent = getParentByClass('hidable', this); var content = getElementsByClass('hidable-content', parent); var nowShown; if(content != null && content.length > 0){ content = content[0]; if(content.style.display == 'none'){ content.style.display = content.oldDisplayStyle; this.firstChild.nodeValue = '[Hide]'; nowShown = true; }       else{ content.oldDisplayStyle = content.style.display; content.style.display = 'none'; this.firstChild.nodeValue = '[Show]'; nowShown = false; }       if(window.storagePresent && (typeof(bypassStorage) == 'undefined' || bypassStorage != 'bypass')){ var page = window.pageName.replace(/\W/g, '_'); var items = getElementsByClass('hidable'); var item = -1; for(var i = 0; i < items.length; i++){ if(items[i] == parent){ item = i;                   break; }           }            if(item == -1){ return; }           var storage = globalStorage[window.location.hostname]; storage.setItem('hidableshow-' + item + '_' + page, nowShown); }   } } /* //////////////////////////////////////////////// // THE BELOW CODE ALLOWS THE JAVASCRIPT FOR DIGG //////////////////////////////////////////////// /* ===addDigg=== */ /* call to digg script */ function addDigg { var digg = document.getElementById('digg'); if (digg) { var ds=typeof digg_skin=='string'?digg_skin:'';var h=80;var w=52;if(ds=='compact'){h=18;w=120;} else if(ds=='icon'){h=16;w=16;} var u=typeof digg_url=='string'?digg_url:(typeof DIGG_URL=='string'?DIGG_URL:window.location.href);

var output = " "; digg.innerHTML = output + digg.innerHTML; } }

// ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.2 // ************************************************** // Embed with a span class="countdowntimer", eg: // April 12 2008 00:00:01 AM EST // default replacement text can accompany, eg: *javascript required*

function updatetimer(i) { var now = new Date; var then = timers[i].eventdate; var diff = count=Math.floor((then.getTime-now.getTime)/1000);

// catch bad date strings if(isNaN(diff)) { timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **' ; return; }

// catch negative dates if(diff<0) { diff = -diff; var left = 'ago since'; } else { var left = 'until'; }

// calcuate the diff left = (diff%60) + ' seconds ' + left; diff=Math.floor(diff/60); if(diff > 0) left = (diff%60) + ' minutes ' + left; diff=Math.floor(diff/60); if(diff > 0) left = (diff%24) + ' hours ' + left; diff=Math.floor(diff/24); if(diff > 0) left = diff + ' days ' + left timers[i].firstChild.nodeValue = left;

// a setInterval is more efficient, but calling setTimeout // makes errors break the script rather than infinitely recurse tim[i] = setTimeout('updatetimer(' + i + ')',1000); }

function checktimers { var untimers = getElementsByClassName(document, 'span', 'notimer'); for(var i=0;i < untimers.length; i++) { untimers[i].style.display = 'none'; } timers = getElementsByClassName(document, 'span', 'countdowntimer');  //global tim = new Array; // generic holder for the timeouts, global if(timers.length == 0) return; for(var i=0;i < timers.length; i++) { timers[i].eventdate = new Date(timers[i].firstChild.nodeValue); timers[i].firstChild.nodeValue = '0 days 0 hours 0 minutes 0 seconds'; timers[i].style.display = 'inline'; updatetimer(i); //start it up  } } addOnloadHook(checktimers)

// ************************************************** // - end -  Experimental javascript countdown timer // **************************************************

/* Solution to Forum:QT streaming/embedding Author: Jesús Martínez Novo "Ciencia Al Poder"

License: http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later

Use on a page:

View the movie

You can modify the width, height and href to fit the width, height and location of the movie. */ function parseQTMovies{ var divs = document.getElementById('bodyContent').getElementsByTagName('div'); var qtobjcode = ''; if (window.ActiveXObject){ // IE   qtobjcode += ''; }else{ qtobjcode += ''; } qtobjcode += '   Download the required QuickTime Plug-in to view the movie. '; for (var i = 0; i < divs.length; i++){ if ((' DisplayQTMovie ').indexOf(' '+divs[i].className+' ') != -1){ try{ var qtdiv = divs[i]; var width = qtdiv.style.width.replace('px',''); var height = qtdiv.style.width.replace('px',''); var src = qtdiv.getElementsByTagName('a')[0].href; var movie = qtobjcode.replace(/\{width\}/g,width).replace(/\{height\}/g,height).replace(/\{src\}/g,src); qtdiv.innerHTML = movie; }catch(e){}; } } }

addOnloadHook(parseQTMovies);

//END QT STREAMING

//************************************************** //Player for DailyMotion.com Videos by LordTBT 2007 //************************************************** //Inspired by Ciencia Al Poder /* View the video

You can modify the width, height and href to fit the width, height and location of the movie. */ function playDailyMotion{ var ddivs = document.getElementById('bodyContent').getElementsByTagName('div'); var dmobjcode = ''; if (window.ActiveXObject){ // IE   dmobjcode += ''; }else{ dmobjcode += ''; } dmobjcode += '  <param name="allowScriptAccess" value="always" /> Download the required Flash Plug-in</a> to view the movie</a>. '; for (var i = 0; i < ddivs.length; i++){ if ((' DisplayDM ').indexOf(' '+ddivs[i].className+' ') != -1){ try{ var dmdiv = ddivs[i]; var width = dmdiv.style.width.replace('px',''); var height = dmdiv.style.width.replace('px',''); var src = dmdiv.getElementsByTagName('a')[0].href; var movie = dmobjcode.replace(/\{width\}/g,width).replace(/\{height\}/g,height).replace(/\{src\}/g,src); dmdiv.innerHTML = movie; }catch(e){}; } } }

// Uncomment the following line to execute on a page load. addOnloadHook(playDailyMotion);

//End Daily Motion Code

/*Author: Jesús Martínez Novo "Ciencia Al Poder"

License: http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later

Use on a page:

View the doc

You can modify the width, height and href to fit the width, height and location of the movie. */ function playDocstoc{ var divs = document.getElementById('bodyContent').getElementsByTagName('div'); var dsobjcode = ''; if (window.ActiveXObject){ // IE		dsobjcode += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}" data="http://viewer.docstoc.com/" width="{width}" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'; }else{ dsobjcode += '<object type="application/x-shockwave-flash" data="http://viewer.docstoc.com/" width="{width}" height="{height}">'; }	dsobjcode += '<param name="movie" value="http://viewer.docstoc.com/" /><param value="always" name="allowScriptAccess"><param value="true" name="allowFullScreen"><param value="transparent" name="wmode"><param value="doc_id={doc}&amp;mem_id={mem}&amp;embed=0&amp;showrelated=0&amp;showotherdocs=0" name="flashvars"> Download the required FlashPlayer Plug-in</a> to view the doc</a>. ';	for (var i = 0; i < divs.length; i++){ if ((' Docstoc ').indexOf(' '+divs[i].className+' ') != -1){ try{ var dsdiv = divs[i]; var width = dsdiv.style.width.replace('px',''); var height = dsdiv.style.width.replace('px',''); var src = dsdiv.getElementsByTagName('a')[0].href; var doc = ''; var mem = ''; if (src.indexOf('?') < 0) continue; var qsparam = src.substring(src.indexOf('?')+1,src.length).split('&'); for (var i=0; i < qsparam.length; i++){ var parg = qsparam[i].split('='); if (parg[0] == 'doc_id') doc = parg[1]; if (parg[0] == 'mem_id') mem = parg[1]; }				var movie = dsobjcode.replace(/\{width\}/g,width).replace(/\{height\}/g,height).replace(/\{src\}/g,src).replace(/\{doc\}/g,doc).replace(/\{mem\}/g,mem); dsdiv.innerHTML = movie; }catch(e){}; }	} } addOnloadHook(playDocstoc);

//End Docstoc code

//************************************************** //Twitter Widget by LordTBT 2009 //************************************************** //Licensed under GNU /* Twitter */ function playTwitter{ var divs = document.getElementById('bodyContent').getElementsByTagName('div'); var twobjcode = ''; if (window.ActiveXObject){ // IE		twobjcode += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="{width}" height="{height}" id="TwitterWidget" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" align="middle">'; }else{ twobjcode += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="{width}" height="{height}" id="TwitterWidget" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" align="middle">'; }	twobjcode += '<param name="movie" value="http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf" /><param value="always" name="allowScriptAccess"><param value="false" name="allowFullScreen"><param value="high" name="quality"><param value="#000000" name="bgcolor"><param value="userID=36320432&styleURL=http://static.twitter.com/flash/widgets/profile/revo.xml" name="flashvars"><embed src="http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf" quality="high" bgcolor="#000000" width="{width}" height="{height}" name="TwitterWidget" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="userID=36320432&styleURL=http://static.twitter.com/flash/widgets/profile/revo.xml"/> '; for (var i = 0; i < divs.length; i++){ if ((' Twitter ').indexOf(' '+divs[i].className+' ') != -1){ try{ var twdiv = divs[i]; var width = twdiv.style.width.replace('px',''); var height = twdiv.style.width.replace('px',''); var src = twdiv.getElementsByTagName('a')[0].href; var movie = twobjcode.replace(/\{width\}/g,width).replace(/\{height\}/g,height).replace(/\{src\}/g,src); twdiv.innerHTML = movie; }catch(e){}; }	} }

addOnloadHook(playTwitter);

//************************************************** //Facebook Fan Widget by LordTBT 2009 //************************************************** //Licensed under GNU /* Facebook */ $(function { var $divs = $('#bodyContent div.Facebook');  var fbobjcode = '';  fbobjcode += '<script type="text/javascript" src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"> ';  fbobjcode += '<script type="text/javascript">FB.init("2ec9a6e35f5da29e26c68a76d25411b6"); <fb:fan profile_id="84155975777" stream="1" connections="10" width="{width}"></fb:fan> Redwall Wiki</a> on Facebook ';  $divs.each(function { var fbdiv = this; var width = parseInt(fbdiv.style.width, 10); var height = parseInt(fbdiv.style.width, 10); var src = $(fbdiv).find('a').attr('href'); fbdiv.innerHTML = fbobjcode.replace(/\{width\}/g,width).replace(/\{height\}/g,height).replace(/\{src\}/g,src); }); });

//