MCPcopy Index your code
hub / github.com/nwutils/nw-sample-apps / handleDocumentChange

Function handleDocumentChange

mini-code-edit/editor.js:18–40  ·  view source on GitHub ↗
(title)

Source from the content-addressed store, hash-verified

16}
17
18function handleDocumentChange(title) {
19 var mode = "javascript";
20 var modeName = "JavaScript";
21 if (title) {
22 title = title.match(/[^/]+$/)[0];
23 document.getElementById("title").innerHTML = title;
24 document.title = title;
25 if (title.match(/.json$/)) {
26 mode = {name: "javascript", json: true};
27 modeName = "JavaScript (JSON)";
28 } else if (title.match(/.html$/)) {
29 mode = "htmlmixed";
30 modeName = "HTML";
31 } else if (title.match(/.css$/)) {
32 mode = "css";
33 modeName = "CSS";
34 }
35 } else {
36 document.getElementById("title").innerHTML = "[no document loaded]";
37 }
38 editor.setOption("mode", mode);
39 document.getElementById("mode").innerHTML = modeName;
40}
41
42function newFile() {
43 fileEntry = null;

Callers 3

newFileFunction · 0.85
readFileIntoEditorFunction · 0.85
writeEditorToFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected