| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | <html>    <head>        <title>Text Reader</title>        <script src="../../script/jquery.min.js"></script>        <script src="../../script/ao_module.js"></script>        <link rel="stylesheet" href="script/SimpleMDE/simplemde.min.css">        <script src="script/SimpleMDE/simplemde.min.js"></script>        <style>            html, body{                background-color:white;                height: calc(100% - 80px);            }            #maintext{                height:100% !important;            }        </style>    </head>    <body>         <textarea id="maintext"></textarea>        <script>            var simplemde;          //SimpleMDE editor object            var filepath = "";      //Current editing filepath            var files = ao_module_loadInputFiles();                        $(window).on("keydown",function(event) {                if (event.which == 83 && event.ctrlKey){                    event.preventDefault();                    saveText();                }            });            if (files !== null && files.length > 0){                //Set the window name                ao_module_setWindowTitle("Notebook - " + files[0].filename);                //Check if there are more than 1 text files to be opened. If yes, open new windows.                if (files.length > 1){                    for (var i = 1; i < files.length; i++){                        var thisFilelist = [{                            filename: files[i].filename,                            filepath: files[i].filepath                        }];                        thisFilelist = encodeURIComponent(JSON.stringify(thisFilelist));                        ao_module_newfw({                            url: "SystemAO/utilities/notebook.html#" + thisFilelist,                            width: 1080,                            height: 580,                            appicon: "SystemAO/utilities/img/notebook.png",                            title: "Notebook",                        });                    }                }                               filepath = files[0].filepath;                //Load the file into the textarea                $.get("../../media?file=" + files[0].filepath,function(data){                    $("#maintext").text(data);                    //Load Markdown Editor                    simplemde = new SimpleMDE({                        autofocus: true,                        element: document.getElementById("maintext"),                        forceSync: true,                        insertTexts: {                            horizontalRule: ["", "\n\n-----\n\n"],                            image: [""],                            link: ["[", "](http://)"],                            table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text     | Text      | Text     |\n\n"],                        },                        placeholder: "(Empty file)",                        //promptURLs: true,                        renderingConfig: {                            singleLineBreaks: true,                            codeSyntaxHighlighting: true,                        },                        toolbar: ["bold","italic","heading","|","code","quote","unordered-list","ordered-list","|","link","image","table","|","preview","side-by-side","fullscreen","|",                        {                            name: "savebtn",                            action: function(){                                saveText();                            },                            className: "fa fa-floppy-o",                            title: "Save",                        },"guide","|"],                        spellChecker: false,                        status: ["autosave", "lines", "words", "cursor"], // Optional usage                    });                });            }else{                simplemde = new SimpleMDE({ element: document.getElementById("maintext") });            }                      function saveText(){                var newcontent = simplemde.value();                $.ajax({                    url: "../../system/utils/notebook/save",                    data: {filepath: filepath, content: newcontent},                    success: function(data){                        console.log(data);                        if (data.error !== undefined){                            alert(data.error);                        }                    }                });            }       </script>    </body></html>
 |