├── LICENSE ├── README.md ├── js+help-screenshot.png ├── js+help.html ├── mfibo.html └── phi.png /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### javascript-notebook 2 | A very simple self-contained javascript notebook 3 | 4 | This is a very simple Javascript notebook in one completely self-contained HTML file. It was inspired by the concept of Jupyter notebooks. 5 | 6 | You can enter Javascript code and execute it in the browser, completely locally and possibly offline. The performance can be pretty good. 7 | 8 | You can put in HTML documentation and also use HTML to provide UI for simple tools. 9 | 10 | All you need is the js+help.html file, which contains basic documentation. You can clear out the notebook and save off various javascript experiments in different files. Being able to save code and outputs is a key useful feature. 11 | 12 | This was developed using the Chrome browser. Limited tests have been done with Firefox, and also on various OSs (Linux/Windows/Mac). The main compatibility issue is the handling of the downloading of files and how that varies in different contexts. 13 | 14 | It is easy to extract a CSS and a JS file that could be stored separately to make for very small notebook files. 15 | 16 | ### A basic screen shot 17 | 18 | ![phi](/phi.png) 19 | 20 | ### The built-in documentation in js+help.html 21 | 22 | ![js+help](/js+help-screenshot.png) 23 | 24 | ### Trying it out 25 | 26 | Direct link: 27 | 28 | [js+help.html via github.io](https://timcwinkler.github.io/js+help.html) 29 | 30 | (You can save locally.) 31 | 32 | This link will show you the source HTML text: 33 | 34 | [js+help.html](https://raw.githubusercontent.com/timcwinkler/javascript-notebook/main/js%2Bhelp.html) 35 | 36 | (You can also use this link to download the file.) 37 | 38 | The mfibo.html file is an example with a bit more content. Computing Fibo(n) using the familiar closed-form formula, but using modular arithmetic. 39 | 40 | [mfib.html](https://raw.githubusercontent.com/timcwinkler/javascript-notebook/main/mfibo.html) 41 | 42 | (Once again, you can use this like to download the file.) 43 | -------------------------------------------------------------------------------- /js+help-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timcwinkler/javascript-notebook/d65c94414ca1c175a754b3acb1e89761251ddfa7/js+help-screenshot.png -------------------------------------------------------------------------------- /js+help.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | js+help 5 | 6 | 7 | 80 | 486 | 487 | 488 | 489 | js10gl 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 |
499 | 500 | 501 | 502 |
[0]: 

611 | Documentation for js.html
612 |
613 | This is a self-contained Javascript Notebook (inspired by Jupyter Notebooks). 614 |
615 |
616 | Appearance of an example notebook ... 617 |
618 |


619 | 620 | jsX    
[0]: 

        

621 | 622 |
623 |
624 |

625 |
626 | Description of elements 627 |
628 |

629 | Top elements 630 |
631 | jsX 632 | - name of the html file (with ".html" removed)
633 |
634 | buttons:
635 |
636 | add - add a new interaction unit (these consist of a javascript/html input and possibly a resultant output)
637 |
638 | RO>RW / RW>RO - make read-write(RW) / read-only(RO), this is a toggle; Helps clicking links in html text
639 |
640 | clear - clears out all content
641 |
642 | store - saves copy of content (within the page's data, not in a file)
643 |
644 | restore - restores saved copy of content
645 |
646 | save - Save to file (functions like downloading a file); 647 | For Chrome browser, want "Ask where to save each file before downloading" turned on (exact behavior varies with OS and browser) 648 |
649 |

650 |
651 | Interaction units 652 | - there may be many of these
653 |
654 | [n] - numbered id of unit
655 |
656 | input text box - place to enter javascript code or html input; Below this may be an output value in a box or unboxed html rendering;
657 |
658 | output appears below input and is boxed if it is the result of evaluation; only appears after "go" or "txt" is clicked; html output will be read-only in RO mode
659 |
660 | 661 | buttons:
662 |
663 |
664 | go - eval input and put result (string version of) in output box below the input box
665 |
666 | txt - show input text via html rendering below input box
667 |
668 | clr - clear the output box (switch to eval output); will create output box if it doesn't exist
669 |
670 | - / + - toggle visibility of input box and go/txt/clr buttons; with html rendering hides the html markup
671 |

672 |
673 | Bottom elements 674 |
675 |
676 | buttons:
677 |
678 | go last - eval last input and show result
679 |
680 | add - add another interaction unit
681 |
682 | go-add - Same as "go last" followed by "add"
683 |
684 | go all - go through all interaction units evaluating and showing the results; if first non-blank character of the input is "<", then input is considered html
685 |
686 | delete - delete the last interaction unit
687 |

688 |
689 | Special functions available in javascript code 690 |
691 |
692 | str(n) - nth output as string
693 |
694 | res(n) - nth output value (not stringified)
695 |
696 | expr(n) - nth input value as string
697 |
698 | last() - previous output value or string (not stringified)
699 |
700 | final() - very last output value (not stringified)
701 |
702 | put(str) - appends value of str to output area for current executing javascript code; like printing to output box
703 |

704 |
705 |
706 | A few additional notes:
707 | Outputs are produced by the default rules for converting values to strings ("toString").
708 | Evaluation is done with global context. Function definitions will be global.
709 | Browser save ("Save page as ...") loses changes and functionality. Make sure to use the Save button.
710 | HTML output/rendering only updated when the txt button is clicked.
711 | When RW, the html outputs can be edited (but the "source" will not be updated). Changes will be preserved by saving.
712 | (The CSS/JS content of this page can be moved to separate files to make very small working pages.)
713 | You can paste text data into an input box and refer to it elsewhere using expr().
714 |

715 |
716 |

717 |
718 |

[1]: 

You can use the clear button to eliminate the documentation and create an empty notebook.

719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 |

735 | 736 | 739 | 740 | 741 | -------------------------------------------------------------------------------- /mfibo.html: -------------------------------------------------------------------------------- 1 |  3 | 4 | js+help 5 | 6 | 7 | 80 | 486 | 487 | 488 | 489 | js+help 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 |
499 | 500 | 501 | 502 |
[0]: 

Computing Fibonacci numbers using the closed-form formula, but in modular arithmetic

[1]: 

[2]: 

In the following the Fibonacci numbers are correct up to Fibo(15)

[3]: 

[4]: 

The trick is that, modulo 929, sqrt(5) exists.

538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 |

554 | 555 | 558 | 559 | 560 | -------------------------------------------------------------------------------- /phi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timcwinkler/javascript-notebook/d65c94414ca1c175a754b3acb1e89761251ddfa7/phi.png --------------------------------------------------------------------------------