Javascript (AJAX) Component of sage Notebook

Javascript (AJAX) Component of sage Notebook

AUTHORS:

  • William Stein
  • Tom Boothby
  • Alex Clemesha

This file contains some minimal code to generate the Javascript code which is inserted to the head of the notebook web page. All of the interesting Javascript code is contained under SAGE_ROOT/devel/sage/sage/server/notebook/templates/notebook_lib.js.

class sage.server.notebook.js.JSKeyCode(key, alt, ctrl, shift)
__init__(key, alt, ctrl, shift)
js_test()
class sage.server.notebook.js.JSKeyHandler

This class is used to make javascript functions to check for specific keyevents.

__init__()
add(name, key='', alt=False, ctrl=False, shift=False)
Similar to code{set_key(...)}, but this instead checks if there is an existing keycode by the specified name, and associates the specified key combination to that name in addition. This way, if different browsers don’t catch one keycode, multiple keycodes can be assigned to the same test.
all_tests()
Builds all tests currently in the handler. Returns a string of javascript code which defines all functions.
set(name, key='', alt=False, ctrl=False, shift=False)
Add a named keycode to the handler. When built by code{all_tests()}, it can be called in javascript by code{key_<key_name>(event_object)}. The function returns true if the keycode numbered by the code{key} parameter was pressed with the appropriate modifier keys, false otherwise.
sage.server.notebook.js.javascript()

Return javascript library for the Sage Notebook. This is done by reading the template notebook_lib.js where all of the javascript code is contained and replacing a few of the values specific to the running session.

Before the code is returned (as a string), it is run through a JavascriptCompressor to minimize the amount of data needed to be sent to the browser.

Note

This the output of this function is cached so that it only needs to be generated once.

EXAMPLES:

sage: from sage.server.notebook.js import javascript
sage: s = javascript()
sage: s[:30]
'/* JavaScriptCompressor 0.1 [w'

Previous topic

The Sage Notebook Twisted Web Server

Next topic

Customization of the Notebook Keybindings

This Page