Welcome to the TWC Wiki! You are not logged in. Please log in to the Wiki to vote in polls, change skin preferences, or edit pages. See HERE for details of how to LOG IN.

Difference between revisions of "MediaWiki:Common.js"

From TWC Wiki
Jump to navigationJump to search
(blanked (don't think any of this is in use) - pls note DO NOT ever use the 13:37 revision below it crashes wiki for javascript users...)
(Tag: Replaced)
 
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/** Should force links within <span class="newwin">xxxx</span> to open in new window
 
* @source https://www.mediawiki.org/wiki/Snippets/Open_specific_links_in_new_window
 
* @version 2018-09-15
 
*/
 
$( function () {
 
$( '#mw-content-text' ).on( 'click', '.newwin > a', function () {
 
var otherWindow = window.open();
 
otherWindow.opener = null;
 
otherWindow.location = this;
 
return false;
 
} );
 
} );
 
 
 
/* Script:  [[User:TheDJ/Gadget-HotCat.js]]
 
  * HotCat: Adds an easy way to add, modify and remove categories
 
  * Documentation: [[User:TheDJ/HotCat]]
 
  * Originally written by: Magnus Manske
 
  *
 
  * This version was forked from http://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&oldid=10204404
 
  * Major changes:
 
  *  - blacklist code is disabled.
 
  *  - all code for the uploadForm has been removed
 
  *  - autocommit is disabled
 
  *  - will be enabled on pages without categories so that you can easily add them
 
  *  - uses javascript:void() as a dummy value for href in order to avoid a conflict with popups.
 
  *  - checks for the "Uncategorized" category and removes it if a category is added
 
  *  - does not use JSconfig for configuration options like its Commons original
 
  *  - tries to detect other categories and if possible, add to the end of them.
 
  *  - fixes a bug in the suggestion list with titles containing : character
 
  *  - Uses opensearch API to look for categories. Allows for case insensitive search.
 
  * [[User:TheDJ]] 2008-03-12
 
  <source lang="javascript"><nowiki> */
 
var hotcat_running = 0 ;
 
var hotcat_last_v = "" ;
 
var hotcat_exists_yes = "http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/P_yes.svg/20px-P_yes.svg.png" ;
 
var hotcat_exists_no = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png" ;
 
 
var hotcat_no_autocommit = 0;
 
// In Commons hotcat_suggestion_delay is configurable trough JSconfig
 
var hotcat_suggestion_delay = 100;
 
 
var hotcat_old_onsubmit = null;
 
var hotcat_nosuggestions = false;
 
// hotcat_nosuggestions is set to true if we don't have XMLHttp! (On IE6, XMLHttp uses
 
// ActiveX, and the user may deny execution.) If true, no suggestions will ever be
 
// displayed, and there won't be any checking whether the category  exists.
 
// Lupo, 2008-01-20
 
 
var hotcat_modify_blacklist = new Array (
 
""
 
) ;
 
 
addOnloadHook ( hotcat ) ;
 
 
function hotcat () {
 
  if ( hotcat_check_action() ) return ; // Edited page, reloading anyway
 
 
  // Do not add interface to protected pages, if user has no edit permission
 
  // Also disable it on preview pages: on a preview, we *are* already editing,
 
  // and HotCat must not open the page for editing a second time. Lupo, 2008-02-27
 
  if( wgAction != "view" || document.getElementById('ca-viewsource' ) != null ||
 
      wgNamespaceNumber == -1 || wgNamespaceNumber == 10 )
 
    return;
 
 
  // If we have no Categories div, then add one
 
  // TheDJ, 2008-02-28
 
 
  var visible_catlinks = document.getElementById ('mw-normal-catlinks') || getElementsByClassName ( document , "p" , "catlinks" ) [0];
 
  var hidden_catlinks = document.getElementById ('mw-hidden-catlinks');
 
 
  if ( visible_catlinks == null || typeof( visible_catlinks ) == 'undefined' ) {
 
    d3 = document.createElement ( "div" );
 
    d3.id = "mw-normal-catlinks";
 
    d3.innerHTML = '<a href="/wiki/Special:Categories" title="Special:Categories">Categories</a>: ';
 
    visible_catlinks = d3;
 
 
    if ( hidden_catlinks ) {
 
      // There are hidden categories.
 
      hidden_catlinks.parentNode.insertBefore( d3, hidden_catlinks );
 
      hidden_catlinks.parentNode.className = "catlinks";
 
    } else {
 
      // This page has no categories at all, lets create a section where we can add them.
 
      var footer = getElementsByClassName ( document , "div" , "printfooter" ) [0];
 
      if( !footer ) return; // We have no idea where we should add this.
 
 
      d1 = document.createElement ( "div" );
 
      d1.id = "catlinks";
 
      d1.className = "catlinks";
 
      d1.appendChild ( d3 );
 
      footer.parentNode.insertBefore( d1, footer.nextSibling );
 
    }
 
  }
 
 
  hotcat_modify_existing ( visible_catlinks ) ;
 
  hotcat_append_add_span ( visible_catlinks ) ;
 
}
 
 
function hotcat_append_add_span ( catline ) {
 
  var span_add = document.createElement ( "span" ) ;
 
  var span_sep = document.createTextNode ( " | " ) ;
 
  if ( catline.getElementsByTagName("span")[0] ) catline.appendChild ( span_sep ) ;
 
  catline.appendChild ( span_add ) ;
 
  hotcat_create_span ( span_add ) ;
 
}
 
 
String.prototype.ucFirst = function () {
 
  return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
 
}
 
 
function hotcat_is_on_blacklist ( cat_title ) {
 
  if ( !cat_title ) return 0 ;
 
  cat_title = cat_title.ucFirst.replace( /Category:/gi, "" );
 
  for ( var i = 0 ; i < hotcat_modify_blacklist.length ; i++ ) {
 
    if ( cat_title.substr ( 0 , hotcat_modify_blacklist[i].length ) == hotcat_modify_blacklist[i] ) return 1 ;
 
  }
 
  return 0 ;
 
}
 
 
function hotcat_modify_span ( span , i ) {
 
  //var cat_title = span.firstChild.getAttribute ( "title" ) ;
 
  // This fails with MW 1.13alpha if the category is a redlink, because MW 1.13alpha appends
 
  // [[MediaWiki:Red-link-title]] to the category name... it also fails if the category name
 
  // contains "&" (because that is represented by &amp; in the XHTML both in the title and in
 
  // the link's content (innerHTML). Extract the category name from the href instead:
 
  var cat_title = null;
 
  var classes  = span.firstChild.getAttribute ('class');
 
  if (classes && classes.search (/\bnew\b/) >= 0) {  // href="/w/index.php?title=...&action=edit"
 
    cat_title = hotcatGetParamValue ('title', span.firstChild.href);
 
  } else { // href="/wiki/..."
 
    var re = new RegExp (wgArticlePath.replace (/\$1/, '(.*)'));
 
    var matches = re.exec (span.firstChild.href);
 
    if (matches && matches.length > 1)
 
      cat_title = decodeURIComponent (matches[1]);
 
    else
 
      return;
 
  }
 
  // Strip namespace, replace _ by blank
 
  cat_title = cat_title.substring (cat_title.indexOf (':') + 1).replace (/_/g, ' ');
 
 
  var sep1 = document.createTextNode ( " " ) ;
 
  var a1 = document.createTextNode ( "(-)" ) ;
 
  var remove_link = document.createElement ( "a" ) ;
 
  // Set the href to a dummy value to make sure we don't move if somehow the onclick handler
 
  // is bypassed.
 
  remove_link.className = "noprint";
 
  remove_link.href = "#catlinks";
 
  remove_link.onclick = hotcat_remove;
 
  remove_link.appendChild ( a1 ) ;
 
  span.appendChild ( sep1 ) ;
 
  span.appendChild ( remove_link ) ;
 
 
  // Disabled blacklist check TheDJ, 2008-02-28
 
  // if ( hotcat_is_on_blacklist ( cat_title ) ) return ;
 
  var mod_id = "hotcat_modify_" + i ;
 
  var sep2 = document.createTextNode ( " " ) ;
 
  var a2 = document.createTextNode ( "(±)" ) ;
 
  var modify_link = document.createElement ( "a" ) ;
 
  modify_link.id = mod_id ;
 
  modify_link.className = "noprint";
 
  modify_link.href = "javascript:hotcat_modify(\"" + mod_id + "\");" ;
 
  modify_link.appendChild ( a2 ) ;
 
  span.appendChild ( sep2 ) ;
 
  span.appendChild ( modify_link ) ;
 
  span.hotcat_name = cat_title; //Store the extracted category name in our own new property of the span DOM node
 
}
 
 
function hotcat_modify_existing ( catline ) {
 
  var spans = catline.getElementsByTagName ( "span" ) ;
 
  for ( var i = 0 ; i < spans.length ; i++ ) {
 
    hotcat_modify_span ( spans[i] , i ) ;
 
  }
 
}
 
 
function hotcat_getEvt (evt) {
 
  return evt || window.event || window.Event; // Gecko, IE, Netscape
 
}
 
 
function hotcat_evt2node (evt) {
 
  var node = null;
 
  try {
 
    var e = hotcat_getEvt (evt);
 
    node = e.target;
 
    if (!node) node = e.srcElement;
 
  } catch (ex) {
 
    node = null;
 
  }
 
  return node;
 
}
 
 
function hotcat_evtkeys (evt) {
 
  var code = 0;
 
  try {
 
    var e = hotcat_getEvt (evt);
 
    if (typeof(e.ctrlKey) != 'undefined') { // All modern browsers
 
      if (e.ctrlKey)  code |= 1;
 
      if (e.shiftKey) code |= 2;
 
      if (e.altKey) code |= 4;
 
    } else if (typeof (e.modifiers) != 'undefined') { // Netscape...
 
      if (e.modifiers & Event.CONTROL_MASK) code |= 1;
 
      if (e.modifiers & Event.SHIFT_MASK)  code |= 2;
 
      if (e.modifiers & Event.ALT_MASK)  code |= 4;
 
    }
 
  } catch (ex) {
 
  }
 
  return code;
 
}
 
 
function hotcat_killEvt (evt)
 
{
 
  try {
 
    var e = hotcat_getEvt (evt);
 
    if (typeof (e.preventDefault) != 'undefined') {
 
      e.preventDefault();
 
      e.stopPropagation()
 
    } else
 
      e.cancelBubble = true;
 
  } catch (ex) {
 
  }
 
}
 
 
function hotcat_remove (evt) {
 
  var node = hotcat_evt2node (evt);
 
  if (!node) return false;
 
  // Get the category name from the original link to the category
 
  var cat_title = node.parentNode.hotcat_name;
 
 
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
 
  if ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4 )) // CTRL or ALT pressed?
 
    editlk = editlk + '&hotcat_nocommit=1';
 
  hotcat_killEvt (evt);
 
  document.location = editlk + '&hotcat_removecat=' + encodeURIComponent(cat_title) ;
 
  return false;
 
}
 
 
function hotcatGetParamValue(paramName, h) {
 
  if (typeof h == 'undefined' ) { h = document.location.href; }
 
  var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
 
  var m=cmdRe.exec(h);
 
  if (m) {
 
    try {
 
      return decodeURIComponent(m[1]);
 
    } catch (someError) {}
 
  }
 
  return null;
 
}
 
 
// New. Code by Lupo & Superm401, added by Lupo, 2008-02-2007
 
