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); |
e5ff42
|
7 |
$('#saveFile').on('click', fm_menu_datei_speichern); |
a4d3b5
|
8 |
$('#closeFile').on('click', fm_menu_datei_schliessen); |
915927
|
9 |
$('#myModal').on('hidden.bs.modal', function (e) { |
U |
10 |
$('#modal_ok').attr('onclick','').unbind('click'); |
b7475d
|
11 |
}); |
U |
12 |
$('#logout').click(fm_logout); |
e5ff42
|
13 |
fm_get_login(); |
a4d3b5
|
14 |
} |
U |
15 |
|
|
16 |
function fm_menu_neue_textdatei() { |
|
17 |
$('#dateiansicht').hide(); |
|
18 |
$('.codeeditor-space').show(); |
|
19 |
$('.code-editor-container').show(); |
|
20 |
fm_code_edit('Test'); |
|
21 |
} |
|
22 |
|
|
23 |
function fm_menu_datei_schliessen() { |
|
24 |
$('.codeeditor-space').hide(); |
|
25 |
$('.code-editor-container').hide(); |
|
26 |
cm.toTextArea(); |
|
27 |
$('#dateiansicht').show(); |
e5ff42
|
28 |
} |
U |
29 |
|
b7475d
|
30 |
/* ----- API Calls ------------- */ |
U |
31 |
|
e5ff42
|
32 |
function fm_get_login() { |
U |
33 |
var m = '?c=de.uhilger.um.pub.SessionManager&m=getSessionUser'; |
|
34 |
var u = '../../um/pub' + m; |
b7475d
|
35 |
fm_get(u, "json", function(resp) { |
e5ff42
|
36 |
$('#userMenu').text(resp.UserData.firstName); |
U |
37 |
}); |
|
38 |
} |
|
39 |
|
|
40 |
function fm_menu_datei_speichern() { |
|
41 |
|
915927
|
42 |
$('#modal_ok').click(function() { |
U |
43 |
// hier speichern |
|
44 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=saveTextFile'; |
|
45 |
var u = '../svc' + m; |
|
46 |
fm_post(u, {p1: '', p2: $('#dateiname').val(), p3: cm.getValue()}, function(resp) { |
|
47 |
|
|
48 |
}); |
|
49 |
}); |
|
50 |
$('#saveModal').modal({ |
|
51 |
keyboard: false, |
|
52 |
show: true |
|
53 |
}); |
|
54 |
|
|
55 |
|
|
56 |
// FileRef saveTextFile(String relPath, String fileName, String contents) |
e5ff42
|
57 |
|
U |
58 |
|
|
59 |
/* |
|
60 |
var t = new Template(-2, $('#filename').val(), self.cm.getValue(), 3); |
|
61 |
var u = '../api/tr/?c=de.uhilger.webbox.api.ContentApi&m=newTemplate'; |
|
62 |
self.post(u, {p: self.serialise(t)}, function (resp) { |
|
63 |
self.isnew = false; |
|
64 |
self.editid = resp.Template.id; |
|
65 |
$('#contlist').append(self.buildContListItem(3, resp.Template.name, resp.Template.id)); |
|
66 |
$('#templateeditor').addClass('hidden'); |
|
67 |
}); |
|
68 |
*/ |
a4d3b5
|
69 |
} |
U |
70 |
|
b7475d
|
71 |
function fm_logout() { |
U |
72 |
var m = '?c=de.uhilger.filecms.pub.SessionManager&m=expireSession'; |
|
73 |
var u = '../pub' + m; |
|
74 |
|
|
75 |
fm_get(u, "text", function(resp) { |
|
76 |
$('#userMenu').text('nicht angemeldet'); |
|
77 |
window.location.href = '../logout.html'; |
|
78 |
}); |
|
79 |
} |
|
80 |
|
|
81 |
|
a4d3b5
|
82 |
/* ---- codemirror editor handling -------- */ |
U |
83 |
|
|
84 |
function fm_code_edit(content) { |
915927
|
85 |
//var windowHeight = $(window).height(); |
a4d3b5
|
86 |
//$("editspace").empty(); |
U |
87 |
//self.cm.toTextArea(); |
|
88 |
|
|
89 |
cm = CodeMirror.fromTextArea(document.getElementById("editspace"), { |
|
90 |
lineNumbers: true, |
|
91 |
mode: "xml", |
|
92 |
viewportMargin : Infinity, |
|
93 |
extraKeys: { |
915927
|
94 |
"F9": function(cm) { |
U |
95 |
cm.setOption("fullScreen", !cm.getOption("fullScreen")); |
|
96 |
}, |
|
97 |
"Esc": function(cm) { |
|
98 |
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); |
|
99 |
} |
a4d3b5
|
100 |
} |
U |
101 |
}); |
|
102 |
cm.setValue(content); |
915927
|
103 |
} |
a4d3b5
|
104 |
|
U |
105 |
|
|
106 |
|
|
107 |
/* -------- helper functions ----------- */ |
|
108 |
|
b7475d
|
109 |
function fm_get(u, dtype, scallback) { |
a4d3b5
|
110 |
$.ajax({ |
U |
111 |
url: u, |
|
112 |
type: "GET", |
b7475d
|
113 |
dataType: dtype, |
a4d3b5
|
114 |
success: scallback, |
U |
115 |
error: function (xhr, status, errorThrown) { |
|
116 |
alert("Error: " + errorThrown + " Status: " + status + " URL: " + u); |
|
117 |
}, |
|
118 |
complete: function (xhr, status) { |
|
119 |
//console.log( "The request is complete!" ); |
|
120 |
} |
|
121 |
|
|
122 |
}); |
915927
|
123 |
} |
a4d3b5
|
124 |
|
U |
125 |
function fm_post(u, d, scallback) { |
|
126 |
$.ajax({ |
|
127 |
url: u, |
|
128 |
data: d, |
|
129 |
type: "POST", |
|
130 |
dataType: "json", |
|
131 |
success: scallback, |
|
132 |
error: function (xhr, status, errorThrown) { |
|
133 |
$('#fehler').html("Error: " + errorThrown + " Status: " + status); |
|
134 |
}, |
|
135 |
complete: function (xhr, status) { |
|
136 |
//alert( "The request is complete!" ); |
|
137 |
} |
|
138 |
}); |
915927
|
139 |
} |
a4d3b5
|
140 |
|
e5ff42
|
141 |
function fm_serialise(obj) { |
U |
142 |
return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; |
915927
|
143 |
} |
e5ff42
|
144 |
|