3
var savebutton = document.getElementById("save_button");
4
var filename = document.getElementById("save_filename").value;
5
data = editAreaLoader.getValue("editbox");
6
/* Do NOT refresh the page contents (causes problems for editarea and is
8
do_action("putfile", filename,
9
{"path":".", "data":data, "overwrite":"true"},
10
"multipart/form-data", true);
11
savebutton.setAttribute("value", "Saved");
12
// XXX Do not disable for now; there is a problem getting the callback
14
//savebutton.setAttribute("disabled", "disabled");
19
var savebutton = document.getElementById("save_button");
20
savebutton.setAttribute("value", "Save");
21
savebutton.removeAttribute("disabled");
24
/** Presents the "editor heading" (the part with the save box)
25
* inserting it into a given element at the front.
27
function present_editorhead(elem, path, handler_type)
29
var div = document.getElementById("actions2");
31
/* Set up minimal interface */
32
var p = dom_make_text_elem("p", "Save as: ");
33
var pathname = document.createElement("input");
34
pathname.setAttribute("type", "text");
35
pathname.setAttribute("size", "30");
36
pathname.setAttribute("id", "save_filename");
37
pathname.setAttribute("value", path);
38
p.appendChild(pathname);
39
var savebutton = document.createElement("input");
40
savebutton.setAttribute("id", "save_button");
41
savebutton.setAttribute("type", "button");
42
savebutton.setAttribute("value", "Saved");
43
// XXX Do not disable for now; there is a problem getting the callback
45
//savebutton.setAttribute("disabled", "disabled");
46
savebutton.setAttribute("onclick", "save_file()");
47
p.appendChild(savebutton);
48
var t = document.createTextNode(" ");
52
/* Print a warning message if this is not actually a text file.
54
if (handler_type != "text")
56
var warn = dom_make_text_elem("p",
57
"Warning: You are editing a binary " +
58
"file, which explains any strange characters you may see. If " +
59
"you save this file, you could corrupt it.");
60
div.appendChild(warn);
64
/** Presents the text editor.
66
function handle_text(path, text, handler_type)
68
/* Create a textarea with the text in it
69
* (The makings of a primitive editor).
71
var files = document.getElementById("filesbody");
72
/* Put our UI at the top */
73
present_editorhead(files, path, handler_type);
75
var div = document.createElement("div");
76
files.appendChild(div);
77
var txt_elem = dom_make_text_elem("textarea",
79
div.appendChild(txt_elem);
80
txt_elem.setAttribute("id", "editbox");
81
txt_elem.setAttribute("onchange", "edit_text()");
82
/* TODO: Make CSS height: 100% work */
83
txt_elem.setAttribute("rows", "35");
85
/* Load EditArea into the editbox */
89
toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, highlight, |, help",
90
start_highlight: true,
93
replace_tab_by_spaces: 4,
94
change_callback: "edit_text"