function hotcat_find_category (wikitext, category)
 
{
 
  var cat_name  = category.replace(/([\\\^\$\.\?\*\+\(\)])/g, "\\$1");
 
  var initial  = cat_name.substr (0, 1);
 
  var cat_regex = new RegExp ("\\[\\[\\s*[Cc]ategory\\s*:\\s*"
 
                              + (initial == "\\"
 
                                ? initial
 
                                : "[" + initial.toUpperCase() + initial.toLowerCase() + "]")
 
                              + cat_name.substring (1).replace (/[ _]/g, "[ _]")
 
                              + "\\s*(\\|.*?)?\\]\\]", "g"
 
                            );
 
  var result = new Array ();
 
  var curr_match  = null;
 
  while ((curr_match = cat_regex.exec (wikitext)) != null) {
 
    result [result.length] = {match : curr_match};
 
  }
 
  return result; // An array containing all matches, with positions, in result[i].match
 
}
 
 
// New. Code by TheDJ, 2008-03-12
 
function hotcat_find_ins ( wikitext )
 
{
 
  var re = /\[\[(?:Category):[^\]]+\]\]/ig
 
  var index = -1;
 
  while( re.exec(wikitext) != null ) index = re.lastIndex;
 
 
  if( index > -1) return index;
 
  //we should try to find interwiki links here, but that's for later.
 
 
  return -1;
 
}
 
 
// Rewritten (nearly) from scratch. Lupo, 2008-02-27
 
function hotcat_check_action () {
 
  var ret = 0;
 
  if (wgAction != 'edit' || typeof(document.editform) == "undefined" ) return ret; // Not an edit page, so not our business...
 
  var summary = new Array () ;
 
  var t = document.editform.wpTextbox1.value ;
 
  var prevent_autocommit = 0;
 
  if (  (typeof (hotcat_no_autocommit) != "undefined" && hotcat_no_autocommit)
 
      || hotcatGetParamValue ('hotcat_nocommit') == '1')
 
    prevent_autocommit = 1;
 
 
  var cat_rm  = hotcatGetParamValue ('hotcat_removecat');
 
  var cat_add = hotcatGetParamValue ('hotcat_newcat');
 
  var comment = hotcatGetParamValue ('hotcat_comment') || "";
 
 
  var cat_key = null;
 
  if (cat_rm != null && cat_rm.length > 0) {
 
    var matches = hotcat_find_category (t, cat_rm);
 
    if (!matches || matches.length == 0) {
 
      alert ('Category "' + cat_rm + '" not found; maybe it is in a template?');
 
      prevent_autocommit = 1;
 
    } else if (matches.length > 1) {
 
      alert ('Category "' + cat_rm
 
            + "\" found several times; don't know which occurrence to remove.");
 
      prevent_autocommit = 1;
 
    } else {
 
      if (cat_add != null && cat_add.length > 0 && matches[0].match.length > 1)
 
        cat_key = matches[0].match[1]; // Remember the category key, if any.
 
      var t1 = t.substring (0, matches[0].match.index);
 
      var t2 = t.substring (matches[0].match.index + matches[0].match[0].length);
 
      // Remove whitespace (properly): strip whitespace, but only up to the next line feed.
 
      // If we then have two linefeeds in a row, remove one. Otherwise, if we have two non-
 
      // whitespace characters, insert a blank.
 
      var i = t1.length - 1;
 
      while (i >= 0 && t1.charAt (i) != '\n' && t1.substr (i, 1).search (/\s/) >= 0) i--;
 
      var j = 0;
 
      while (j < t2.length && t2.charAt (j) != '\n' && t1.substr (j, 1).search (/\s/) >= 0) j++;
 
      if (i >= 0 && t1.charAt (i) == '\n' && j < t2.length && t2.charAt (j) == '\n')
 
        i--;
 
      if (i >= 0) t1 = t1.substring (0, i+1); else t1 = "";
 
      if (j < t2.length) t2 = t2.substring (j); else t2 = "";
 
      if (t1.length > 0 && t1.substring (t1.length - 1).search (/\S/) >= 0
 
          && t2.length > 0 && t2.substr (0, 1).search (/\S/) >= 0)
 
        t1 = t1 + ' ';
 
      t = t1 + t2;
 
      summary.push ( "Removed category \"" + cat_rm + "\"" ) ;
 
      ret = 1;
 
    }
 
  }
 
  if (cat_add != null && cat_add.length > 0) {
 
    var matches = hotcat_find_category (t, cat_add);
 
    if (matches && matches.length > 0) {
 
      alert ('Category "' + cat_add + '" already exists; not added.');
 
      prevent_autocommit = 1;
 
    } else {
 
      var insertionpoint = hotcat_find_ins( t );
 
      var newcatstring = '\n\[\[Category:' + cat_add + (cat_key != null ? cat_key : "") + '\]\]';
 
      if( insertionpoint > -1 ) {
 
        t = t.substring(0, insertionpoint ) + newcatstring + t.substring( insertionpoint );
 
      } else {
 
        t = t + newcatstring;
 
      }
 
      summary.push ( "Quick-adding category \"" + cat_add + "\"" + comment) ;
 
      var t2 = t.replace(/\{\{[Uu]ncategorized[^}]*\}\}/g, ""); // Remove "uncategorized" template
 
      if (t2.length != t.length) {
 
        t = t2;
 
        summary.push ( "removed {{uncategorized}}" ) ;
 
      }
 
      ret = 1;
 
    }
 
  }
 
  if (ret) {
 
    document.editform.wpTextbox1.value = t ;
 
    document.editform.wpSummary.value = summary.join( "; " )
 
                                      + " (using [[TWC Wiki:HotCat|HotCat]])" ;
 
    document.editform.wpMinoredit.checked = true ;
 
    if (!prevent_autocommit) {
 
      // Hide the entire edit section so as not to tempt the user into editing...
 
      var bodyContentId = document.getElementById("bodyContent") || document.getElementById("mw_contentholder");
 
      bodyContentId.style.display = "none";
 
      document.editform.submit();
 
    }
 
  }
 
  return ret;
 
}
 
 
function hotcat_clear_span ( span_add ) {
 
  while ( span_add.firstChild ) span_add.removeChild ( span_add.firstChild ) ;
 
}
 
 
function hotcat_create_span ( span_add ) {
 
  hotcat_clear_span ( span_add ) ;
 
  var a_add = document.createElement ( "a" ) ;
 
  var a_text = document.createTextNode ( "(+)" ) ;
 
  span_add.id = "hotcat_add" ;
 
  a_add.className = "noprint";
 
  a_add.href = "javascript:hotcat_add_new()" ;
 
  a_add.appendChild ( a_text ) ;
 
  span_add.appendChild ( a_add ) ;
 
}
 
 
function hotcat_modify ( link_id ) {
 
  var link = document.getElementById ( link_id ) ;
 
  var span = link.parentNode ;
 
  var catname = span.hotcat_name;
 
 
  while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
 
  span.firstChild.style.display = "none" ;
 
  hotcat_create_new_span ( span , catname ) ;
 
  hotcat_last_v = "" ;
 
  hotcat_text_changed () ; // Update icon
 
}
 
 
function hotcat_add_new () {
 
  var span_add = document.getElementById ( "hotcat_add" ) ;
 
  hotcat_clear_span ( span_add ) ;
 
  hotcat_last_v = "" ;
 
  hotcat_create_new_span ( span_add , "" ) ;
 
}
 
 
function hotcat_create_new_span ( thespan , init_text ) {
 
  var form = document.createElement ( "form" ) ;
 
  form.method = "post" ;
 
  form.onsubmit = function () { hotcat_ok(); return false; } ;
 
  form.id = "hotcat_form" ;
 
  form.style.display = "inline" ;
 
 
  var list = null;
 
 
  if (!hotcat_nosuggestions) {
 
    // Only do this if we may actually use XMLHttp...
 
    list = document.createElement ( "select" ) ;
 
    list.id = "hotcat_list" ;
 
    list.onclick = function ()
 
      {
 
        var l = document.getElementById("hotcat_list");
 
        if (l != null)
 
          document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text;
 
        hotcat_text_changed();
 
      };
 
    list.ondblclick = function (evt)
 
      {
 
        var l = document.getElementById("hotcat_list");
 
        if (l != null)
 
          document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text;
 
        // Don't call text_changed here if on upload form: hotcat_ok will remove the list
 
        // anyway, so we must not ask for new suggestions since show_suggestions might
 
        // raise an exception if it tried to show a no longer existing list.
 
        // Lupo, 2008-01-20
 
        hotcat_text_changed();
 
        hotcat_ok((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); // CTRL or ALT pressed?
 
      };
 
    list.style.display = "none" ;
 
  }
 
 
  var text = document.createElement ( "input" ) ;
 
  text.size = 40 ;
 
  text.id = "hotcat_text" ;
 
  text.type = "text" ;
 
  text.value = init_text ;
 
  text.onkeyup = function () { window.setTimeout("hotcat_text_changed();", hotcat_suggestion_delay ); } ;
 
 
  var exists = null;
 
  if (!hotcat_nosuggestions) {
 
    exists = document.createElement ( "img" ) ;
 
    exists.id = "hotcat_exists" ;
 
    exists.src = hotcat_exists_no ;
 
  }
 
 
  var OK = document.createElement ( "input" ) ;
 
  OK.type = "button" ;
 
  OK.value = "OK" ;
 
  OK.onclick = function (evt) { hotcat_ok ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); }; // CTRL or ALT pressed?
 
 
  var cancel = document.createElement ( "input" ) ;
 
  cancel.type = "button" ;
 
  cancel.value = "Cancel" ;
 
  cancel.onclick = hotcat_cancel ;
 
 
  if (list != null) form.appendChild ( list ) ;
 
  form.appendChild ( text ) ;
 
  if (exists != null) form.appendChild ( exists ) ;
 
  form.appendChild ( OK ) ;
 
  form.appendChild ( cancel ) ;
 
  thespan.appendChild ( form ) ;
 
  text.focus () ;
 
}
 
 
function hotcat_ok (nocommit) {
 
  var text = document.getElementById ( "hotcat_text" ) ;
 
  var v = text.value || "";
 
  v = v.replace(/_/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); // Trim leading and trailing blanks
 
 
  // Empty category ?
 
  if (!v) {
 
    hotcat_cancel() ;
 
    return ;
 
  }
 
 
  // Get the links and the categories of the chosen category page
 
  var url = wgServer + wgScriptPath + '/api.php?action=query&titles='
 
          + encodeURIComponent ('Category:' + v)
 
          + '&prop=info|links|categories&plnamespace=14&format=json&callback=hotcat_json_resolve';
 
  var request = sajax_init_object() ;
 
  if (request == null) {
 
    //Oops! We don't have XMLHttp...
 
    hotcat_nosuggestions = true;
 
    hotcat_closeform (nocommit);
 
    hotcat_running = 0;
 
    return;
 
  }
 
  request.open ('GET', url, true);
 
  request.onreadystatechange =
 
    function () {
 
      if (request.readyState != 4) return;
 
      if (request.status != 200) {
 
        hotcat_closeform (nocommit);
 
      } else {
 
        var do_submit = eval (request.responseText);
 
        var txt = document.getElementById ('hotcat_text');
 
        if (do_submit) {
 
          hotcat_closeform (
 
            nocommit
 
            ,(txt && txt.value != v) ? " (redirect \[\[:Category:" + v + "|" + v + "\]\] resolved)" : null
 
          );
 
        }
 
      }
 
    };
 
  request.setRequestHeader ('Pragma', 'cache=yes');
 
  request.setRequestHeader ('Cache-Control', 'no-transform');
 
  request.send (null);
 
}
 
 
function hotcat_json_resolve (params)
 
