32
34
file_listing = null;
39
function action_rename(fromfilename)
41
tofilename = prompt("Rename file \"" + fromfilename + "\" to?");
42
if (tofilename == null) return;
43
do_action("move", current_path, {"from":fromfilename, "to":tofilename});
47
function action_remove(files)
49
do_action("remove", current_path, {"path":files});
53
function action_copy(files)
55
do_action("copy", current_path, {"path":files});
59
function action_cut(files)
61
do_action("cut", current_path, {"path":files});
65
function action_paste()
67
do_action("paste", current_path, {"path":"."});
35
73
/** Updates the side-panel. Expects selected_files reflects the current
123
161
if ("type" in file)
124
162
handler_type = get_handler_type(file.type);
125
163
/* Action: Use the "files" / "edit" app */
127
p = dom_make_link_elem("p", "Browse",
128
"Browse this directory in the file browser");
129
else if (handler_type == "text")
130
p = dom_make_link_elem("p", "Edit", "Edit this file");
132
p = dom_make_link_elem("p", "Browse",
133
"View this file in the file browser");
134
sidepanel.appendChild(p);
165
if (selected_files.length == 1)
167
/* Don't have "Browse" if this is the current dir */
169
p = dom_make_link_elem("p", "Browse",
170
"Navigate to this directory in the file browser",
171
make_path(path_join(this_app, current_path, filename)));
172
else if (handler_type == "text")
173
p = dom_make_link_elem("p", "Edit", "Edit this file",
174
make_path(path_join(edit_app, current_path, filename)));
176
p = dom_make_link_elem("p", "Browse",
177
"View this file in the file browser",
178
make_path(path_join(this_app, current_path, filename)));
179
sidepanel.appendChild(p);
136
182
/* Action: Use the "serve" app */
137
183
/* TODO: Figure out if this file is executable,
140
186
if (file.isdir || handler_type == "binary") {}
142
188
p = dom_make_link_elem("p", "View",
190
make_path(path_join(serve_app, current_path, filename)));
145
192
sidepanel.appendChild(p);
147
194
/* Action: Use the "download" app */
196
path = make_path(path_join(download_app, current_path, filename));
150
198
p = dom_make_link_elem("p", "Download as zip",
151
"Download this directory as a ZIP file");
199
"Download this directory as a ZIP file", path);
153
201
p = dom_make_link_elem("p", "Download",
154
"Download this file to your computer");
202
"Download this file to your computer", path);
156
204
sidepanel.appendChild(p);
158
206
p = dom_make_link_elem("p", "Rename",
159
"Change the name of this file");
207
"Change the name of this file", null,
208
"return action_rename(" + repr(filename) + ")");
160
209
sidepanel.appendChild(p);
213
path = make_path(path_join(download_app, current_path) + "?");
214
for (var i=0; i<selected_files.length; i++)
215
path += "path=" + encodeURIComponent(selected_files[i]) + "&";
216
path = path.substr(0, path.length-1);
164
217
/* Multiple files selected */
165
218
p = dom_make_link_elem("p", "Download as zip",
166
"Download the selected files as a ZIP file");
219
"Download the selected files as a ZIP file", path);
167
220
sidepanel.appendChild(p);
170
223
/* Common actions */
224
p = dom_make_link_elem("p", "Delete",
225
"Delete the selected files", null,
226
"return action_remove(selected_files)");
227
sidepanel.appendChild(p);
171
228
p = dom_make_link_elem("p", "Cut",
172
"Prepare to move the selected files to another directory");
229
"Prepare to move the selected files to another directory", null,
230
"return action_cut(selected_files)");
173
231
sidepanel.appendChild(p);
174
232
p = dom_make_link_elem("p", "Copy",
175
"Prepare to copy the selected files to another directory");
233
"Prepare to copy the selected files to another directory", null,
234
"return action_copy(selected_files)");
176
235
sidepanel.appendChild(p);
177
236
p = dom_make_link_elem("p", "Paste",
178
"Paste the copied or cut files to the current directory");
237
"Paste the copied or cut files to the current directory", null,
238
"return action_paste()");
179
239
sidepanel.appendChild(p);
181
241
if (under_subversion)
408
468
/* Column 3: Filename */
409
469
td = dom_make_link_elem("td", filename,
410
470
"Navigate to " + path_join(path, filename),
411
make_path(path_join(this_app, path, filename)),
412
"navigate(" + repr(path_join(path, filename)) + ")");
471
make_path(path_join(this_app, path, filename))/*,
472
"navigate(" + repr(path_join(path, filename)) + ")"*/);
413
473
td.setAttribute("onclick", selection_string);
414
474
row.appendChild(td);