Create a Javascript display object given raw data. When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. If the data is a URL, the data will first be downloaded and then displayed.
(self, data=None, url=None, filename=None, lib=None, css=None)
| 734 | class Javascript(TextDisplayObject): |
| 735 | |
| 736 | def __init__(self, data=None, url=None, filename=None, lib=None, css=None): |
| 737 | """Create a Javascript display object given raw data. |
| 738 | |
| 739 | When this object is returned by an expression or passed to the |
| 740 | display function, it will result in the data being displayed |
| 741 | in the frontend. If the data is a URL, the data will first be |
| 742 | downloaded and then displayed. |
| 743 | |
| 744 | In the Notebook, the containing element will be available as `element`, |
| 745 | and jQuery will be available. Content appended to `element` will be |
| 746 | visible in the output area. |
| 747 | |
| 748 | Parameters |
| 749 | ---------- |
| 750 | data : unicode, str or bytes |
| 751 | The Javascript source code or a URL to download it from. |
| 752 | url : unicode |
| 753 | A URL to download the data from. |
| 754 | filename : unicode |
| 755 | Path to a local file to load the data from. |
| 756 | lib : list or str |
| 757 | A sequence of Javascript library URLs to load asynchronously before |
| 758 | running the source code. The full URLs of the libraries should |
| 759 | be given. A single Javascript library URL can also be given as a |
| 760 | string. |
| 761 | css : list or str |
| 762 | A sequence of css files to load before running the source code. |
| 763 | The full URLs of the css files should be given. A single css URL |
| 764 | can also be given as a string. |
| 765 | """ |
| 766 | if isinstance(lib, str): |
| 767 | lib = [lib] |
| 768 | elif lib is None: |
| 769 | lib = [] |
| 770 | if isinstance(css, str): |
| 771 | css = [css] |
| 772 | elif css is None: |
| 773 | css = [] |
| 774 | if not isinstance(lib, (list,tuple)): |
| 775 | raise TypeError('expected sequence, got: %r' % lib) |
| 776 | if not isinstance(css, (list,tuple)): |
| 777 | raise TypeError('expected sequence, got: %r' % css) |
| 778 | self.lib = lib |
| 779 | self.css = css |
| 780 | super(Javascript, self).__init__(data=data, url=url, filename=filename) |
| 781 | |
| 782 | def _repr_javascript_(self): |
| 783 | r = '' |