{
 
  function resolve (page)
 
  {
 
    var cats    = page.categories;
 
    var is_dab  = false;
 
    var is_redir = typeof (page.redirect) == 'string'; // Hard redirect?
 
    if (!is_redir && cats) {
 
      for (var c = 0; c < cats.length; c++) {
 
        var cat = cats[c]["title"];
 
        if (cat) cat = cat.substring (cat.indexOf (':') + 1); // Strip namespace prefix
 
        if (cat == 'Disambiguation') {
 
          is_dab = true; break;
 
        } else if (cat == 'Category_redirects' || cat == 'Category redirects') {
 
          is_redir = true; break;
 
        }
 
      }
 
    }
 
    if (!is_redir && !is_dab) return true;
 
    var lks = page.links;
 
    var titles = new Array ();
 
    for (i = 0; i < lks.length; i++) {
 
      if (  lks[i]["ns"] == 14                              // Category namespace
 
          && lks[i]["title"] && lks[i]["title"].length > 0) { // Name not empty
 
        // Internal link to existing thingy. Extract the page name.
 
        var match = lks[i]["title"];
 
        // Remove the category prefix
 
        match = match.substring (match.indexOf (':') + 1);
 
        titles.push (match);
 
        if (is_redir) break;
 
      }
 
    }
 
    if (titles.length > 1) {
 
      // Disambiguation page
 
      hotcat_show_suggestions (titles);
 
      return false;
 
    } else if (titles.length == 1) {
 
      var text = document.getElementById ("hotcat_text");
 
      if (text) text.value = titles[0];
 
    }
 
    return true;
 
  } // end local function resolve
 
 
  // We should have at most one page here
 
  for (var page in params.query.pages) return resolve (params.query.pages[page]);
 
  return true; // In case we have none.
 
}
 
 
function hotcat_closeform (nocommit, comment)
 
