if (!window.disableWiktLookup) {
/*****************  
If you wish to use this elsewhere, please do not copy it, but instead hotlink it. This is still undergoing active development, and you will miss out if you just statically copy it. To hotlink, copy only the following line:  
mw.loader.load('//en.wikinews.org/w/index.php?title=MediaWiki:Gadget-dictionaryLookupHover.js&action=raw&ctype=text/javascript');  
See //en.wikinews.org/wiki/WN:WiktLookup#Wiktionary_lookup_gadget_.28Hover_box_variety.29
for details on this script, and how to use it on your own site.  
- /  
/*** This is the stable version of the gadget js.***/  
/*****************  
If you wish to use this elsewhere, please do not copy it, but instead hotlink it. This is still undergoing active development, and you will miss out if you just statically copy it. To hotlink, copy only the following line:  
mw.loader.load('//en.wikinews.org/w/index.php?title=MediaWiki:Gadget-dictionaryLookupHover.js&action=raw&ctype=text/javascript');  
See //en.wikinews.org/wiki/WN:WiktLookup#Wiktionary_lookup_gadget_.28Hover_box_variety.29
for details on this script, and how to use it on your own site.  
Note this script can take a number of parameters. Parameters are stored in the wiktLookup object. Generally its a good idea to set parameters before the onload event is fired (some parameters it matters, others it doesn't). An example of parameters would be using the following js code (don't feel like you have to set all of them. they all have defaults. this is just an example):  
if (!window.wiktLookup) wiktLookup = {};
wiktLookup.count = 1; //number of defn to return.
wiktLookup.showWord = bold; // to show what word we're looking up. one of bold, , link
wiktLookup.noRedir = false;// true to stop magic (not mediawiki)-redirection. unrecomended
wiktLookup.audio = true;// true, false, autoplay. NOT IMPLEMENTED
wiktLookup.width = 500; // width of box. make sure number not string. in units of pixels.
wiktLookup.height = 400; //- height of box
wiktLookup.key = 'w';// - ctrl+shift+key makes box popup (should be lowercase. default is 'l')
wiktLookup.reverseShift = false; // - if set, requires shift+double click to lookup a word.
wiktLookup.mode = context; // - context, bottom. default to context. to display as tooltip, or at bottom
wiktLookup.definitionBegin = 'Definition ('; // - for i18n. in english it is 'Definition ('. used in mode='bottom'
wiktLookup.definitionEnd = '):'; // - for i18n. in English it is '):' used in bottom mode
wiktLookup.hideText = 'hide'; //- for i18n. in English it is 'hide'. used in bottom mode.
wiktLookup.exit = true; //have a hide link.
wiktLookup.disableByDefault = true; //enable only in <span>blah</span> sections.  
- /  
/*** This is the stable version of the gadget js.***/
/*
Stolen from fr wikinews, and than subsequently heavily modified by Bawolff. This script is based on the french one created by :en:wiktionary:User:Bequw and en:wiktionary:User:Conrad.Irwin. The bottom mode is heavily based on work done by :fr:wikt:user:Darkdadaah.  
Special thanks for wikinews:User:Amgine, :fr:Wikinews:User:Otourly, :fr:wikinews:user:Sniff, :fr:Wikinews:User:JackPotte, :en:wikibooks:user:TestPilot, and many others for support and assistance.  
The current version of this is maintained by Bawolff. please don't hesitate to contact me (bawolff - //en.wikinews.org/wiki/user_talk:Bawolff ) if you have any issues, comments, bugs, need help, or whatever.
- /  
/*global wgUserLanguage, wgContentLanguage, window, addOnloadHook, XSLTProcessor*/
/*jslint browser: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, newcap: true, immed: true, maxerr: 80 */  
/*members TEXT_NODE, addEventListener, appendChild, attachEvent, body,
, charAt, clientWidth, clientX, clientY, cloneContents,
cloneRange, collapse, createElement, createRange, data, detach, display,
documentElement, en, endContainer, endOffset, event, expand, findWord,
firstChild, focus, fr, fra, frc, fre, getElementById, getInnerWidth,
getRangeAt, getScrollX, getScrollY, getSelection, height, id,
innerWidth, , length, lookupWord, match, nl, nodeType, ondblclick,
open, pageXOffset, pageYOffset, position, preferLang, preventDefault,
rangeOffset, rangeParent, rangeToWord, readyState, replace, returnValue,
scrollLeft, scrollTop, selection, setEnd, setStart, setup, shiftKey,
split, src, startContainer, startOffset, stopPropagation,
stripAfterDash, style, substring, text, toString, top, useNewWindow,
validLangs, wgUserLanguage, width, wiktDomain, wiktLookup, zIndex, audio,
count, toUpperCase, audio, noRedir
- /  
//set wiktLookup.useNewWindow to true to force new window.
if (!window.wiktLookup) var wiktLookup = {};
wiktLookup.key = wiktLookup.key ? wiktLookup.key : 'l';
/*
Options:
count - numb results to return
showWord - bold, , link
noRedir - true to stop redirection
audio - true, false, autoplay
width - width of box
height - height of box
key - ctrl+shift+key makes box popup (should be lowercase)
reverseShift - if set, requires shift+double click to lookup a word.
mode - context, bottom. default to context
definitionBegin - for i18n. in english it is 'Definition ('
definitionEnd - for i18n. in English it is '):'
hideText - for i18n. in English it is 'hide';
exit - X in corner to hide.
disableByDefault - only enable in specially marked sections.
- /  
wiktLookup.validLangs = {ta: "ta", en: "en", fr: "fr", frc: "fr", fra: "fr", fre: "fr", nl: "nl", es: 'es', it: 'it', ja: 'ja', pt: 'pt', ru: 'ru'};
wiktLookup.wiktDomain = 'ta'; //default
wiktLookup.stripAfterDash = /-.*$/;
if (wiktLookup.validLangs[wgUserLanguage]) {
wiktLookup.wiktDomain = wiktLookup.validLangs[wgUserLanguage];
} else if (wiktLookup.validLangs[wgUserLanguage.replace(wiktLookup.stripAfterDash)]) {
wiktLookup.wiktDomain = wiktLookup.validLangs[wgUserLanguage.replace(wiktLookup.stripAfterDash)];
} else if (wiktLookup.validLangs[mw.config.get('wgContentLanguage')]) {
wiktLookup.wiktDomain = wiktLookup.validLangs[mw.config.get('wgContentLanguage')];
} else if (wiktLookup.validLangs[mw.config.get('wgContentLanguage').replace(wiktLookup.stripAfterDash)]) {
wiktLookup.wiktDomain = wiktLookup.validLangs[mw.config.get('wgContentLanguage').replace(wiktLookup.stripAfterDash)];
}  
if (!wiktLookup.preferLang) wiktLookup.preferLang = (window.wgContentLanguage ? mw.config.get('wgContentLanguage') : wiktLookup.wiktDomain );  
if (wiktLookup.disableByDefault === undefined) wiktLookup.disableByDefault = false;  
wiktLookup.getOptions = function {
var opt = '';
if (wiktLookup.count)
opt += '&count=' + wiktLookup.count;
if (wiktLookup.showWord)
opt += '&showWord=' + wiktLookup.showWord;
if (wiktLookup.audio)
opt += '&audio=' + wiktLookup.audio;
if (wiktLookup.noRedir)
opt += '&rd=500';
if (wiktLookup.exit)
opt += '&exit=true';  
return opt;
}  
wiktLookup.rangeToWord = function (selection) {
//includes apostraphes
//fixme: if at begin of container.
var finalText = selection.toString;
try {
var expandWord = /['\-]/ //list of chars that are not actual word boundries.
var range = selection.getRangeAt(0);
var rangeBefore = range.cloneRange;
if (rangeBefore.startOffset !== 0 ) {
rangeBefore.setStart(rangeBefore.startContainer, rangeBefore.startOffset - 1);
var textNode = rangeBefore.cloneContents.firstChild;
if (textNode.nodeType === 3 && expandWord.test(textNode.data[0])) {
for (var i = 0; i < 30 /*to stop run-away*/; i++) {
rangeBefore.setStart(rangeBefore.startContainer, rangeBefore.startOffset - 1);
textNode = rangeBefore.cloneContents.firstChild;
if ((textNode.nodeType !== 3) || (textNode.nodeType === 3 && textNode.data.match(/^\s/))) {
rangeBefore.setStart(rangeBefore.startContainer, rangeBefore.startOffset + 1);
finalText = rangeBefore.toString;
rangeBefore.detach;
range.detach;
return finalText;
}
else if (rangeBefore.startOffset === 0) { //at the end of the range. this might add periods, which are stripped later.
finalText = rangeBefore.toString;
rangeBefore.detach;
range.detach;