23
23
/* Url names for apps */
24
24
this_app = "files";
25
25
service_app = "fileservice";
27
download_app = "download";
27
29
/* Mapping MIME types onto handlers.
28
30
* "text" : When navigating to a text file, the text editor is opened.
235
237
function handle_error(message)
237
/* TODO: Find a better place to put this message. */
238
var files = document.getElementById("files");
239
var tr = document.createElement("tr");
240
var td = document.createElement("td");
242
var td = document.createElement("td");
244
var td = document.createElement("td");
246
var txt_elem = dom_make_text_elem("td", "Error: "
239
var files = document.getElementById("filesbody");
240
var txt_elem = dom_make_text_elem("div", "Error: "
247
241
+ message.toString() + ".")
248
txt_elem.setAttribute("class", "error");
249
tr.appendChild(txt_elem);
250
var td = document.createElement("td");
252
var td = document.createElement("td");
254
files.appendChild(tr);
242
txt_elem.setAttribute("class", "padding error");
243
files.appendChild(txt_elem);
257
246
/** Presents a path list (address bar inside the page) for clicking.
478
467
function handle_text(path, text)
469
/* Create a textarea with the text in it
470
* (The makings of a primitive editor).
472
var files = document.getElementById("filesbody");
473
var div = document.createElement("div");
474
files.appendChild(div);
475
div.setAttribute("class", "padding");
476
var txt_elem = dom_make_text_elem("textarea",
478
div.appendChild(txt_elem);
479
txt_elem.setAttribute("id", "editbox");
480
/* TODO: Make CSS height: 100% work */
481
txt_elem.setAttribute("rows", "20");
484
484
/** Displays a download link to the binary file.
486
486
function handle_binary(path)
489
var files = document.getElementById("filesbody");
490
var div = document.createElement("div");
491
files.appendChild(div);
492
div.setAttribute("class", "padding");
493
var download_link = make_path(path_join(download_app, path));
494
var par1 = dom_make_text_elem("p",
495
"The file " + path + " is a binary file. To download this file, " +
496
"click the following link:");
497
var par2 = dom_make_link_elem("p",
498
"Download " + path, "Download " + path, download_link);
499
div.appendChild(par1);
500
div.appendChild(par2);
492
503
/** Called when the page loads initially.