{
 
  var text = document.getElementById ( "hotcat_text" ) ;
 
  var v = text.value || "";
 
  v = v.replace(/_/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); // Trim leading and trailing blanks
 
  if (!v                                                // Empty
 
      || wgNamespaceNumber == 14 && v == wgTitle        // Self-reference
 
      || text.parentNode.parentNode.id != 'hotcat_add'  // Modifying, but
 
        && text.parentNode.parentNode.hotcat_name == v) //  name unchanged
 
  {
 
    hotcat_cancel ();
 
    return;
 
  }
 
 
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
 
  var url = editlk + '&hotcat_newcat=' + encodeURIComponent( v ) ;
 
 
  // Editing existing?
 
  var span = text.parentNode.parentNode ; // span.form.text
 
  if ( span.id != "hotcat_add" ) { // Not plain "addition" 
 
    url += '&hotcat_removecat=' + encodeURIComponent (span.hotcat_name);
 
  }
 
  if (nocommit) url = url + '&hotcat_nocommit=1';
 
  if (comment) url = url + '&hotcat_comment=' + encodeURIComponent (comment);
 
  // Make the list disappear:
 
  var list = document.getElementById ( "hotcat_list" ) ;
 
  if (list) list.style.display = 'none';
 
 
  document.location = url ;
 
}
 
 
function hotcat_just_add ( text ) {
 
  var span = document.getElementById("hotcat_form") ;
 
  while ( span.tagName != "SPAN" ) span = span.parentNode ;
 
  var add = 0 ;
 
  if ( span.id == "hotcat_add" ) add = 1 ;
 
  span.id = "" ;
 
  while ( span.firstChild ) span.removeChild ( span.firstChild ) ;
 
  var na = document.createElement ( "a" ) ;
 
  na.href = wgArticlePath.split("$1").join("Category:" + encodeURI (text)) ;
 
  na.appendChild ( document.createTextNode ( text ) ) ;
 
  na.setAttribute ( "title" , "Category:" + text ) ;
 
  span.appendChild ( na ) ;
 
  var catline = getElementsByClassName ( document , "p" , "catlinks" ) [0] ;
 
  if ( add ) hotcat_append_add_span ( catline ) ;
 
 
  for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
 
    if ( span.parentNode.childNodes[i] != span ) continue ;
 
    hotcat_modify_span ( span , i ) ;
 
    break ;
 
  }
 
}
 
 
function hotcat_cancel () {
 
  var span = document.getElementById("hotcat_form").parentNode ;
 
  if ( span.id == "hotcat_add" ) {
 
    hotcat_create_span ( span ) ;
 
  } else {
 
    while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
 
    span.firstChild.style.display = "" ;
 
    for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
 
      if ( span.parentNode.childNodes[i] != span ) continue ;
 
      hotcat_modify_span ( span , i ) ;
 
      break ;
 
    }
 
  }
 
}
 
 
function hotcat_text_changed () {
 
  if ( hotcat_running ) return ;
 
  var text = document.getElementById ( "hotcat_text" ) ;
 
  var v = text.value.ucFirst() ;
 
  if ( hotcat_last_v == v ) return ; // Nothing's changed...
 
 
  if (hotcat_nosuggestions) {
 
    // On IE, XMLHttp uses ActiveX, and the user may deny execution... just make sure
 
    // the list is not displayed.
 
    var list = document.getElementById ('hotcat_list');
 
    if (list != null) list.style.display = "none" ;
 
    var exists = document.getElementById ('hotcat_exists');
 
    if (exists != null) exists.style.display = "none" ;
 
    return;
 
  }
 
 
  hotcat_running = 1 ;
 
  hotcat_last_v = v ;
 
 
  if ( v != "" ) {
 
    var url = wgMWSuggestTemplate.replace("{namespaces}","14")
 
    .replace("{dbname}",wgDBname)
 
    .replace("{searchTerms}",encodeURIComponent(v));
 
    var request = sajax_init_object() ;
 
    if (request == null) {
 
      //Oops! We don't have XMLHttp...
 
      hotcat_nosuggestions = true;
 
      var list = document.getElementById ('hotcat_list');
 
      if (list != null) list.style.display = "none" ;
 
      var exists = document.getElementById ('hotcat_exists');
 
      if (exists != null) exists.style.display = "none" ;
 
      hotcat_running = 0;
 
      return;
 
    }
 
    request.open('GET', url, true);
 
    request.onreadystatechange =
 
      function () {
 
        if (request.readyState == 4) {
 
          try {
 
            eval( "var queryResult="+ request.responseText );
 
          } catch (someError ) {
 
            if( console && console.log )
 
              console.log( "Oh dear, our JSON query went down the drain?\nError: " +someError );
 
            return;
 
          }
 
          var pages = queryResult[1]; // results are *with* namespace here
 
          var titles = new Array();
 
          for ( var i = 0 ; pages && i < pages.length ; i++ ) {
 
            // Remove the namespace. No hardcoding of 'Category:', please, other Wikis may have
 
            // local names ("Kategorie:" on de-WP, for instance). Also don't break on category
 
            // names containing a colon
 
            var s = pages[i].substring (pages[i].indexOf (':') + 1);
 
            if ( s.substr ( 0 , hotcat_last_v.length ).toLowerCase() != hotcat_last_v.toLowerCase() ) break ;
 
            titles.push ( s ) ;
 
          }
 
          hotcat_show_suggestions ( titles ) ;
 
        }
 
      };
 
    request.setRequestHeader ('Pragma', 'cache=yes');
 
    request.setRequestHeader ('Cache-Control', 'no-transform');
 
    request.send(null);
 
  } else {
 
    hotcat_show_suggestions ( new Array () ) ;
 
  }
 
  hotcat_running = 0 ;
 
}
 
 
function hotcat_show_suggestions ( titles ) {
 
  var text = document.getElementById ( "hotcat_text" ) ;
 
  var list = document.getElementById ( "hotcat_list" ) ;
 
  var icon = document.getElementById ( "hotcat_exists" ) ;
 
  // Somehow, after a double click on the selection list, we still get here in IE, but
 
  // the list may no longer exist... Lupo, 2008-01-20
 
  if (list == null) return;
 
  if (hotcat_nosuggestions) {
 
    list.style.display = "none" ;
 
    if (icon != null) icon.style.display = "none";
 
    return;
 
  }
 
  if ( titles.length == 0 ) {
 
    list.style.display = "none" ;
 
    icon.src = hotcat_exists_no ;
 
    return ;
 
  }
 
 
  // Set list size to minimum of 5 and actual number of titles. Formerly was just 5.
 
  // Lupo, 2008-01-20
 
  list.size = (titles.length > 5 ? 5 : titles.length) ;
 
  // Avoid list height 1: double-click doesn't work in FF. Lupo, 2008-02-27
 
  if (list.size == 1) list.size = 2;
 
  list.style.align = "left" ;
 
  list.style.zIndex = 5 ;
 
  list.style.position = "absolute" ;
 
 
  // Was listh = titles.length * 20: that makes no sense if titles.length > list.size
 
  // Lupo, 2008-01-20
 
  var listh = list.size * 20;
 
  var nl = parseInt (text.offsetLeft) - 1 ;
 
  var nt = parseInt (text.offsetTop) - listh ;
 
  list.style.top = nt + "px" ;
 
  list.style.width = text.offsetWidth + "px" ;
 
  list.style.height = listh + "px" ;
 
  list.style.left = nl + "px" ;
 
  while ( list.firstChild ) list.removeChild ( list.firstChild ) ;
 
  for ( var i = 0 ; i < titles.length ; i++ ) {
 
    var opt = document.createElement ( "option" ) ;
 
    var ot = document.createTextNode ( titles[i] ) ;
 
    opt.appendChild ( ot ) ;
 
    //opt.value = titles[i] ;
 
    list.appendChild ( opt ) ;
 
  }
 
 
  icon.src = hotcat_exists_yes ;
 
 
  var nof_titles = titles.lenght;
 
  var first_title = titles.shift ();
 
  var v = text.value.ucFirst();
 
 
  text.focus();
 
  if ( first_title == v ) {
 
    if( nof_titles == 1 ) {
 
      // Only one result, and it's the same as whatever is in the input box: makes no sense
 
      // to show the list.
 
      list.style.display = "none";
 
    }
 
    return;
 
  }
 
  list.style.display = "block" ;
 
 
  // Put the first entry of the title list into the text field, and select the
 
  // new suffix such that it'll be overwritten if the user keeps typing.
 
  // ONLY do this if we have a way to select parts of the content of a text
 
  // field, otherwise, this is very annoying for the user. Note: IE does it
 
  // again differently from the two versions previously implemented.
 
  // Lupo, 2008-01-20
 
  // Only put first entry into the list if the user hasn't typed something
 
  // conflicting yet Dschwen 2008-02-18
 
  if ( ( text.setSelectionRange ||
 
        text.createTextRange ||
 
        typeof (text.selectionStart) != 'undefined' &&
 
        typeof (text.selectionEnd) != 'undefined' ) &&
 
        v == first_title.substr(0,v.length) )
 
  {
 
    // taking hotcat_last_v was a major annoyance,
 
    // since it constantly killed text that was typed in
 
    // _since_ the last AJAX request was fired! Dschwen 2008-02-18
 
    var nosel = v.length ;
 
 
    text.value = first_title ;
 
 
    if (text.setSelectionRange)      // e.g. khtml
 
      text.setSelectionRange (nosel, first_title.length);
 
    else if (text.createTextRange) { // IE
 
      var new_selection = text.createTextRange();
 
      new_selection.move ("character", nosel);
 
      new_selection.moveEnd ("character", first_title.length - nosel);
 
      new_selection.select();
 
    } else {
 
      text.selectionStart = nosel;
 
      text.selectionEnd  = first_title.length;
 
    }
 
  }
 
}
 
/* </nowiki></source> */
 
 
//<pre>
 
//Version: 3.1
 
//============================================================
 
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL
 
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE
 
//============================================================
 
// Vorschläge für neue Buttons werden gerne entgegengenommen
 
// Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.
 
 
//================================
 
//Control Variables
 
//
 
//rmEditButtons - Removes standard toolbar buttons
 
//XEBOrder - The order in which the buttons are displayed
 
 
document.write('<link rel="stylesheet" type="text/css" href="' +
 
      'http://en.wikipedia.org/w/index.php?title=User:MarkS/XEB/live.css' +
 
      '&action=raw&ctype=text/css&dontcountme=s">');
 
 
if(typeof XEBPopups== 'undefined')XEBPopups=true;
 
if(typeof XEBHideDelay== 'undefined')XEBHideDelay=0.5; //Time before the popup disappears after the mouse moves out
 
if(typeof XEBExtendEditSummary == 'undefined')XEBExtendEditSummary=true; // Is the edit summary extended after a popup
 
 
//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar 
 
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){
 
mwCustomEditButtons.push({
 
  "imageFile": imageFile,
 
  "speedTip": speedTip,
 
  "tagOpen": tagOpen,
 
  "tagClose": tagClose,
 
  "sampleText": sampleText});
 
}
 
 
if (typeof usersignature == 'undefined') var usersignature = '-- \~\~\~\~';
 
 
var Isrc='http://upload.wikimedia.org/wikipedia/commons/';
 
 
// English Wikipedia creates 11 extra buttons which are stored in mwCustomEditButtons
 
//  rather than mwEditButtons. However, there is no guarantee it will always be 11
 
//  so we count them here.
 
var enExtraButtons=mwCustomEditButtons.length;
 
 
 
var BDict={
 
'A':['e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'],
 
'B':['1/13/Button_enter.png','Line break','<br />','',''],
 
'C':['5/5f/Button_center.png','Center','<div style="text-align: center;">\n','\n<\/div>','Centred text'],
 
'D':['e/ea/Button_align_left.png','Left-Align','<div style="text-align: left; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Left-aligned text'],
 
'D1':['a/a5/Button_align_right.png','Right-Align','<div style="text-align: right; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Right-aligned text'],
 
'E':['0/04/Button_array.png','Table','\n{| class="wikitable" \n|- \n| 1 || 2\n|- \n| 3 || 4','\n|}\n',''],
 
'F':['1/1e/Button_font_color.png','Insert coloured text','<span style="color: ','">Coloured text<\/span>','ColourName'],
 
'FS':['1/1b/Button_miss_signature.png','Unsigned post','{{subst:unsigned|','|date}}','user name or IP'],
 
'G':['9/9e/Btn_toolbar_gallery.png','Picture gallery',"\n<gallery>\nImage:","|[[M63]]\nImage:Mona Lisa.jpg|[[Mona Lisa]]\nImage:Truite arc-en-ciel.jpg|Eine [[Forelle ]]\n<\/gallery>",'M63.jpg'],
 
'H':['7/74/Button_comment.png','Comment',"<!--","-->",'Comment'],
 
'I1':['6/6a/Button_sup_letter.png','Superscript','<sup>','<\/sup>','Superscript text'],
 
'I2':['a/aa/Button_sub_letter.png','Subscript','<sub>','<\/sub>','Subscript text'],
 
'J1':['5/58/Button_small.png','Small','<small>','<\/small>','Small Text'],
 
'J2':['5/56/Button_big.png','Big text','<big>','<\/big>','Big text'],
 
'K':['b/b4/Button_category03.png','Category',"[[Category:","]]",'Category name'],
 
'L':['8/8e/Button_shifting.png','Insert tab(s)',':','',':'],
 
'M':['f/fd/Button_blockquote.png','Insert block of quoted text','<blockquote style="border: 1px solid blue; padding: 2em;">\n','\n<\/blockquote>','Block quote'],
 
'N':['4/4b/Button_nbsp.png','nonbreaking space','&nbsp;','',''],
 
'O':['2/23/Button_code.png','Insert code','<code>','<\/code>','Code'],
 
'P':['3/3c/Button_pre.png','Pre formatted Text','<pre>','<\/pre>','Pre formatted text'],
 
'P1':['9/93/Button_sub_link.png','Insert link to sub-page','[[','/Sub_Page]]','Page'],
 
'Q':['d/d3/Button_definition_list.png','Insert definition list','\n; ','\n: Item 1\n: Item 2','Definition'],
 
'R':['7/79/Button_reflink.png','Insert a reference','<ref>','<\/ref>','Insert reference material'],
 
'R1':['7/79/Button_reflink.png','Start a reference','<ref name="','','Reference name'],
 
'R2':['9/99/Button_reflink_advanced_2.png','Insert reference material','">','</ref>','Reference material'],
 
'R3':['1/1a/Button_reflink_advanced_3.png','No reference material','','"/>',''],
 
'R4':['9/9a/Button_references.png','Reference footer',"\n==Notes==\n<!--See http://en.wikipedia.org/wiki/Wikipedia:Footnotes for an explanation of how to generate footnotes using the <ref(erences/)> tags-->\n<div class=\'references-small\'>\n<references/>\n</div>",'',''],
 
'S':['c/c9/Button_strike.png','Strikeout','<s>','<\/s>','Struck out text'],
 
'T':['e/eb/Button_plantilla.png','Template','{{','}}','Template name'],
 
'TS':['a/a4/TableStart.png','Start a table','{|','',''],
 
'TC':['7/71/TableCell.png','Table cell','|','',''],
 
'TE':['0/06/TableEnd.png','End a table','','|}',''],
 
'TR':['4/4c/TableRow.png','Start a table row','|-','',''],
 
'T1':['3/30/Tt_icon.png','Teletype text','<tt>','<\/tt>','Teletype Text'],
 
'TL':['3/37/Button_tl_template.png','Template link',"{{subst:"+"tl|",'}}','Template name'],
 
'U':['f/fd/Button_underline.png','Underlined',"<u>","<\/u>",'Underlined text'],
 
'V':['c/c8/Button_redirect.png','Redirect',"#REDIRECT [[","]]",'Article Name'],
 
'W':['8/88/Btn_toolbar_enum.png','Numbering',"\n# ","\n# Element 2\n# Element 3",'Element 1'],
 
'X':['1/11/Btn_toolbar_liste.png','List',"\n* ","\n* Element B\n* Element C",'Element A'],
 
'Y1':['c/ce/Button_no_include.png','No Include',"<noinclude>","<\/noinclude>",'Text'],
 
'Y2':['7/79/Button_include.png','Include only',"<includeonly>","<\/includeonly>",'Text'],
 
'Z':['3/35/Button_substitute.png','Substitute',"{{subst:","}}",'Template'],
 
'AI':['1/1c/Button_advanced_image.png','Advanaced Image',"[[Image:","|thumb|right|px|Caption]]",'FileName.jpg'],
 
'GEO':['b/b8/Button_Globe.png','Geo location',"","",""],
 
'TALK':['4/49/Button_talk.png','Add talk template',"","",""]
 
};
 
 
var XEBOrder2=[];
 
 
 
 
 
addOnloadHook(initButtons);
 
if(!wgIsArticle)// only if edit
 
{
 
 
if(XEBPopups)hookEvent("load", extendButtons);
 
}
 
 
function initButtons(){
 
 
var bc,d;
 
 
if (typeof XEBOrder!='string') // can be modified
 
XEBOrder2="A,D,C,D1,F,U,J1,E,G,Q,W,X,K,L,H,O,R,T".split(",");
 
else if (XEBOrder.toLowerCase()=='all')
 
for (b in BDict) XEBOrder2.push(b);
 
else XEBOrder2=XEBOrder.toUpperCase().split(",");
 
 
for (b in BDict) BDict[b][0] = Isrc+BDict[b][0]; // // Add the start of the URL (Isrc) to the XEB buttons
 
// If the user has defined any buttons then add them into the available button lists
 
 
if (typeof myButtons=='object')
 
  for (b in myButtons) BDict[b] = myButtons[b]; // custom user buttons
 
// Add the media wiki standard buttons into the available buttons
 
 
for (b in mwEditButtons) { // add standard buttons for full XEB order changing
 
 
// BDict[b]=[];
 
BDict[b]=[mwEditButtons[b].imageFile,mwEditButtons[b].speedTip,mwEditButtons[b].tagOpen,mwEditButtons[b].tagClose,mwEditButtons[b].sampleText];
 
 
// for (d in mwEditButtons[b]) BDict[b].push(mwEditButtons[b][d]);
 
}
 
 
// Build the new buttons
 
 
for (i=0;i<XEBOrder2.length;i++) {
 
bc = BDict[XEBOrder2[i]];
 
 
//Check if bc is an object
 
// - protects if user specified a non-existant buttons
 
// - IE causes a javascript error when viewing a page
 
if(typeof bc=='object')
 
{
 
 
//Call addCustomButton in wikibits
 
addCustomButton(bc[0],bc[1],bc[2],bc[3],bc[4]);
 
}
 
}
 
 
// Remove the default buttons (if requested by the user)
 
eraseButtons();
 
}
 
 
 
/** en: Removes arbitrary standard buttons from the toolbar
 
* @author: [[:de:User:Olliminatore]]
 
* @version: 0.1 (01.10.2006) **/
 
 
function eraseButtons(){
 
 
//Remove the buttons the user doesn't want
 
 
if(typeof rmEditButtons!='object') return;
 
 
if (typeof rmEditButtons[0] == 'string' && rmEditButtons[0].toLowerCase() == 'all')
 
{
 
mwEditButtons=[];
 
for(i=0;i<enExtraButtons;i++){mwCustomEditButtons.shift();}
 
}
 
//Sort the user's requests so we remove the button with the highest index first
 
//- This ensures we remove the buttons the user expects whatever order he requested the buttons in
 
rmEditButtons.sort(sortit);
 
 
//Remove individual buttons the user doesn't want
 
 
for(i=0;i<rmEditButtons.length;i++){
 
var n=rmEditButtons[i];
 
//Standard Wikimedia buttons
 
if(n>=0 && n<mwEditButtons.length){
 
if(n<mwEditButtons.length){
 
var x = -1;
 
while((++x)<mwEditButtons.length)
 
if(x>=n)
 
mwEditButtons[x] = mwEditButtons[x+1];
 
}
 
mwEditButtons.pop();
 
}
 
//Extra buttons in English Wikipedia
 
n=n-mwEditButtons.length;
 
if(n>0 && n<mwCustomEditButtons.length){
 
if(n<mwCustomEditButtons.length){
 
var x = -1;
 
while((++x)<mwCustomEditButtons.length)
 
if(x>=n)
 
mwCustomEditButtons[x] = mwCustomEditButtons[x+1];
 
}
 
mwCustomEditButtons.pop();
 
}
 
}
 
};
 
 
//Function:
 
// sortit
 
//Purpose:
 
// Used to sort the rmEditButtons array into descending order
 
function sortit(a,b){
 
return(b-a)
 
}
 
 
 
//Function:
 
//Purpose:
 
// Adds extended onclick-function to some buttons
 
function extendButtons(){
 
 
if(!(allEditButtons = document.getElementById('toolbar'))) return false;
 
if(typeof editform != 'undefined')
 
if(!(window.editform = document.forms['editform'])) return false;
 
 
//  table
 
extendAButton(Isrc+"0/04/Button_array.png",XEBPopupTable)
 
extendAButton(Isrc+"7/79/Button_reflink.png",XEBPopupRef)
 
extendAButton(Isrc+"b/b8/Button_Globe.png",XEBPopupGeoLink)
 
extendAButton(Isrc+"4/49/Button_talk.png",XEBPopupTalk)
 
extendAButton(Isrc+"1/1c/Button_advanced_image.png",XEBPopupImage)
 
//extendAButton(Isrc+"6/6a/Button_sup_letter.png",XEBPopupFormattedText)
 
 
// redirect -##IE doesn't like this line. Object doesn't support this property or method
 
//c=XEBOrder2.getIndex('V');
 
 
// if(c != -1)
 
// allEditButtons[bu_len+c].onclick=function(){
 
// var a='#REDIRECT \[\['+prompt("Which page do you want to redirect to\?")+'\]\]';
 
// document.editform.elements['wpTextbox1'].value=a;
 
// document.editform.elements['wpSummary'].value=a;
 
// document.editform.elements['wpWatchthis'].checked=false
 
//  };
 
};
 
 
function extendAButton(url,newfunc)
 
