Yokome Firefox WebExtension (JavaScript)

background.initializePageAction(tab)

Initialize/reset page action to activate Yokome.

Arguments
  • tab – The tab on which to initialize Yokome.

background.toggleYokome(tab)

Activate or deactivate Yokome, depending on the current state.

Arguments
  • tab – The tab on which to toggle Yokome.

content..anyContains(rectangles, point)

Determine whether any rectangle in rectangles contains point.

Arguments
  • rectangles – A sequence of rectangles, each expressed by its four attributes left, right, top and bottom.

  • point – A pair of two values, the first in horizontal direction and the second in vertical direction.

Returns

true if any rectangle contains the point, false otherwise.

content..contains(rectangle, point)

Determine whether rectangle contains point.

Arguments
  • rectangle – A rectangle, expressed by its four attributes left, right, top and bottom.

  • point – A pair of two values, the first in horizontal direction and the second in vertical direction.

Returns

true if the rectangle contains the point, false otherwise.

content..createArrowNode(parent, top, left)

Create an arrow node on the info box.

Arrow nodes allow users to move the info box into a corner of their choice.

Arguments
  • parent – The parent node for which to create an arrow node as a child.

  • top – Whether the arrow points to the top.

  • left – Whether the arrow points to the left.

content..createInfoBox()

Create the info box (i.e. the main Yokome interface); place it on the page.

content..disambiguateTargetToken(event)

Initiate disambiguation on a token.

Find the token (a text node) under the mouse pointer and start a timeout for disambiguation.

Arguments
  • event – The event that determines which token to disambiguate.

content..getCursorPosition(event)

Get the mouse position described by the event.

Arguments
  • event – A mouse event.

Returns

A pair of two values, the first in horizontal direction and the second in vertical direction, describing the x and y coordinates of the mouse position during the event.

content..getHighestZIndex()

Determine the highest z-dimension index of any element on the page.

Returns

The highest z-index.

content..getIndex(node)

Get the index of node (the number of siblings that precede it).

Arguments
  • node – The node to determine the index for.

Returns

The number of siblings that precede node, or -1 if node === null.

content..initialize(nodeFilter)

Initialize the page for tokenization and disambiguation tasks.

Arm every relevant element with onmouseenter events.

Arguments
  • nodeFilter – A node filter to detect relevant elements.

content..initiateTabSwitching(event)

Display the content of a tab that is a parent element of the target of event or that target itself.

Arguments
  • event – An onclick event that targets a tab of the info box or a child thereof.

content..maybeRefreshTabs(node)

Disambiguate the text in node based on its surrounding text if the disambiguation timeout was last started on this node.

Request disambiguation at the server.

Intended to be called by a timeout event.

Arguments
  • event – The original event that lauched the timeout.

  • node – A text node, inserted by a tokenization process.

content..maybeTokenize(event, node)

Tokenize the text in node if the tokenization timeout was last started on this node.

Request tokenization at the server.

Intended to be called by a timeout event.

Arguments
  • event – The original event that lauched the timeout.

  • node – A text node. A child node of event.target.

content..movebox(event)

Move the box into the corner indicated by the arrow node that is the target of event.

Arguments
  • event – An onlick event.

content..post(url, data, node, callback, args)

Make an HTTP POST request.

Arguments
  • url – The url to make the request to.

  • data – The data to send.

  • node – A node that is the first argument to callback.

  • callback – A function to be called after a successful response. callback is called with node, the JSON-parsed response text, and args.

  • args – Additional arguments to be passed to callback.

content..refreshTabs(node, lexemes, args)

Update the info box to reflect information on the disambiguate node node.

Arguments
  • node – A text node, inserted by a tokenization process.

  • lexemes – A response after word-sense disambiguation, a parsed JSON document.

  • args – Not used. For compatibility with post() only.

content..removeInfoBox()

Remove the info box (i.e. the main Yokome interface) from the page.

content..resetDisambiguationTimeoutStart()

Reset the timeout start time for disambiguation.

There is one such time for each page. This helps detecting which element triggered a disambiguation request last.

content..resetTokenizerTimeoutStart()

Reset the timeout start time for tokenization.

There is one such time for each page. This helps detecting which element triggered a tokenization request last.

content..switchToTab(node)

Display the content of the tab that is associated with node.

Arguments
  • node – A tab of the info box.

content..tokenize(node, response, args)

Replace the text of node with the text received from the tokenizer.

Initiate disambiguation on the part of the text that is in the area of the mouse event that launched the tokenization request.

Arguments
  • node – The text node whose text to replace.

  • response – The response from the tokenizer, parsed JSON document.

  • args – A list of the form [event, head, tail], where event is the original event that launched the tokenization action, and head and tail are the leading and trailing whitespaces from the original text, respectively.