User:Ruakh/keypad.js

Hello, you have come here looking for the meaning of the word User:Ruakh/keypad.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Ruakh/keypad.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Ruakh/keypad.js in singular and plural. Everything you need to know about the word User:Ruakh/keypad.js you have here. The definition of the word User:Ruakh/keypad.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Ruakh/keypad.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
/* todo:
-find better "icon"
-refactor/cleanup
*/

 var html;

// Returns a new XMLHttpRequest object, except in IE, where it returns the
// equivalent.
function newXMLHttpRequest() {
  var reqObj = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
   try {
    reqObj = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
      reqObj = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
     reqObj = false;
    }
   }
@else
   reqObj = false;
@end @*/
  if (!reqObj) {
   try {
    reqObj = new XMLHttpRequest();
   } catch (e) {
    reqObj = false;
   }
  }
 return reqObj;
}

function getAppendCharFunc(c) {
  return function() {
    document.getElementById('searchInput').value += c;
    return false;
  };
}

// Given, in string form, one of the "p"-s that makes up the edittools, returns
// an table object containing all the character-adding links. (N.B.: currently
// expects its input in a rather idiosyncratic form. TODO change that)
function p2Table ( txt ) {
  var q='"';
  var sq="'";
  tbl = document.createElement('table');
  tbl.id = 'searchKeyboard';
  var row = document.createElement('tr');
  txt = txt.replace(/<span\s*class=*\bcharinsert\b**>/g, '<charinsert>');
  kybs = txt.split('<charinsert>');
  var onthisline=0;
  for (i=1; i<kybs.length; i++) {
    var chars = kybs.split(//);
    var needBr=false;
    for (j=0; j<chars.length; j++) {
      if ( chars.indexOf('special') > -1 ) {
        tbl.appendChild(row);
        row = document.createElement('tr');
        onthisline=0;
      }
      if ( chars.length > 1 || chars == ' ' || chars == 'p' || chars == '>' || chars == "'" || chars == '"' )
        continue;
      onthisline++;
      var cell = document.createElement('td');
      cell.bgcolor = 'gray';
      cell.align = 'center';
      var link = document.createElement('a');
      link.href = '#' + chars;
      link.onclick = getAppendCharFunc(chars);
      link.appendChild(document.createTextNode(chars));
      cell.appendChild(link);
      row.appendChild(cell);
      needBr=true;
      if (onthisline > 7) {
        tbl.appendChild(row);
        row = document.createElement('tr');
        onthisline=0;
      }
    }
  }
  tbl.appendChild(row);
  return tbl;
}

function keyPadSelection( keyBoardNumber ) {
  var tbl = document.getElementById('searchKeyboard');
  var kW = tbl.parentNode;
  kW.removeChild(tbl);
  var txt = html.split('<p ');
  var tbl = p2Table(txt);
  kW.insertBefore(tbl, kW.firstChild);
  return true;
}

function keyPad() {
    var q='"';
    var sq="'";
    var selected = parseInt( getCookie('edittoolscharsubset') );
    if ( isNaN(selected) ) selected = 1;
    if (selected < 1) selected = 1; //skip zero, as that is the "templates" thing.
    var sF = document.getElementById("searchform");
        var searchBox = document.getElementById('searchBody');
        var kW = document.createElement('div');
        var tbl = document.createElement('table');
        tbl.bgcolor = 'black';
        tbl.id = 'searchKeyboard';
        var row = document.createElement('tr');
        var cell = document.createElement('td');
        var link = document.createElement('a');
        var func;
        link.appendChild(document.createTextNode('testing'));
        cell.appendChild(link);
        cell.bgcolor = 'gray';
        cell.align = 'center';

 var req = newXMLHttpRequest();
 req.open('GET', 'http://en.wiktionary.orghttps://en.wiktionary.org/w/index.php?title=MediaWiki:Edittools&action=raw', true) ;
 req.send(null);
 req.onreadystatechange = function() {
   if (req.readyState==4) {
     html = req.responseText;
     //TODO: get all of them, extract name, add combobox, all loop thing that makes them visible=flase/visible=true.
     var menus = html.split('editpage-specialchars').split('<p ');
     var menu = document.createElement('select');
     menu.style.display = 'inline';
     for (j=2; j<menus.length; j++) {
         var lin = menus.split('id=');
         if (!lin) lin = '';
         if (lin.indexOf('"') > -1) lin = lin.split('"');
         if (lin.indexOf('edittools-') == 0) lin = lin.split('edittools-');
         if (lin == '') { lin = 'Unnamed ' + j; };
         menu.options = new Option(lin);
        }
     menu.options.selected = true;
     menu.onchange = function() { keyPadSelection(this.selectedIndex); };
     tbl.appendChild(row);
     kW.appendChild(tbl);
     searchBox.appendChild(kW);
     kW.appendChild(menu);
    }
   }

  return;
}

function addKeyPadTimer() {
  setTimeout( 'keyPad()', 200 ); //wait 1/5th of one second.
}

$( addKeyPadTimer );