Dateiverwaltung für die WebBox
ulrich
2017-02-16 a4d3b5898ebecf3e413ce45feb6a4e1cfdba9ddc
commit | author | age
a4d3b5 1 var cm;
c7c502 2
U 3 function fm_init() {
a4d3b5 4   $('.codeeditor-space').hide();
U 5   $('.code-editor-container').hide();
6   $('#newTextFile').on('click', fm_menu_neue_textdatei);
7   $('#closeFile').on('click', fm_menu_datei_schliessen);
8 }
9
10 function fm_menu_neue_textdatei() {
11   $('#dateiansicht').hide();
12   $('.codeeditor-space').show();
13   $('.code-editor-container').show();
14   fm_code_edit('Test');
15 }
16
17 function fm_menu_datei_schliessen() {
18   $('.codeeditor-space').hide();
19   $('.code-editor-container').hide();
20   cm.toTextArea();
21   $('#dateiansicht').show();  
22 }
23
24 /* ---- codemirror editor handling -------- */
25
26 function fm_code_edit(content) {
27   var windowHeight = $(window).height();
28
29   //$("editspace").empty();
30   //self.cm.toTextArea();
31
32   cm = CodeMirror.fromTextArea(document.getElementById("editspace"), {
33     lineNumbers: true,
34     mode: "xml",
35     viewportMargin : Infinity,
36     extraKeys: {
37             "F9": function(cm) {
38               cm.setOption("fullScreen", !cm.getOption("fullScreen"));
39             },
40             "Esc": function(cm) {
41               if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
42           }
43     }
44   });
c7c502 45   
a4d3b5 46   // cm.setSize("100%", windowHeight - 100); // w, h
U 47   cm.setValue(content);
48   
49 };
50
51
52
53 /* -------- helper functions ----------- */
54
55 function fm_get(u, scallback) {
56   $.ajax({
57     url: u,
58     type: "GET",
59     dataType: "json",
60     success: scallback,
61     error: function (xhr, status, errorThrown) {
62       alert("Error: " + errorThrown + " Status: " + status + " URL: " + u);
63     },
64     complete: function (xhr, status) {
65       //console.log( "The request is complete!" );
66     }
67
68   });
69 };
70
71 function fm_post(u, d, scallback) {
72   $.ajax({
73     url: u,
74     data: d,
75     type: "POST",
76     dataType: "json",
77     success: scallback,
78     error: function (xhr, status, errorThrown) {
79       $('#fehler').html("Error: " + errorThrown + " Status: " + status);
80     },
81     complete: function (xhr, status) {
82       //alert( "The request is complete!" );
83     }
84   });
85 };
86