{
 
if(!(allEditButtons = document.getElementById('toolbar'))) return false;
 
if(typeof editform != 'undefined')
 
if(!(window.editform = document.forms['editform'])) return false;
 
allEditButtons = allEditButtons.getElementsByTagName('img');
 
for(i=0;i<allEditButtons.length;i++)
 
{
 
if(allEditButtons[i].src==url)
 
{
 
allEditButtons[i].onclick=newfunc;
 
}
 
}
 
}
 
 
//==========================================================================================================
 
// General purpose popup code
 
//==========================================================================================================
 
 
function getXEBPopupDiv(name)
 
{
 
XEBMainDiv= document.getElementById("XEB");
 
if(XEBMainDiv==null){
 
XEBMainDiv=document.createElement("div");
 
document.body.appendChild(XEBMainDiv);
 
XEBMainDiv.id="XEB";
 
}
 
 
me= document.getElementById("XEBPopup" & name);
 
if(!(me==null))return me;
 
me=document.createElement("div");
 
XEBMainDiv.appendChild(me);
 
 
me.id="XEBPopup";
 
me.style.position='absolute';
 
me.display='none';
 
me.visibility='hidden';
 
me.onmouseout=CheckHideXEBPopup;
 
me.onmouseover=cancelHidePopup;
 
return me;
 
}
 
 
//Function:
 
// CheckHideXEBPopup
 
//Purpose:
 
// Looks at the cursor position and if it has moved outside the popup it will close the popup
 
//Called:
 
// When the onMouseEvent is fired on the popup
 
 
function CheckHideXEBPopup(e){
 
m= document.getElementById("XEBmnu");
 
if(is_gecko)
 
{
 
ph=m.offsetHeight;
 
var x=e.clientX + window.scrollX;
 
var y=e.clientY + window.scrollY;;
 
s=window.getComputedStyle(m,"");
 
ph=s.height;
 
ph=Number(ph.substring(0,ph.length-2));
 
}
 
else
 
{
 
var x=event.clientX+ document.documentElement.scrollLeft + document.body.scrollLeft;
 
var y=event.clientY+ document.documentElement.scrollTop + document.body.scrollTop;
 
ph=m.offsetHeight;
 
}
 
pl=curPopup.x;
 
pt=curPopup.y;
 
pw=m.style.width;
 
pw=Number(pw.substring(0,pw.length-2));
 
 
if(x>(pl+2)&&x<(pl+pw-5)&&y>(pt+2)&&y<(pt+ph-5))return;
 
curPopup.hideTimeout=setTimeout('hideXEBPopup()',XEBHideDelay*1000);
 
}
 
 
function cancelHidePopup()
 
{
 
clearTimeout(curPopup.hideTimeout)
 
}
 
 
function hideXEBPopup(){
 
XEBMainDiv= document.getElementById("XEB");
 
m= document.getElementById("XEBPopup");
 
XEBMainDiv.removeChild(m);
 
}
 
 
function XEBstartDrag(e)
 
{
 
m=new GetPos(e||event);
 
curPopup.startDrag.mouse=m;
 
curPopup.startDrag.floatpopup.y=parseInt(curPopup.div.style.top);
 
curPopup.startDrag.floatpopup.x=parseInt(curPopup.div.style.left);
 
curPopup.dragging=true;
 
}
 
 
function XEBstopDrag(e)
 
{
 
if(curPopup.dragging==false)return;
 
curPopup.dragging=false;
 
}
 
 
function XEBDrag(e)
 
{
 
if(curPopup.dragging==false)return;
 
 
m=new GetPos(e||event);
 
x=parseInt(curPopup.startDrag.floatpopup.x+(m.x-curPopup.startDrag.mouse.x));
 
y=parseInt(curPopup.startDrag.floatpopup.y+(m.y-curPopup.startDrag.mouse.y));
 
 
curPopup.div.style.top=y+"px";
 
curPopup.div.style.left=x+"px";
 
 
curPopup.x=x;
 
curPopup.y=y;
 
}
 
 
//=============================================================================
 
// Popup: Table
 
//=============================================================================
 
 
function XEBPopup(name,x,y)
 
{
 
// Make sure the popup can appear on the screen
 
 
this.IESelectedRange=XEBgetIESelectedRange();
 
 
winW=(is_gecko)?window.innerWidth:document.body.offsetWidth;
 
if((winW-this.width)<x)x=(winW-this.width);
 
 
this.div=getXEBPopupDiv(name);
 
this.div.style.zIndex=2000;
 
this.div.display="inline";
 
this.div.visibility="visible";
 
this.div.style.top=y + "px";
 
this.x=x;
 
this.y=y;
 
this.name=name;
 
 
this.startDrag=new Object;
 
this.startDrag.floatpopup=new Object;
 
}
 
 
function setInnerHTML(text)
 
{
 
winW=(is_gecko)?window.innerWidth:document.body.offsetWidth;
 
if((winW-this.width)<this.x)this.x=(winW-this.width);
 
this.div.style.left=this.x+ "px";
 
 
mt="<div id='XEBmnu' style='width:" + this.width + "px' >";
 
mt+='<div id="XEBmnuTitle" class="XEBPopupTitle" onmousedown="XEBstartDrag(event)" onmouseup="XEBstopDrag(event)" onmousemove="XEBDrag(event)">Title</div>'
 
mt+=text;
 
mt+="</div>";
 
this.div.innerHTML=mt;
 
//Turn off autocomplete. If the mouse moves over the autocomplete popup then x,y in CheckHidePopup is relative to the
 
// autocomplete popup and our popup is hidden
 
var InTexts = this.div.getElementsByTagName('input');
 
for (var i = 0; i < InTexts.length; i++) {
 
        var theInput = InTexts[i];
 
if (theInput.type == 'text'){theInput.setAttribute('autocomplete','off');}
 
}
 
//Add rollover features to menu items. Doing it here means we don't have to do it for each menu
 
x=XEBgetElementsByClassName(this.div,'XEBMnuItm','span');
 
for (var i = 0; i < x.length; i++) {
 
        var theItm = x[i];
 
theItm.onmouseout=XEBMenuMouseOut;
 
theItm.onmouseover=XEBMenuMouseOver;
 
}
 
 
this.div.style.borderWidth='thin';
 
this.div.style.borderStyle='solid';
 
this.div.style.backgroundColor='#D0D0D0';
 
}
 
XEBPopup.prototype.width=250;
 
XEBPopup.prototype.dragging=false;
 
XEBPopup.prototype.setInnerHTML=setInnerHTML;
 
 
var curPopup;
 
 
function GetPos(e)
 
{
 
this.x=e.clientX-10+ document.documentElement.scrollLeft + document.body.scrollLeft;
 
this.y=e.clientY-10+ document.documentElement.scrollTop + document.body.scrollTop;
 
}
 
 
function XEBPopupTable(e){
 
m=new GetPos(e||event);
 
 
curPopup=new XEBPopup("table",m.x,m.y);
 
 
mt='<p>Enter the table parameters below: <\/p>'
 
+'<form name="XEBPopupTableForm">'
 
+'Table caption: <input type="checkbox" name="inputCaption"><p\/>'
 
+'Table alignment: center<input type="checkbox" name="inputAlign"><p\/>'
 
+'Table headline: colored<input type="checkbox" name="inputHead"><p\/>'
 
+'Number of rows: <input type="text" name="inputRow" value="3" size="2"><p\/>'
 
+'Number of columns: <input type="text" name="inputCol" value="3" size="2"><p\/>'
 
//+'Alternating grey lines: <input type="checkbox" name="inputLine" checked="1" ><p\/>'
 
+'Item column: <input type="checkbox" name="inputItems" ><p\/>'
 
+'Sortable: <input type="checkbox" name="inputSort" ><p\/>'
 
+'<\/form>'
 
+'<i>The default table allows for fields and values only.<\/i><p\/>'
 
+'Check "Item column" to allow for the table to have fields, items, and values.<\/i><p\/>'
 
+'<p><button onClick="javascript:insertTableCode()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>'
 
 
curPopup.setInnerHTML(mt);
 
 
return true;
 
}
 
 
function insertTableCode(){
 
f=document.XEBPopupTableForm;
 
var caption = (f.inputCaption.checked)?"|+ TABLE CAPTION \n":"";
 
var exhead = (f.inputHead.checked)?'|- style="background: #DDFFDD;"\n':"";
 
var nbRow = parseInt(f.inputRow.value);
 
var nbCol = parseInt(f.inputCol.value);
 
var exfield = f.inputItems.checked;
 
var align = (f.inputAlign.checked)?'align="center"':"";
 
 
//generateTable(caption, exhead, nbCol, nbRow, exfield, align);
 
 
var code = "\n";
 
code += '{| {{prettytable}} ' + align + ' '; // en: class="wikitable"
 
code+=(f.inputSort.checked)?'class="sortable" \n':'\n';
 
code += caption + exhead;
 
if (exfield) code += '!\n';
 
for (i=1;i<nbCol+1;i++) code += '! FELD ' + i + '\n';
 
var items = 0;
 
for (var j=0;j<nbRow;j++){
 
if (exfield) {
 
items++;
 
code += '|-\n! style="background: #FFDDDD;"|ITEM ' + items + '\n';
 
} else code += '|-\n';
 
for (i=0;i<nbCol;i++) code += '| Element\n';
 
}
 
code += '|}\n';
 
hideXEBPopup();
 
insertTags('','', code);
 
extendSummary('table');
 
 
return false;
 
 
 
// Get the text currently selected by user in the textAra
 
// This code is based on part of the insertTags function in wikibits.js
 
 
function XEBGetSelectedText()
 
{
 
var txtarea;
 
if (document.editform) {
 
txtarea = document.editform.wpTextbox1;
 
} else {
 
// some alternate form? take the first one we can find
 
var areas = document.getElementsByTagName('textarea');
 
 
txtarea = areas[0];
 
}
 
// IE & Opera
 
if (document.selection  && !is_gecko)
 
{
 
var theSelection = document.selection.createRange().text;
 
if (!theSelection) theSelection='';
 
}
 
// Mozilla
 
else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 
var replaced = false;
 
var startPos = txtarea.selectionStart;
 
var endPos = txtarea.selectionEnd;
 
var theSelection = (txtarea.value).substring(startPos, endPos);
 
if (!theSelection) theSelection='';
 
}
 
return theSelection;
 
}
 
 
//Notes:
 
