๐Ÿ“ฆ pavelfeldman / cte_old

๐Ÿ“„ index.html ยท 44 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44<body>
</body>
<script>
WebInspector = {}
</script>
<script src="utilities.js"></script>
<script src="KeyboardShortcut.js"></script>
<script src="TextEditorModel.js"></script>
<script src="TextEditor.js"></script>
<script src="TextEditorHighlighter.js"></script>
<script src="SourceCSSTokenizer.js"></script>
<script src="SourceJavaScriptTokenizer.js"></script>
<script src="SourceHTMLTokenizer.js"></script>
<link rel="stylesheet" type="text/css" href="textEditor.css"></link>
<script>

function platform()
{
    var match = navigator.userAgent.match(/Windows NT/);
    if (match)
        return "windows";
    match = navigator.userAgent.match(/Mac OS X/);
    if (match)
        return "mac";
    return "linux";
}

function init()
{
    var textModel = new WebInspector.TextEditorModel();
    var editor = new WebInspector.TextEditor(textModel, platform());
    editor.mimeType = "text/javascript";
    editor.readOnly = false;
    document.body.appendChild(editor.element);
    fetch("TextEditor.js").then(result => result.text()).then(text => textModel.setText(null, text));
    window.editor = editor;
}

init();

window.onresize = () => window.editor.updateCanvasSize();

</script>