~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/browser/editor.js

  • Committer: drtomc
  • Date: 2007-12-11 03:26:29 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:25
A bit more work on the userdb stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
saved_status = null;
2
 
 
3
 
function save_file()
4
 
{
5
 
    filename = document.getElementById("save_filename").value;
6
 
    data = editAreaLoader.getValue("editbox");
7
 
    do_action("putfile", filename, {"path":".", "data":data});
8
 
    saved_status.data = "Saved.";
9
 
}
10
 
 
11
 
function edit_text()
12
 
{
13
 
    saved_status.data = "Not saved.";
14
 
}
15
 
 
16
 
/** Presents the text editor.
17
 
 */
18
 
function handle_text(path, text, handler_type)
19
 
{
20
 
    /* Create a textarea with the text in it
21
 
     * (The makings of a primitive editor).
22
 
     */
23
 
 
24
 
    setmode(true);
25
 
    var files = document.getElementById("filesbody");
26
 
    var div = document.createElement("div");
27
 
    files.appendChild(div);
28
 
    div.setAttribute("class", "padding");
29
 
 
30
 
    /* Set up minimal interface */
31
 
    var p = dom_make_text_elem("p", "Path: ");
32
 
    var pathname = document.createElement("input");
33
 
    pathname.setAttribute("type", "text");
34
 
    pathname.setAttribute("size", "30");
35
 
    pathname.setAttribute("id", "save_filename");
36
 
    pathname.setAttribute("value", path);
37
 
    p.appendChild(pathname);
38
 
    var savebutton = document.createElement("input");
39
 
    savebutton.setAttribute("type", "button");
40
 
    savebutton.setAttribute("value", "Save");
41
 
    savebutton.setAttribute("onclick", "save_file()");
42
 
    p.appendChild(savebutton);
43
 
    var t = document.createTextNode(" ");
44
 
    p.appendChild(t);
45
 
    saved_status = document.createTextNode("Saved.");
46
 
    //p.appendChild(saved_status);
47
 
    div.appendChild(p);
48
 
 
49
 
    /* Print a warning message if this is not actually a text file.
50
 
     */
51
 
    if (handler_type != "text")
52
 
    {
53
 
        var warn = dom_make_text_elem("p",
54
 
            "Warning: You are editing a binary " +
55
 
            "file, which explains any strange characters you may see. If " +
56
 
            "you save this file, you could corrupt it.");
57
 
        div.appendChild(warn);
58
 
    }
59
 
    var txt_elem = dom_make_text_elem("textarea",
60
 
        text.toString())
61
 
    div.appendChild(txt_elem);
62
 
    txt_elem.setAttribute("id", "editbox");
63
 
    txt_elem.setAttribute("onchange", "edit_text()");
64
 
    /* TODO: Make CSS height: 100% work */
65
 
    txt_elem.setAttribute("rows", "35");
66
 
 
67
 
    /* Load EditArea into the editbox */
68
 
    editAreaLoader.init({
69
 
        id : "editbox",
70
 
        syntax: "python",
71
 
        start_highlight: true
72
 
    });
73
 
}
74