// IE loses the cursor position in the textarea when the popup is used.
 
// So we save the cursor position here
 
function XEBgetIESelectedRange(){
 
var IESel=new Object;
 
var txtarea;
 
if (document.editform) {
 
txtarea = document.editform.wpTextbox1;
 
} else {
 
// some alternate form? take the first one we can find
 
var areas = document.getElementsByTagName('textarea');
 
 
txtarea = areas[0];
 
}
 
// IE & Opera
 
 
if (document.selection  && !is_gecko)
 
{
 
txtarea.focus();
 
IESel.Rng=document.selection.createRange();
 
return IESel;
 
}
 
}
 
 
function XEBinsertText(beforeText,selText,afterText,IESelectedRange) {
 
var newText=beforeText + selText + afterText;
 
var txtarea;
 
if (document.editform) {
 
txtarea = document.editform.wpTextbox1;
 
} else {
 
// some alternate form? take the first one we can find
 
var areas = document.getElementsByTagName('textarea');
 
txtarea = areas[0];
 
}
 
 
// IE
 
if (document.selection  && !is_gecko) {
 
 
tr=IESelectedRange.Rng;
 
tr.text=newText;
 
txtarea.focus();
 
//txtarea.caretpos=tr.duplicate();
 
tr.select();
 
 
return;
 
 
// Mozilla
 
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 
var replaced = false;
 
var startPos = txtarea.selectionStart;
 
var endPos = txtarea.selectionEnd;
 
 
if (endPos-startPos) {
 
replaced = true;
 
}
 
var scrollTop = txtarea.scrollTop;
 
// var myText = (txtarea.value).substring(startPos, endPos);
 
// if (!myText) {
 
// myText=sampleText;
 
// }
 
// if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
 
// subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
 
// } else {
 
// subst = tagOpen + myText + tagClose;
 
// }
 
txtarea.value = txtarea.value.substring(0, startPos) + newText +
 
txtarea.value.substring(endPos, txtarea.value.length);
 
txtarea.focus();
 
//set new selection
 
if (!replaced) {
 
var cPos = startPos+(newText.length);
 
txtarea.selectionStart = cPos;
 
txtarea.selectionEnd = cPos;
 
} else {
 
txtarea.selectionStart = startPos+beforeText.length;
 
txtarea.selectionEnd = startPos+beforeText.length+selText.length;
 
}
 
txtarea.scrollTop = scrollTop;
 
 
// All other browsers get no toolbar.
 
// There was previously support for a crippled "help"
 
// bar, but that caused more problems than it solved.
 
}
 
// reposition cursor if possible
 
if (txtarea.createTextRange) {
 
 
txtarea.caretPos = document.selection.createRange().duplicate();
 
//txtarea.caretPos =IESelectedRange.Rng;
 
}
 
txtarea.focus();
 
}
 
 
 
//============================================================
 
// Table generator
 
//============================================================
 
/** en: Generate an array using Mediawiki syntax
 
* @author: originally from fr:user:dake
 
* @version: 0.2 */
 
function generateTable(caption, exhead, nbCol, nbRow, exfield, align){
 
 
};
 
 
 
function XEBPopupRef(e){
 
 
m=new GetPos(e||event);
 
 
curPopup=new XEBPopup("ref",m.x,m.y);
 
curPopup.width=500;
 
mt='<p>Enter the reference parameters below: <\/p>'
 
+'<form name="XEBPopupRefForm">'
 
+'Name:<input type="text" name="refName" value="" size="10"><p\/>'
 
+'Material:<input type="text" name="refMaterial" value="' + XEBGetSelectedText() + '" size="20">'
 
+'<\/form>'
 
+'<p><button onClick="javascript:insertRef()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
curPopup.setInnerHTML(mt);
 
// document.XEBPopupRefForm.refName.focus();
 
return true;
 
}
 
 
function insertRef(){
 
f=document.XEBPopupRefForm;
 
var refName = f.refName.value;
 
var refMaterial=f.refMaterial.value;
 
 
hideXEBPopup();
 
var code1='<ref';
 
code1+=(refName)?' name="'+refName+'">':'>';
 
code2=refMaterial;
 
code3='<\/ref>'
 
XEBinsertText(code1,code2,code3,curPopup.IESelectedRange);
 
 
extendSummary('ref');
 
return false;
 
}
 
 
//===GEO LINK Function==================================================
 
 
function XEBPopupGeoLink(e)
 
{
 
m=new GetPos(e||event);
 
 
curPopup=new XEBPopup("geo",m.x,m.y);
 
curPopup.width=300;
 
mt='<p>Enter the location parameters below: <\/p>'
 
+'<form name="XEBPopupGeoLinkForm">'
 
+'Loction:<p\/>'
 
+'<table style="background: transparent;">'
 
+'<tr><td>Latitude:<\/td><td><input type="text" autocomplete="off" name="geoLatDeg" value="" size="4"><\/td>'
 
+'<td><input type="text" name="geoLatMin" size="4"><\/td>'
 
+'<td><input type="text" name="geoLatSec" size="4"><\/td>'
 
+'<td><select name="geoLatNS"><option value="N">N<option value="S">S</select><\/td><\/tr>'
 
+'<tr><td>Longitude:<\/td><td><input type="text" name="geoLonDeg" value="" size="4"><\/td>'
 
+'<td><input type="text" name="geoLonMin" value="" size="4"><\/td>'
 
+'<td><input type="text" name="geoLonSec" value="" size="4"><\/td>'
 
+'<td><select name="geoLonEW"><option value="E">E<option value="W">W</select><\/td><\/tr>'
 
+'<\/table>'
 
+'Region:<input type="text" name="geoRegion" value="" size="4"><p\/>'
 
+'Type:'
 
+'<SELECT NAME="geoType" size="5">'
 
+'<OPTION VALUE="country">Country<OPTION VALUE="state">State'
 
+'<OPTION VALUE="adm1st">Admin unit, 1st level<OPTION VALUE="adm2st">Admin unit, 2nd level'
 
+'<OPTION VALUE="city">City<OPTION VALUE="airport">Airport'
 
+'<OPTION VALUE="mountain">Mountain<OPTION VALUE="isle">Isle'
 
+'<OPTION VALUE="waterbody">Waterbody<OPTION VALUE="landmark" SELECTED>Landmark'
 
+'<OPTION VALUE="forest">forest</SELECT><br>'
 
+'Title: <input type="checkbox" name="geoTitle" ><p\/>'
 
+'<\/form>'
 
+'<p><button onClick="javascript:insertGeoLink()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
curPopup.setInnerHTML(mt);
 
document.paramForm.refName.focus();
 
return true;
 
 
}
 
function insertGeoLink()
 
{
 
f=document.XEBPopupGeoLinkForm;
 
 
var code='{{Coor ';
 
if(f.geoTitle.checked)code+='title ';
 
ft='dms';
 
if(f.geoLatSec.value==''&&f.geoLonSec.value=='')ft='dm';
 
if(ft=='dm'&&f.geoLatMin.value==''&&f.geoLonMin.value=='')ft='d';
 
code+=ft;
 
code+='|'+f.geoLatDeg.value;
 
code+=(ft=='dm'||ft=='dms')?'|'+f.geoLatMin.value:'';
 
code+=(ft=='dms')?'|'+f.geoLatSec.value:'';
 
code+='|'+f.geoLatNS.value;
 
code+='|'+f.geoLonDeg.value;
 
code+=(ft=='dm'||ft=='dms')?'|'+f.geoLonMin.value:'';
 
code+=(ft=='dms')?'|'+f.geoLonSec.value:'';
 
code+='|'+f.geoLonEW.value;
 
code+='|type:'+f.geoType.value+'_region:'+f.geoRegion.value
 
code+='}}';
 
insertTags('','', code);
 
extendSummary('geo-location');
 
hideXEBPopup();
 
return false;
 
}
 
 
//===Talk Page entry Function===========================================
 
 
function XEBPopupTalk(e)
 
{
 
m=new GetPos(e||event);
 
 
curPopup=new XEBPopup("talk",m.x,m.y);
 
curPopup.width=200;
 
mt='<div style="font-size:medium"><p>Please choose:<\/p>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(1)">Test1<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(2)">Self Test<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(3)">Nonsense<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(4)">Please stop<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(5)">Last chance<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(6)">Blanking<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(7)">Blatant<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(8)">*BLOCKED*<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(9)">Spam<\/span><br>'
 
mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(10)">Npov<\/span></div>'
 
 
curPopup.setInnerHTML(mt);
 
 
return true;
 
 
}
 
function XEBInsertTalk(itm)
 
