Object.freeze((function () { String.prototype.isInt = function () { return !isNaN(parseInt(this, 10)); }; String.prototype.isLower = function () { return this == this.toLowerCase(); }; var globals = { active : null, activeArr : [], activeInput : null, elements : [], positions : [], lastInput : null, lastPosition : 0, newTab : false, notify : null, hintTypes : [ "a, textarea, select, input:not([type=hidden]), button, frame, iframe, [onclick], [onmousedown]," + "[role=link], [role=option], [role=button], [role=option], img", // HINT_T_ALL //[ "iframe", "a", // HINT_T_LINKS "img", // HINT_T_IMAGES "input:not([type=hidden]), input[type=text], input[type=password], input[type=search], textarea", // HINT_T_EDITABLE "[src], [href]" // HINT_T_URL ] }; var HintTypes = { HINT_T_ALL : 0, HINT_T_LINKS : 1, HINT_T_IMAGES : 2, HINT_T_EDITABLE : 3, HINT_T_URL : 4 }; var OpenMode = { OPEN_NORMAL : 1<<0, OPEN_NEW_VIEW : 1<<1, OPEN_NEW_WINDOW : 1<<2 }; var __getTextHints = function(arr) { var length = arr.length; var i, j, e, text, cur, start, l, max, r; if (length === 0) return; if (arr[0] instanceof __numberHint) { for (i=0; i 0 ? width : width + compleft) + "px"; overlay.style.height = (comptop > 0 ? height : height + comptop) + "px"; overlay.style.top = t + "px"; overlay.style.left = l + "px"; overlay.style.display = "block"; overlay.style.cursor = "pointer"; overlay.style.zIndex = 37001; this.overlay = overlay; }; this.hint = hint; }; var __createElement = function(tagname) { var element = document.createElement(tagname); if (!element.style) { var namespace = document.getElementsByTagName('html')[0].getAttribute('xmlns') || "http://www.w3.org/1999/xhtml"; element = document.createElementNS(namespace, tagname); } return element; }; var __numberHint = function (element, win, rect, offsetElement) { this.varructor = __newHint; this.varructor(element, win, rect, offsetElement); this.getStart = function(n) { var start = parseInt(Math.log(n) / Math.log(10), 10)*10; if (n > 10*start-start) { start*=10; } return Math.max(start, 1); }; this.betterMatch = function(input) { var length = globals.activeArr.length; var i, cl; if (input.isInt()) return 0; var bestposition = 37; var ret = 0; for (i=0; i input.length)) { __clear(); globals.lastInput = input; __showHints(type, globals.newTab); return __updateHints(input, type); } globals.lastInput = input; if (input) { if (globals.style == "number") { if (input[input.length-1].isInt()) { input = input.match(/[0-9]+/g).join(""); matchHint = true; } else input = input.match(/[^0-9]+/g).join(""); } else if (globals.style == "letter") { var lowerSeq = globals.letterSeq.toLowerCase(); if (input[input.length-1].isLower()) { if (lowerSeq.indexOf(input.charAt(input.length-1)) == -1) return "_dwb_no_hints_"; input = input.match(new RegExp("[" + lowerSeq + "]", "g")).join(""); matchHint = true; } else input = input.match(new RegExp("[^" + lowerSeq + "]", "g")).join(""); } } for (i=0; i height || r.bottom < 0 || r.left > width || r.right < 0 || !e.getClientRects()[0]) return null; return r; }; var __clear = function() { var p, i; try { if (globals.elements) { for (i=0; i 0) { switch (type) { case HintTypes.HINT_T_IMAGES: ret = e.src; __clear(); return ret; case HintTypes.HINT_T_URL : ret = e.hasAttribute("href") ? e.href : e.src; __clear(); return ret; default: break; } } if ((tagname && (tagname == "input" || tagname == "textarea"))) { if (type == "radio" || type == "checkbox") { e.focus(); __clickElement(e, "click"); ret = ret || "_dwb_check_"; } else if (elementType && (elementType == "submit" || elementType == "reset" || elementType == "button")) { __clickElement(e, "click"); ret = ret || "_dwb_click_"; } else { e.focus(); ret = ret || "_dwb_input_"; } } else if (e.hasAttribute("role")) { __clickElement(e); ret = ret || "_dwb_click_"; } else { if (tagname == "a" || e.hasAttribute("onclick")) __clickElement(e, "click"); else if (e.hasAttribute("onmousedown")) __clickElement(e, "mousedown"); else if (e.hasAttribute("onmouseover")) __clickElement(e, "mouseover"); else __clickElement(e); ret = ret || "_dwb_click_"; } __clear(); return ret; }; var __focusNext = function() { var newpos = globals.lastPosition === globals.activeArr.length-1 ? 0 : globals.lastPosition + 1; __setActive(globals.activeArr[newpos]); globals.lastPosition = newpos; }; var __focusPrev = function() { var newpos = globals.lastPosition === 0 ? globals.activeArr.length-1 : globals.lastPosition - 1; __setActive(globals.activeArr[newpos]); globals.lastPosition = newpos; }; var __addSearchEngine = function() { var i, j; try { __createStyleSheet(document); var hints = document.createDocumentFragment(); var res = document.body.querySelectorAll("form"); var r, e; var oe = __getOffsets(document); for (i=0; i