-
Notifications
You must be signed in to change notification settings - Fork 0
/
fEdit.html
executable file
·348 lines (281 loc) · 16 KB
/
fEdit.html
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="max-age=0">
<title>FEdit</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.getUrlParam.js"></script>
<script type="text/javascript" src="js/jquery.blockUI.js"></script>
<!-- EditArea Example -->
<script src="edit_area/edit_area_full.js" type="text/javascript"></script>
<!-- Configuration -->
<script src="js/fEdit_config.js" type="text/javascript"></script>
<script type="text/javascript">
/*
* Init Script
*/
var filename = $(document).getUrlParam("filename");
var deffilename = filepath.substring(filepath.lastIndexOf('/') + 1);
filepath = filepath.substr(0,filepath.length-deffilename.length);
var initarea = false;
var header;
var p_noscript="true";
var emen = new Array;
var act = "";
/*
* Map for Converting UTF-8 to ISO + HTML-Entities
*/
var UTFChar = new Array("Â","â","´","Æ","æ","À","à","ℵ","Α","α","∧","∠","'","Å","å","≈","Ã","ã","Ä","ä","„","Β","β","¦","•","∩","Ç","ç","¸","¢","Χ","χ","ˆ","♣","≅","©","↵","∪","¤","‡","†","⇓","↓","°","Δ","δ","♦","÷","É","é","Ê","ê","È","è","∅"," "," ","Ε","ε","≡","Η","η","Ð","ð","Ë","ë","€","∃","ƒ","∀","½","¼","¾","⁄","Γ","γ","≥","⇔","↔","♥","…","Í","í","Î","î","¡","Ì","ì","ℑ","∞","∫","Ι","ι","¿","∈","Ï","ï","Κ","κ","Λ","λ","〈","«","⇐","←","⌈","“","≤","⌊","∗","◊","","‹","‘","¯","—","µ","·","−","Μ","μ","∇"," ","–","≠","∋","¬","∉","⊄","Ñ","ñ","Ν","ν","Ó","ó","Ô","ô","Œ","œ","Ò","ò","‾","Ω","ω","Ο","ο","⊕","∨","ª","º","Ø","ø","Õ","õ","⊗","Ö","ö","¶","∂","‰","⊥","Φ","φ","Π","π","ϖ","±","£","″","′","∏","∝","Ψ","ψ","√","〉","»","⇒","→","⌉","”","ℜ","®","⌋","Ρ","ρ","","›","’","‚","Š","š","⋅","§","","Σ","σ","ς","∼","♠","⊂","⊆","∑","⊃","¹","²","³","⊇","ß","Τ","τ","∴","Θ","θ","ϑ"," ","Þ","þ","˜","×","™","Ú","ú","⇑","↑","Û","û","Ù","ù","¨","ϒ","Υ","υ","Ü","ü","℘","Ξ","ξ","Ý","ý","¥","Ÿ","ÿ","Ζ","ζ");
var HTMLent = new Array("Â","â","´","Æ","æ","À","à","ℵ","Α","α","∧","∠","'","Å","å","≈","Ã","ã","Ä","ä","„","Β","β","¦","•","∩","Ç","ç","¸","¢","Χ","χ","ˆ","♣","≅","©","↵","∪","¤","‡","†","⇓","↓","°","Δ","δ","♦","÷","É","é","Ê","ê","È","è","∅"," "," ","Ε","ε","≡","Η","η","Ð","ð","Ë","ë","€","∃","ƒ","∀","½","¼","¾","⁄","Γ","γ","≥","⇔","↔","♥","…","Í","í","Î","î","¡","Ì","ì","ℑ","∞","∫","Ι","ι","¿","∈","Ï","ï","Κ","κ","Λ","λ","⟨","«","⇐","←","⌈","“","≤","⌊","∗","◊","‎","‹","‘","¯","—","µ","·","−","Μ","μ","∇"," ","–","≠","∋","¬","∉","⊄","Ñ","ñ","Ν","ν","Ó","ó","Ô","ô","Œ","œ","Ò","ò","‾","Ω","ω","Ο","ο","⊕","∨","ª","º","Ø","ø","Õ","õ","⊗","Ö","ö","¶","∂","‰","⊥","Φ","φ","Π","π","ϖ","±","£","″","′","∏","∝","Ψ","ψ","√","⟩","»","⇒","→","⌉","”","ℜ","®","⌋","Ρ","ρ","‏","›","’","‚","Š","š","⋅","§","­","Σ","σ","ς","∼","♠","⊂","⊆","∑","⊃","¹","²","³","⊇","ß","Τ","τ","∴","Θ","θ","ϑ"," ","Þ","þ","˜","×","™","Ú","ú","⇑","↑","Û","û","Ù","ù","¨","ϒ","Υ","υ","Ü","ü","℘","Ξ","ξ","Ý","ý","¥","Ÿ","ÿ","Ζ","ζ");
var UnicDec = new Array("Â","â","´","Æ","æ","À","à","ℵ","Α","α","∧","∠","'","Å","å","≈","Ã","ã","Ä","ä","„","Β","β","¦","•","∩","Ç","ç","¸","¢","Χ","χ","ˆ","♣","≅","©","↵","∪","¤","‡","†","⇓","↓","°","Δ","δ","♦","÷","É","é","Ê","ê","È","è","∅"," "," ","Ε","ε","≡","Η","η","Ð","ð","Ë","ë","€","∃","ƒ","∀","½","¼","¾","⁄","Γ","γ","≥","⇔","↔","♥","…","Í","í","Î","î","¡","Ì","ì","ℑ","∞","∫","Ι","ι","¿","∈","Ï","ï","Κ","κ","Λ","λ","〈","«","⇐","←","⌈","“","≤","⌊","∗","◊","‎","‹","‘","¯","—","µ","·","−","Μ","μ","∇"," ","–","≠","∋","¬","∉","⊄","Ñ","ñ","Ν","ν","Ó","ó","Ô","ô","Œ","œ","Ò","ò","‾","Ω","ω","Ο","ο","⊕","∨","ª","º","Ø","ø","Õ","õ","⊗","Ö","ö","¶","∂","‰","⊥","Φ","φ","Π","π","ϖ","±","£","″","′","∏","∝","Ψ","ψ","√","〉","»","⇒","→","⌉","”","ℜ","®","⌋","Ρ","ρ","‏","›","’","‚","Š","š","⋅","§","­","Σ","σ","ς","∼","♠","⊂","⊆","∑","⊃","¹","²","³","⊇","ß","Τ","τ","∴","Θ","θ","ϑ"," ","Þ","þ","˜","×","™","Ú","ú","⇑","↑","Û","û","Ù","ù","¨","ϒ","Υ","υ","Ü","ü","℘","Ξ","ξ","Ý","ý","¥","Ÿ","ÿ","Ζ","ζ");
var UnicHex = new Array("Â","â","´","Æ","æ","À","à","ℵ","Α","α","∧","∠","'","Å","å","≈","Ã","ã","Ä","ä","„","Β","β","¦","•","∩","Ç","ç","¸","¢","Χ","χ","ˆ","♣","≅","©","↵","∪","¤","‡","†","⇓","↓","°","Δ","δ","♦","÷","É","é","Ê","ê","È","è","∅"," "," ","Ε","ε","≡","Η","η","Ð","ð","Ë","ë","€","∃","ƒ","∀","½","¼","¾","⁄","Γ","γ","≥","⇔","↔","♥","…","Í","í","Î","î","¡","Ì","ì","ℑ","∞","∫","Ι","ι","¿","∈","Ï","ï","Κ","κ","Λ","λ","〈","«","⇐","←","⌈","“","≤","⌊","∗","◊","‎","‹","‘","¯","—","µ","·","−","Μ","μ","∇"," ","–","≠","∋","¬","∉","⊄","Ñ","ñ","Ν","ν","Ó","ó","Ô","ô","Œ","œ","Ò","ò","‾","Ω","ω","Ο","ο","⊕","∨","ª","º","Ø","ø","Õ","õ","⊗","Ö","ö","¶","∂","‰","⊥","Φ","φ","Π","π","ϖ","±","£","″","′","∏","∝","Ψ","ψ","√","〉","»","⇒","→","⌉","”","ℜ","®","⌋","Ρ","ρ","‏","›","’","‚","Š","š","⋅","§","­","Σ","σ","ς","∼","♠","⊂","⊆","∑","⊃","¹","²","³","⊇","ß","Τ","τ","∴","Θ","θ","ϑ","ߙ","Þ","þ","˜","×","™","Ú","ú","⇑","↑","Û","û","Ù","ù","¨","ϒ","Υ","υ","Ü","ü","℘","Ξ","ξ","Ý","ý","¥","Ÿ","ÿ","Ζ","ζ");
/* ISO-Supported
* var UTFChar[] = "\"","<",">","&"
* var HTMLent[] = ""","<",">","&"
* var UnicDec[] = ""","<",">","&"
* var UnicHex[] = ""","<",">","&"
*
* not ISO-Supported
* ‍ Engl.: Zero Width Joiner ‍ ‍ General Punctuation
* ‌ Engl.: Zero Width Non-Joiner ‌ ‌ General Punctuation
*/
/*
* Map for Converting UTF-8 to ISO + HTML-Entities
*/
var emptyTags = new Array("meta","base","basefont","param","link","img","br","hr","area","input");
function utf_convert (text,dir) {
for(var i = 0; i < UTFChar.length; i++) {
sString = "/" + UTFChar[i] + "/g";
sString = eval(sString);
text = text.replace(sString,HTMLent[i]);
}
return text;
}
function html2xhtml (text) {
for(var i = 0; i < emptyTags.length; i++) {
sString = "/<(" + emptyTags[i] + " )([^>]*)([^\/])>/g";
sString = eval(sString);
text = text.replace(sString,'<$1$2$3 />');
}
return text;
}
function cancelhtml() {
document.location.href=base;
return false;
}
function savehtml() {
var rfilename = '';
if(act == "#html") {
// erzwinge wechsel zu frameview
$("#tabs a[href='#wysiwyg']").click();
}
$.blockUI('saving ...');
var data = $('#frameview').contents().find("html").html();
/* proof
*
* <a href="mailto:$%7BMailAdrFuerZusaetzlicheDokumenteMail%7D">
* remove br
* data = data.replace(/\<br\>/ig,'');
* trim whitespace
* data = data.replace(/^\s+|\s+$/g, "");
* Remove trailing blanks
* data = data.replace(/\\s+\n/g, "\n");
* escape
* data = encodeURIComponent(data);
*/
// delete everything till <body...
data = data.substring(data.indexOf("<body"));
// remove inv.
data = data.replace(/\<span class=\"inv\"\>(\$\{.*\})\<\/span\>/ig,'$1');
// convert {}
data = data.replace(/\%7B/ig,"{");
data = data.replace(/\%7D/ig,"}");
// Remove duplicate end-of-lines
data = data.replace(/\n\n\n/g, "\n");
// remove generated html-breaks in tables
data = data.replace(/\<br\><\/td\>/ig,'</td>');
// convert html to xhtml
data = html2xhtml(data);
// add doctype and html
data = header + data + "\n<\/html>";
// convert utf-8 chars to iso-chars or html-entities
data = utf_convert(data,"htmlentities");
rfilename = filename.replace(/#/, "");
rfilename = filepath+rfilename;
$.post(savecgi, submitdata = { fdata:data, fname:rfilename }, function(str) {
if(str) {
$.unblockUI();
alert('Fehler:\n'+str);
} else {
document.location.href=base;
}
}, "text");
return false;
}
$(document).ready(function() {
$('#tabs > a').each(function() {
var $this = $(this);
var hash = $this.attr("href");
if(act=="") {
act=hash;
$this.addClass('disable');
} else {
$(hash).hide();
$this.removeClass('disable');
}
$this.bind("click",function(e){
var $this = $(this);
var hash = $this.attr("href");
if(act!=hash) {
$(act).hide();
$("#tabs a[href='"+act+"']").removeClass('disable');
act=hash;
$(act).show();
$("#tabs a[href='"+act+"']").addClass('disable');
switch (hash) {
case "#wysiwyg":
// WYSIWYG
if (initarea == true) {
data = editAreaLoader.getValue('textarea_1');
$('#frameview').contents().find("body").html(data);
}
break;
case "#html":
// Edit Source
if(initarea == false) {
// init editarea eample
editAreaLoader.init({
id : "textarea_1" // textarea id
,syntax: "html" // syntax to be uses for highgliting
,start_highlight: true // to display with highlight mode on start-up
,language: "de"
,allow_resize: "no"
,allow_toggle: false
,font_size: "8"
,font_family: "Monaco,monospace"
});
initarea = true;
}
// Load Content into editor
var data = $('#frameview').contents().find("body").html();
editAreaLoader.setValue('textarea_1', data);
break;
}
}
return false;
});
});
if(filename){
$('#dna').prepend(filepath+filename);
var data;
$.blockUI('loading ...');
/* Seite in iframe laden
* Parameter:
* p_edit [true] Ausblenden von Platzhaltern
* idz [Zufallszahl] zur Vermeidung Caching
*/
frames['frameview'].location.href=filepath+filename+'?p_edit=true&idz='+parseInt( Math.random() * ( 1000000 ));
// wait till document loaded
$('#frameview').load(function() {
document.getElementById("frameview").contentDocument.designMode="on";
$.ajax({
type: "GET",
url: filepath+filename,
cache: false,
dataType: "html",
async: false,
success: function(data){
header = data.substring(0, data.indexOf("<body"));
}
});
$.unblockUI();
});
}
});
</script>
<style type="text/css">
html, body {
height:100%;
margin: 0;
padding: 0;
}
body {
background-color: #666;
}
table {
width:100%;
height:100%;
border:none;
border-collapse:collapse;
}
table td {
padding:0;
white-space:nowrap;
}
#content,#content div {
height:100%;
}
#footer {
height: 40px;
width:100%;
overflow:hidden;
background-color:#ece9d8;
border-top: 1px solid #888;
border-bottom: 1px solid #999;
z-index:998;
}
iframe, textarea {
width:100%;
height:100%;
border: none;
margin: 0px;
padding: 0px;
background-color:#fff;
}
td {
font-family: arial, helvetica, sans-serif;
font-size: 14px;
line-height: 14px;
color: #999;
}
a, span {
margin-left:16px;
margin-right:16px;
text-decoration: none;
color: #999;
}
a:hover {
color: #333;
}
.disable {
color: #333;
}
</style>
</head>
<body>
<table>
<tr>
<td id="content">
<div id="wysiwyg"><iframe id="frameview" name="frameview" src="about:blank" scrolling="auto" frameborder="no">Sorry, your browser does not support IFrames</iframe></div>
<div id="html"><textarea id="textarea_1" name="content"></textarea></div>
</td>
</tr>
<tr>
<td id="footer">
<table>
<tr>
<td id="tabs">
<a href="#wysiwyg">Ansicht bearbeiten</a> | <a href="#html">HTML bearbeiten</a>
</td>
<td align="right" nowrap>
<span class="disable" id="dna" style="font-size:10px;"></span><a href="#" onClick="cancelhtml();">Cancel</a> | <a href="#" onClick="savehtml();">Save</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>