code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function drainQueue() { if (draining) { return; } var timeout = setTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { curre...
Used to grok the `now` parameter to createClock.
drainQueue
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function Item(fun, array) { this.fun = fun; this.array = array; }
Used to grok the `now` parameter to createClock.
Item
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function ok (val, msg) { if (!!!val) { fail(val, true, msg, '=='); } }
Used to grok the `now` parameter to createClock.
ok
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function AssertionError (opts) { opts = opts || {}; this.name = 'AssertionError'; this.actual = opts.actual; this.expected = opts.expected; this.operator = opts.operator || ''; this.message = opts.message || getAssertionErrorMessage(this); if (Error.captureStackT...
Used to grok the `now` parameter to createClock.
AssertionError
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function fail (actual, expected, message, operator, stackStartFunction) { throw new AssertionError({ message: message, actual: actual, expected: expected, operator: operator, stackStartFunction: stackStartFunction }); }
Used to grok the `now` parameter to createClock.
fail
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isUndefinedOrNull (val) { return (val === null || typeof val === 'undefined'); }
Used to grok the `now` parameter to createClock.
isUndefinedOrNull
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isArgumentsObject (val) { return (Object.prototype.toString.call(val) === '[object Arguments]'); }
Used to grok the `now` parameter to createClock.
isArgumentsObject
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isPlainObject (val) { return Object.prototype.toString.call(val) === '[object Object]'; }
Used to grok the `now` parameter to createClock.
isPlainObject
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function includes (haystack, needle) { /* jshint maxdepth: 3*/ var i; // Array#indexOf, but ie... if (isArray(haystack)) { for (i = haystack.length - 1; i >= 0; i = i - 1) { if (haystack[i] === needle) { return true; } ...
Used to grok the `now` parameter to createClock.
includes
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function getObjectKeys (obj) { var key; var keys = []; for (key in obj) { if (obj.hasOwnProperty(key)) { keys.push(key); } } return keys; }
Used to grok the `now` parameter to createClock.
getObjectKeys
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function objectsEqual (obj1, obj2) { /* jshint eqeqeq: false */ // Check for undefined or null if (isUndefinedOrNull(obj1) || isUndefinedOrNull(obj2)) { return false; } // Object prototypes must be the same if (obj1.prototype !== obj2.prototype) { ...
Used to grok the `now` parameter to createClock.
objectsEqual
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isDeepEqual (actual, expected) { /* jshint eqeqeq: false */ if (actual === expected) { return true; } if (expected instanceof Date && actual instanceof Date) { return actual.getTime() === expected.getTime(); } if (actual instanceof RegExp ...
Used to grok the `now` parameter to createClock.
isDeepEqual
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function functionThrows (fn, expected) { // Try/catch var thrown = false; var thrownError; try { fn(); } catch (err) { thrown = true; thrownError = err; } // Check error if (thrown && expected) { th...
Used to grok the `now` parameter to createClock.
functionThrows
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function errorMatches (actual, expected) { if (typeof expected === 'string') { return actual.message === expected; } if (expected instanceof RegExp) { return expected.test(actual.message); } if (actual instanceof expected) { return true; ...
Used to grok the `now` parameter to createClock.
errorMatches
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function getAssertionErrorMessage (error) { if (typeof require === 'function') { var util = require('util'); return [ truncateString(util.inspect(error.actual, {depth: null}), 128), error.operator, truncateString(util.inspect(error.expected...
Used to grok the `now` parameter to createClock.
getAssertionErrorMessage
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isNaN(value) { // Unlike global isNaN, this avoids type coercion // typeof check avoids IE host object issues, hat tip to // lodash var val = value; // JsLint thinks value !== value is "weird" return typeof value === "number" && value !== val; }
Used to grok the `now` parameter to createClock.
isNaN
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function getClass(value) { // Returns the internal [[Class]] by calling Object.prototype.toString // with the provided value as this. Return value is a string, naming the // internal class, e.g. "Array" return o.toString.call(value).split(/[ \]]/)[1]; }
Used to grok the `now` parameter to createClock.
getClass
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isArguments(object) { if (getClass(object) === 'Arguments') { return true; } if (typeof object !== "object" || typeof object.length !== "number" || getClass(object) === "Array") { return false; } if (typeof object.callee == "function") { return true; ...
@name samsam.isArguments @param Object object Returns ``true`` if ``object`` is an ``arguments`` object, ``false`` otherwise.
isArguments
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isElement(object) { if (!object || object.nodeType !== 1 || !div) { return false; } try { object.appendChild(div); object.removeChild(div); } catch (e) { return false; } return true; }
@name samsam.isElement @param Object object Returns ``true`` if ``object`` is a DOM element node. Unlike Underscore.js/lodash, this function will return ``false`` if ``object`` is an *element-like* object, i.e. a regular object with a ``nodeType`` property that holds the value ``1``.
isElement
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function keys(object) { var ks = [], prop; for (prop in object) { if (o.hasOwnProperty.call(object, prop)) { ks.push(prop); } } return ks; }
@name samsam.keys @param Object object Return an array of own property names.
keys
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isDate(value) { return typeof value.getTime == "function" && value.getTime() == value.valueOf(); }
@name samsam.isDate @param Object value Returns true if the object is a ``Date``, or *date-like*. Duck typing of date objects work by checking that the object has a ``getTime`` function whose return value equals the return value from the object's ``valueOf``.
isDate
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isNegZero(value) { return value === 0 && 1 / value === -Infinity; }
@name samsam.isNegZero @param Object value Returns ``true`` if ``value`` is ``-0``.
isNegZero
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function identical(obj1, obj2) { if (obj1 === obj2 || (isNaN(obj1) && isNaN(obj2))) { return obj1 !== 0 || isNegZero(obj1) === isNegZero(obj2); } }
@name samsam.equal @param Object obj1 @param Object obj2 Returns ``true`` if two objects are strictly equal. Compared to ``===`` there are two exceptions: - NaN is considered equal to NaN - -0 and +0 are not considered equal
identical
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function deepEqualCyclic(obj1, obj2) { // used for cyclic comparison // contain already visited objects var objects1 = [], objects2 = [], // contain pathes (position in the object structure) // of the already visited objects // indexes same as in objects arra...
@name samsam.deepEqual @param Object obj1 @param Object obj2 Deep equal comparison. Two values are "deep equal" if: - They are equal, according to samsam.identical - They are both date objects representing the same time - They are both arrays containing elements that are all deepEqual - They are objects with ...
deepEqualCyclic
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isObject(value) { if (typeof value === 'object' && value !== null && !(value instanceof Boolean) && !(value instanceof Date) && !(value instanceof Number) && !(value instanceof RegExp) && !(val...
used to check, if the value of a property is an object (cyclic logic is only needed for objects) only needed for cyclic logic
isObject
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function getIndex(objects, obj) { var i; for (i = 0; i < objects.length; i++) { if (objects[i] === obj) { return i; } } return -1; }
returns the index of the given object in the given objects array, -1 if not contained only needed for cyclic logic
getIndex
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function arrayContains(array, subset) { if (subset.length === 0) { return true; } var i, l, j, k; for (i = 0, l = array.length; i < l; ++i) { if (match(array[i], subset[0])) { for (j = 0, k = subset.length; j < k; ++j) { if (!match(array[i + j], su...
returns the index of the given object in the given objects array, -1 if not contained only needed for cyclic logic
arrayContains
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function inspect(obj, opts) { // default options var ctx = { seen: [], stylize: stylizeNoColor }; // legacy... if (arguments.length >= 3) ctx.depth = arguments[2]; if (arguments.length >= 4) ctx.colors = arguments[3]; if (isBoolean(opts)) { // legacy... ctx.showHidden = opts; } else if (...
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
inspect
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function stylizeWithColor(str, styleType) { var style = inspect.styles[styleType]; if (style) { return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm'; } else { return str; } }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
stylizeWithColor
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function stylizeNoColor(str, styleType) { return str; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
stylizeNoColor
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function arrayToHash(array) { var hash = {}; array.forEach(function(val, idx) { hash[val] = true; }); return hash; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
arrayToHash
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function formatValue(ctx, value, recurseTimes) { // Provide a hook for user-specified inspect functions. // Check that value is an object with an inspect function on it if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special ...
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatValue
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") ...
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatPrimitive
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatError
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { if (hasOwnProperty(value, String(i))) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); } else { output.push(''); ...
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatArray
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; if (desc.get) { if (desc.set) { str = ctx.stylize('[Getter/Setter]', 'special'); } else { str = ctx.stylize('[Getter]',...
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
formatProperty
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function reduceToSingleString(output, base, braces) { var numLinesEst = 0; var length = output.reduce(function(prev, cur) { numLinesEst++; if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); if (length > 60) { return braces[0] + ...
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
reduceToSingleString
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isArray(ar) { return Array.isArray(ar); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isArray
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isBoolean(arg) { return typeof arg === 'boolean'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isBoolean
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isNull(arg) { return arg === null; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isNull
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isNullOrUndefined(arg) { return arg == null; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isNullOrUndefined
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isNumber(arg) { return typeof arg === 'number'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isNumber
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isString(arg) { return typeof arg === 'string'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isString
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isSymbol(arg) { return typeof arg === 'symbol'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isSymbol
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isUndefined(arg) { return arg === void 0; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isUndefined
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isRegExp(re) { return isObject(re) && objectToString(re) === '[object RegExp]'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isRegExp
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isObject(arg) { return typeof arg === 'object' && arg !== null; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isObject
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isDate(d) { return isObject(d) && objectToString(d) === '[object Date]'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isDate
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isError(e) { return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isError
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isFunction(arg) { return typeof arg === 'function'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isFunction
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
isPrimitive
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function objectToString(o) { return Object.prototype.toString.call(o); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
objectToString
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function pad(n) { return n < 10 ? '0' + n.toString(10) : n.toString(10); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
pad
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); }
Echos the value of a value. Trys to print the value out in the best way possible given the different types. @param {Object} obj The object to print out. @param {Object} opts Optional options object that alters the output.
timestamp
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
Inherit the prototype methods from one constructor into another. The Function.prototype.inherits from lang.js rewritten as a standalone function (not on Function.prototype). NOTE: If this file is to be loaded during bootstrapping this function needs to be rewritten using some native functions as prototype setup using ...
hasOwnProperty
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
getElementToNavigate(linkOnly = false) { const focusedElement = document.activeElement; // StartPage seems to still focus and change it to body when the page loads. if (focusedElement == null || focusedElement.localName === 'body') { if ( this.focusedIndex < 0 || this.focusedIndex >= t...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
getElementToNavigate
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
highlight(searchResult) { const highlighted = searchResult.highlightedElement; if (highlighted == null) { console.error('No element to highlight: %o', highlighted); return; } highlighted.classList.add(searchResult.highlightClass); if ( this.options.sync.get('hideOutline') || ...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
highlight
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
unhighlight(searchResult) { const highlighted = searchResult.highlightedElement; if (highlighted == null) { console.error('No element to unhighlight: %o', highlighted); return; } highlighted.classList.remove(searchResult.highlightClass); highlighted.classList.remove('wsn-no-outline'); ...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
unhighlight
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
focus(index, scroll = FOCUS_SCROLL_ONLY) { if (this.focusedIndex >= 0) { const searchResult = this.searchResults[this.focusedIndex]; // If the current result is outside the viewport and FOCUS_SCROLL_ONLY was // requested, scroll to the current hidden result, but don't focus on the // new res...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
focus
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
focusNext(shouldWrap) { if (this.focusedIndex < this.searchResults.length - 1) { this.focus(this.focusedIndex + 1); } else if (shouldWrap) { this.focus(0); } }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
focusNext
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
focusPrevious(shouldWrap) { if (this.focusedIndex > 0) { this.focus(this.focusedIndex - 1); } else if (shouldWrap) { this.focus(this.searchResults.length - 1); } else { window.scrollTo(window.scrollX, 0); } }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
focusPrevious
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
focusDown(shouldWrap) { if ( this.focusedIndex + this.searchResults.itemsPerRow < this.searchResults.length ) { this.focus(this.focusedIndex + this.searchResults.itemsPerRow); } else if (shouldWrap) { const focusedRowIndex = this.focusedIndex % this.searchResults.itemsPerRow;...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
focusDown
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
focusUp(shouldWrap) { if (this.focusedIndex - this.searchResults.itemsPerRow >= 0) { this.focus(this.focusedIndex - this.searchResults.itemsPerRow); } else if (shouldWrap) { const focusedRowIndex = this.focusedIndex % this.searchResults.itemsPerRow; this.focus( this.searchRes...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
focusUp
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
constructor() { this.bindings = []; this.bindingsToggle = {active: true}; }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
constructor
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
async init() { this.options = new ExtensionOptions(); await this.options.load(); this.searchEngine = await getSearchEngine(this.options.sync.getAll()); if (this.searchEngine == null) { return; } const sleep = (milliseconds) => { return new Promise((resolve) => setTimeout(resolve, mil...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
init
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
sleep = (milliseconds) => { return new Promise((resolve) => setTimeout(resolve, milliseconds)); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
sleep
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
sleep = (milliseconds) => { return new Promise((resolve) => setTimeout(resolve, milliseconds)); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
sleep
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
injectCSS() { const style = document.createElement('style'); style.textContent = this.options.sync.get('customCSS'); document.head.append(style); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
injectCSS
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
initKeybindings() { this.bindingsToggle['active'] = false; for (const [shortcut, element, ,] of this.bindings) { /* eslint-disable-next-line new-cap */ const ms = Mousetrap(element); ms.unbind(shortcut); ms.reset(); } const isFirstCall = this.bindings.length === 0; this.bindi...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
initKeybindings
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
initSearchInputNavigation() { let searchInput = document.querySelector( this.searchEngine.searchBoxSelector, ); if (searchInput == null) { return; } // Only apply the extension logic if the key is not something the user may // have wanted to type into the searchbox, so that we don'...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
initSearchInputNavigation
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
shouldHandleSearchInputKey = (event) => { return event.ctrlKey || event.metaKey || event.key === 'Escape'; }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
shouldHandleSearchInputKey
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
shouldHandleSearchInputKey = (event) => { return event.ctrlKey || event.metaKey || event.key === 'Escape'; }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
shouldHandleSearchInputKey
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
detectSearchInput = () => { if (searchInput != null && searchInput.offsetParent != null) { return true; } searchInput = document.querySelector(this.searchEngine.searchBoxSelector); return searchInput != null && searchInput.offsetParent != null; }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
detectSearchInput
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
detectSearchInput = () => { if (searchInput != null && searchInput.offsetParent != null) { return true; } searchInput = document.querySelector(this.searchEngine.searchBoxSelector); return searchInput != null && searchInput.offsetParent != null; }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
detectSearchInput
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
outsideSearchboxHandler = (event) => { if (!detectSearchInput()) { return; } if (event === lastEvent) { return !shouldHandleSearchInputKey(event); } const element = document.activeElement; if ( element.isContentEditable || ['textarea', 'input'].include...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
outsideSearchboxHandler
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
outsideSearchboxHandler = (event) => { if (!detectSearchInput()) { return; } if (event === lastEvent) { return !shouldHandleSearchInputKey(event); } const element = document.activeElement; if ( element.isContentEditable || ['textarea', 'input'].include...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
outsideSearchboxHandler
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
insideSearchboxHandler = (event) => { if (!detectSearchInput()) { return; } lastEvent = event; if (!shouldHandleSearchInputKey(event)) { return true; } // Everything is selected; deselect all. if ( searchInput.selectionStart === 0 && searchInput....
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
insideSearchboxHandler
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
insideSearchboxHandler = (event) => { if (!detectSearchInput()) { return; } lastEvent = event; if (!shouldHandleSearchInputKey(event)) { return true; } // Everything is selected; deselect all. if ( searchInput.selectionStart === 0 && searchInput....
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
insideSearchboxHandler
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
registerObject(obj) { for (const [optionName, elementOrGetter] of Object.entries(obj)) { this.register(this.options.sync.get(optionName), () => { if (elementOrGetter == null) { return true; } let element; if (elementOrGetter instanceof HTMLElement) { element...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
registerObject
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
initTabsNavigation() { const tabs = this.searchEngine.tabs || {}; this.registerObject(tabs); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
initTabsNavigation
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
initResultsNavigation(isFirstCall) { this.registerObject({ navigatePreviousResultPage: this.searchEngine.previousPageButton, navigateNextResultPage: this.searchEngine.nextPageButton, }); this.resetResultsManager(); let gridNavigation = this.resultsManager.searchResults.gridNavigation; th...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
initResultsNavigation
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
resetResultsManager() { if (this.resultsManager != null && this.resultsManager.focusedIndex >= 0) { const searchResult = this.resultsManager.searchResults[this.resultsManager.focusedIndex]; // NOTE: it seems that search results can become undefined when the DOM // elements are removed (for...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
resetResultsManager
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
registerResultsNavigationKeybindings(gridNavigation) { const getOpt = (key) => { return this.options.sync.get(key); }; const onFocusChange = (callback) => { return () => { if (!this.resultsManager.isInitialFocusSet) { this.resultsManager.focus(0); } else { con...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
registerResultsNavigationKeybindings
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
getOpt = (key) => { return this.options.sync.get(key); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
getOpt
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
getOpt = (key) => { return this.options.sync.get(key); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
getOpt
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
onFocusChange = (callback) => { return () => { if (!this.resultsManager.isInitialFocusSet) { this.resultsManager.focus(0); } else { const _callback = callback.bind(this.resultsManager); _callback(getOpt('wrapNavigation')); } return false; }; ...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
onFocusChange
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
onFocusChange = (callback) => { return () => { if (!this.resultsManager.isInitialFocusSet) { this.resultsManager.focus(0); } else { const _callback = callback.bind(this.resultsManager); _callback(getOpt('wrapNavigation')); } return false; }; ...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
onFocusChange
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
initChangeToolsNavigation() { if (this.searchEngine.changeTools == null) { return; } const getOpt = (key) => { return this.options.sync.get(key); }; this.register(getOpt('navigateShowAll'), () => this.searchEngine.changeTools('a'), ); this.register(getOpt('navigateShowHour'...
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
initChangeToolsNavigation
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
getOpt = (key) => { return this.options.sync.get(key); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
getOpt
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
getOpt = (key) => { return this.options.sync.get(key); }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
getOpt
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
register(shortcuts, callback, element = document, global = false) { for (const shortcut of shortcuts) { this.bindings.push([shortcut, element, global, callback]); } }
Returns the element to click on upon navigation. The focused element in the document is preferred (if there is one) over the highlighted result. Note that the focused element does not have to be an anchor <a> element. @param {boolean} linkOnly If true the focused element is preferred only when it is a link with "href"...
register
javascript
infokiller/web-search-navigator
src/main.js
https://github.com/infokiller/web-search-navigator/blob/master/src/main.js
MIT
constructor(storage, defaultValues) { this.storage = storage; this.values = {}; this.defaultValues = defaultValues; }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
constructor
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
load() { // this.storage.get(null) returns all the data stored: // https://developer.chrome.com/extensions/storage#method-StorageArea-get return this.storage.get(null).then((values) => { this.values = values; // Prior to versions 0.4.* the keybindings were stored as strings, so we // migra...
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
load
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
save() { return this.storage.set(this.values); }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
save
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
get(key) { const value = this.values[key]; if (value != null) { return value; } return this.defaultValues[key]; }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
get
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
set(key, value) { this.values[key] = value; }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
set
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
clear() { return this.storage.clear().then(() => { this.values = {}; }); }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
clear
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
getAll() { // Merge options from storage with defaults. return {...this.defaultValues, ...this.values}; }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
getAll
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
createSyncedOptions = () => { return new BrowserStorage(browser.storage.sync, DEFAULT_OPTIONS); }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
createSyncedOptions
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT
createSyncedOptions = () => { return new BrowserStorage(browser.storage.sync, DEFAULT_OPTIONS); }
@param {StorageArea} storage The storage area to which this section will write. @param {Object} defaultValues The default options. @constructor
createSyncedOptions
javascript
infokiller/web-search-navigator
src/options.js
https://github.com/infokiller/web-search-navigator/blob/master/src/options.js
MIT