JavaScript (AJAX) Components of the Notebook
JavaScript (AJAX) Components of the 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
data/sage/js/notebook_lib.js.
-
class sagenb.notebook.js.JSKeyCode(key, alt, ctrl, shift)
-
js_test()
-
class sagenb.notebook.js.JSKeyHandler
This class is used to make javascript functions to check
for specific keyevents.
-
add(name, key='', alt=False, ctrl=False, shift=False)
- Similar to 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
all_tests(), it can be called in javascript by
key_<key_name>(event_object). The function returns
true if the keycode numbered by the key parameter was
pressed with the appropriate modifier keys, false otherwise.
-
sagenb.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 sagenb.notebook.js import javascript
sage: s = javascript()
sage: s[:30]
'/* JavaScriptCompressor 0.1 [w'