157
157
* Called "navigate", can also be used for a simple refresh.
158
158
* Always makes a GET request.
159
159
* No return value.
160
* \param editmode Optional boolean. If true, then the user navigated here
161
* with an "edit" URL so we should favour using the editor.
163
function navigate(path, editmode)
161
function navigate(path)
165
163
callback = function(response)
283
281
/* Treat this as an ordinary file. Get the file type. */
284
282
var content_type = response.getResponseHeader("Content-Type");
285
283
var handler_type = get_handler_type(content_type);
286
/* If we're in "edit mode", always treat this file as text */
287
284
would_be_handler_type = handler_type;
288
285
/* handler_type should now be set to either
289
286
* "text", "image", "audio" or "binary". */
329
326
dom_removechildren(document.getElementById("sidepanel"));
332
/** Sets the mode to either "file browser" or "text editor" mode.
333
* This modifies the window icon, and selected tab.
334
* \param editmode If True, editor mode. Else, file browser mode.
336
function setmode(editmode)
338
/* Find the DOM elements for the file browser and editor tabs */
339
var tabs = document.getElementById("apptabs");
340
var tab_files = null;
344
for (var i=0; i<tabs.childNodes.length; i++)
346
/* Find the href of the link within */
347
if (!tabs.childNodes[i].getElementsByTagName) continue;
348
a = tabs.childNodes[i].getElementsByTagName("a");
349
if (a.length == 0) continue;
350
href = a[0].getAttribute("href");
351
if (href == null) continue;
352
if (endswith(href, this_app))
353
tab_files = tabs.childNodes[i];
354
else if (endswith(href, edit_app))
355
tab_edit = tabs.childNodes[i];
360
tab_files.removeAttribute("class");
361
tab_edit.setAttribute("class", "thisapp");
365
tab_edit.removeAttribute("class");
366
tab_files.setAttribute("class", "thisapp");
370
329
/*** HANDLERS for different types of responses (such as dir listing, file,
373
332
function handle_error(message)
376
334
var files = document.getElementById("filesbody");
377
335
var txt_elem = dom_make_text_elem("div", "Error: "
378
336
+ message.toString() + ".")
700
657
app_path(this_app, current_path, filename));
701
658
else if (handler_type == "text")
702
659
p = dom_make_link_elem("p", "Edit", "Edit this file",
703
app_path(edit_app, current_path, filename));
660
app_path(this_app, current_path, filename));
705
662
p = dom_make_link_elem("p", "Browse",
706
663
"View this file in the file browser",
914
871
var path = parse_url(window.location.href).path;
915
872
/* Strip out root_dir + "/files" from the front of the path */
916
873
var strip = make_path(this_app);
917
var editmode = false;
918
874
if (path.substr(0, strip.length) == strip)
919
875
path = path.substr(strip.length+1);