{
 
hideXEBPopup();
 
if(itm==1)code='{{subst:test1-n|}}';
 
if(itm==2)code='{{subst:selftest-n|}}';
 
if(itm==3)code='{{subst:test2-n|}}';
 
if(itm==4)code='{{subst:test3-n|}}';
 
if(itm==5)code='{{subst:test4-n|}}';
 
if(itm==6)code='{{subst:test2a-n|}}';
 
if(itm==7)code='{{subst:bv-n|}}';
 
if(itm==8)code='{{subst:blantant|}}';
 
if(itm==9)code='{{subst:spam-n|}}';
 
if(itm==10)code='{{subst:NPOV user}}';
 
 
insertTags('','', code);
 
return false;
 
}
 
function XEBPopupImage(e)
 
{
 
m=new GetPos(e||event);
 
 
curPopup=new XEBPopup("image",m.x,m.y);
 
curPopup.width=300;
 
 
mt='<p>Enter the image parameters below: <\/p>'
 
+'<form name="XEBPopupImageForm">'
 
+'File:<input type="text" name="imgFile" value="' + XEBGetSelectedText() + '" size="30"><br>'
 
+'Type:<SELECT NAME="imgType">'
 
+'<OPTION VALUE="thumb">Thumbnail'
 
+'<OPTION VALUE="frame">Frame'
 
+'<OPTION VALUE="none">[not specified]'
 
+'</SELECT><br>'
 
+'Location:<SELECT NAME="imgLocation">'
 
+'<OPTION VALUE="left">Left'
 
+'<OPTION VALUE="center">Centre'
 
+'<OPTION VALUE="right">Right'
 
+'<OPTION VALUE="none">None'
 
+'</SELECT><br>'
 
+'Size:<input type="text" name="imgSize" value="100" size="3">px<br>'
 
+'Caption:<input type="text" name="imgCaption" value="" size="30"><\/p>'
 
+'<\/form>'
 
+'<p><button onClick="javascript:XEBInsertImage()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
curPopup.setInnerHTML(mt);
 
 
return true;
 
}
 
function XEBInsertImage()
 
{
 
f=document.XEBPopupImageForm;
 
hideXEBPopup();
 
var code='[[Image:';
 
code+=f.imgFile.value;
 
code+='|'+f.imgType.value;
 
code+='|'+f.imgLocation.value;
 
code+='|'+f.imgSize.value;
 
code+='|'+f.imgCaption.value;
 
code+=']]';
 
insertTags('','', code);
 
extendSummary('image');
 
 
return false;
 
}
 
 
function XEBPopupFormattedText(e)
 
{
 
m=new GetPos(e||event);
 
 
curPopup=new XEBPopup("image",m.x,m.y);
 
curPopup.width=300;
 
 
mt='<form name="XEBPopupImageForm">'
 
+'<table  style="background: transparent;">'
 
+'<tr><td>Bold:<\/td><td><input type="checkbox" name="textBold"><\/td>'
 
+'<td>Superscript:<\/td><td><input type="checkbox" name="textSuperscript"><\/td><\/tr>'
 
+'<tr><td>Italic:<\/td><td><input type="checkbox" name="textItalic"><\/td>'
 
+'<td>Subscript:<\/td><td><input type="checkbox" name="textSubscript"><\/td><\/tr>'
 
+'<tr><td>Strike:<\/td><td><input type="checkbox" name="textStrike"><\/td>'
 
+'<td>&nbsp;<\/td><\/tr>'
 
+'</table>'
 
+'Size:<SELECT NAME="textSize">'
 
+'<OPTION VALUE="small">small'
 
+'<OPTION VALUE="normal">[Normal]'
 
+'<OPTION VALUE="big">big'
 
+'</SELECT><br><table style="background:transparent;"><tr><td>Colour:<\/td><td>'
 
+'<table width="100px">'
 
+'<tr><td colspan="4">None<\/td></tr>'
 
+'<tr><td bgcolor="aqua">&nbsp;<\/td><td bgcolor="gray"> &nbsp;<\/td>'
 
+'<td bgcolor="olive">&nbsp;<\/td><td bgcolor="navy">&nbsp;<\/td><\/tr>'
 
+'<tr><td bgcolor="black">&nbsp;<\/td><td bgcolor="green"> &nbsp;<\/td>'
 
+'<td bgcolor="purple">&nbsp;<\/td><td bgcolor="teal">&nbsp;<\/td><\/tr>'
 
+'<tr><td bgcolor="blue">&nbsp;<\/td><td bgcolor="lime">&nbsp;<\/td>'
 
+'<td bgcolor="red">&nbsp;<\/td><td bgcolor="white">&nbsp;<\/td><\/tr>'
 
+'<tr><td bgcolor="fuchsia">&nbsp;<\/td><td bgcolor="maroon">&nbsp;<\/td>'
 
+'<td bgcolor="silver">&nbsp;<\/td><td bgcolor="yellow">&nbsp;<\/td><\/tr>'
 
+'</table><\/td><\/tr>'
 
+'<\/form>'
 
+'Sample:'
 
+'<span id="sampleText">Text</span>"'
 
+'<p><button onClick="javascript:XEBInsertFormattedText()">Insert</button>'
 
+'<button onClick="hideXEBPopup()">Cancel</button>';
 
 
curPopup.setInnerHTML(mt);
 
 
return true;
 
}
 
 
function XEBUpdateSampleText()
 
{
 
f=document.XEBPopupImageForm;
 
}
 
 
//====================
 
 
function XEBMenuMouseOut(e)
 
{
 
var targ;
 
if (!e) var e = window.event;
 
if (e.target) targ = e.target;
 
else if (e.srcElement) targ = e.srcElement;
 
 
targ.style.color='black';
 
}
 
 
function XEBMenuMouseOver(e)
 
{ var targ;
 
if (!e) var e = window.event;
 
if (e.target) targ = e.target;
 
else if (e.srcElement) targ = e.srcElement;
 
 
targ.style.color='red';
 
}
 
 
//=======================================================================
 
// Other functions
 
//=======================================================================
 
 
function XEBgetElementsByClassName(parent,clsName,htmltag){
 
var arr = new Array();
 
var elems = parent.getElementsByTagName(htmltag);
 
for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
 
if ( elem.className == clsName ){
 
arr[arr.length] = elem;
 
}
 
}
 
return arr;
 
}
 
 
function extendSummary(newText)
 
{
 
if(!XEBExtendEditSummary)return;
 
s=document.editform.elements['wpSummary'].value;
 
s+=(s=='')?newText:' +'+newText;
 
document.editform.elements['wpSummary'].value=s;
 
}
 
 
function bug(msg)
 
{
 
if(wgUserName=='MarkS')alert(msg);
 
}
 
 
/** Collapsible tables *********************************************************
 
  *
 
  *  Description: Allows tables to be collapsed, showing only the header. See
 
  *              [[Wikipedia:NavFrame]].
 
  *  Maintainer on Wikipedia: [[User:R. Koot]]
 
  */
 
 
var autoCollapse = 2;
 
var collapseCaption = "hide";
 
var expandCaption = "show";
 
 
function hasClass( element, className ) {
 
  var Classes = element.className.split( " " );
 
  for ( var i = 0; i < Classes.length; i++ ) {
 
    if ( Classes[i] == className ) {
 
      return ( true );
 
    }
 
  }
 
  return ( false );
 
}
 
 
function collapseTable( tableIndex )
 
{
 
    var Button = document.getElementById( "collapseButton" + tableIndex );
 
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
 
    if ( !Table || !Button ) {
 
        return false;
 
    }
 
 
    var Rows = Table.getElementsByTagName( "tr" );
 
 
    if ( Button.firstChild.data == collapseCaption ) {
 
        for ( var i = 1; i < Rows.length; i++ ) {
 
            Rows[i].style.display = "none";
 
        }
 
        Button.firstChild.data = expandCaption;
 
    } else {
 
        for ( var i = 1; i < Rows.length; i++ ) {
 
            Rows[i].style.display = Rows[0].style.display;
 
        }
 
        Button.firstChild.data = collapseCaption;
 
    }
 
}
 
 
function createCollapseButtons()
 
{
 
    var tableIndex = 0;
 
    var NavigationBoxes = new Object();
 
    var Tables = document.getElementsByTagName( "table" );
 
 
    for ( var i = 0; i < Tables.length; i++ ) {
 
        if ( hasClass( Tables[i], "collapsible" ) ) {
 
            NavigationBoxes[ tableIndex ] = Tables[i];
 
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
 
            var Button    = document.createElement( "span" );
 
            var ButtonLink = document.createElement( "a" );
 
            var ButtonText = document.createTextNode( collapseCaption );
 
 
            Button.style.styleFloat = "right";
 
            Button.style.cssFloat = "right";
 
            Button.style.fontWeight = "normal";
 
            Button.style.textAlign = "right";
 
            Button.style.width = "6em";
 
 
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
 
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
 
            ButtonLink.appendChild( ButtonText );
 
 
            Button.appendChild( document.createTextNode( "[" ) );
 
            Button.appendChild( ButtonLink );
 
            Button.appendChild( document.createTextNode( "]" ) );
 
 
            var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
 
            /* only add button and increment count if there is a header row to work with */
 
            if (Header) {
 
                Header.insertBefore( Button, Header.childNodes[0] );
 
                tableIndex++;
 
            }
 
        }
 
    }
 
 
    for ( var i = 0;  i < tableIndex; i++ ) {
 
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
 
            collapseTable( i );
 
        }
 
    }
 
}
 
 
addOnloadHook( createCollapseButtons );
 
 
 
//</pre>
 

Latest revision as of 08:26, 18 April 2020

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