31
31
/** The listing object returned by the server as JSON */
32
32
file_listing = null;
35
/** Updates the side-panel. Expects selected_files reflects the current
38
function update_sidepanel(total_file_size_sel)
40
var sidepanel = document.getElementById("sidepanel");
44
/* Is this dir under svn? */
45
var under_subversion = "svnstatus" in thisdir;
46
dom_removechildren(sidepanel);
47
if (selected_files.length <= 1)
49
if (selected_files.length == 0)
51
/* Display information about the current directory instead */
52
filename = path_basename(current_path);
55
else if (selected_files.length == 1)
57
filename = selected_files;
58
file = file_listing[filename];
61
if ("isdir" in file && file.isdir)
62
filetype = "text/directory";
63
else if ("type" in file)
66
filetype = "text/plain";
68
p = document.createElement("p");
69
sidepanel.appendChild(p);
70
p.appendChild(dom_make_img(mime_type_to_icon(filetype, true),
71
null, null, filetype));
72
p = dom_make_text_elem("h2", filename);
73
sidepanel.appendChild(p);
74
p = dom_make_text_elem("p", filetype);
75
sidepanel.appendChild(p);
78
p = dom_make_text_elem("p", "Size: " + nice_filesize(file.size));
79
sidepanel.appendChild(p);
81
if ("mtime_nice" in file)
83
p = dom_make_text_elem("p", "Modified: " + file.mtime_nice);
84
sidepanel.appendChild(p);
89
/* Multiple files selected */
90
p = document.createElement("p");
91
sidepanel.appendChild(p);
92
p.appendChild(dom_make_img(
93
make_path(path_join(type_icons_path_large, "multi.png")),
94
null, null, "Multiple files"));
95
p = dom_make_text_elem("h2",
96
selected_files.length.toString() + " files selected");
97
sidepanel.appendChild(p);
98
p = dom_make_text_elem("p", "Total size: "
99
+ nice_filesize(total_file_size_sel));
100
sidepanel.appendChild(p);
103
p = dom_make_text_elem("h3", "Actions");
104
sidepanel.appendChild(p);
106
if (selected_files.length <= 1)
108
var handler_type = null;
110
handler_type = get_handler_type(file.type);
111
/* Action: Use the "files" / "edit" app */
113
p = dom_make_link_elem("p", "Browse",
114
"Browse this directory in the file browser");
115
else if (handler_type == "text")
116
p = dom_make_link_elem("p", "Edit", "Edit this file");
118
p = dom_make_link_elem("p", "Browse",
119
"View this file in the file browser");
120
sidepanel.appendChild(p);
122
/* Action: Use the "serve" app */
123
/* TODO: Figure out if this file is executable,
124
* and change the link to "Run" */
126
if (file.isdir || handler_type == "binary") {}
128
p = dom_make_link_elem("p", "View",
131
sidepanel.appendChild(p);
133
/* Action: Use the "download" app */
136
p = dom_make_link_elem("p", "Download as zip",
137
"Download this directory as a ZIP file");
139
p = dom_make_link_elem("p", "Download",
140
"Download this file to your computer");
142
sidepanel.appendChild(p);
144
p = dom_make_link_elem("p", "Rename",
145
"Change the name of this file");
146
sidepanel.appendChild(p);
150
/* Multiple files selected */
151
p = dom_make_link_elem("p", "Download as zip",
152
"Download the selected files as a ZIP file");
153
sidepanel.appendChild(p);
157
p = dom_make_link_elem("p", "Cut",
158
"Prepare to move the selected files to another directory");
159
sidepanel.appendChild(p);
160
p = dom_make_link_elem("p", "Copy",
161
"Prepare to copy the selected files to another directory");
162
sidepanel.appendChild(p);
163
p = dom_make_link_elem("p", "Paste",
164
"Paste the copied or cut files to the current directory");
165
sidepanel.appendChild(p);
168
<p><a href="">Cut</a></p>
169
<p><a href="">Copy</a></p>
171
if (under_subversion)
173
p = dom_make_text_elem("h3", "Subversion");
174
sidepanel.appendChild(p);
176
<p><a href="">Commit</a></p>
177
<p><a href="">Update</a></p>
34
183
/** Updates the side-panel and status bar to reflect the current set of
35
184
* selected files. This is done by inspecting the states of the check boxes.