266
var err = document.createElement("div");
267
var p = dom_make_text_elem("p", "Error: "
268
+ "There was an unexpected server error processing "
269
+ "the selected command.");
271
p = dom_make_text_elem("p", "If the problem persists, please "
272
+ "contact the system administrator.")
274
p = document.createElement("p");
275
var refresh = document.createElement("input");
276
refresh.setAttribute("type", "button");
277
refresh.setAttribute("value", "Back to file view");
278
refresh.setAttribute("onclick", "refresh()");
279
p.appendChild(refresh);
285
var err = document.createElement("div");
286
var p = dom_make_text_elem("p", "Error: "
287
+ "There was an unexpected server error retrieving "
288
+ "the requested file or directory.");
290
p = dom_make_text_elem("p", "If the problem persists, please "
291
+ "contact the system administrator.")
249
handle_error("The server returned an invalid directory listing");
297
252
/* Get "." out, it's special */
298
253
current_file = file_listing["."]; /* Global */
299
254
delete file_listing["."];
301
if ('revision' in listing)
303
current_revision = listing.revision;
306
256
/* Check if this is a directory listing or file contents */
307
257
var isdir = response.getResponseHeader("X-IVLE-Return") == "Dir";
311
home_listing(listing, subjects, path);
260
handle_dir_listing(path, listing);
426
353
/*** HANDLERS for different types of responses (such as dir listing, file,
430
* message may either be a string, or a DOM node, which will be placed inside
433
356
function handle_error(message)
435
358
var files = document.getElementById("filesbody");
437
if (typeof(message) == "string")
439
txt_elem = dom_make_text_elem("div", "Error: "
440
+ message.toString() + ".")
444
/* Assume message is a DOM node */
445
txt_elem = document.createElement("div");
446
txt_elem.appendChild(message);
359
var txt_elem = dom_make_text_elem("div", "Error: "
360
+ message.toString() + ".")
448
361
txt_elem.setAttribute("class", "padding error");
449
362
files.appendChild(txt_elem);
452
/** Given a path, filename and optional revision, returns a URL to open that
453
* revision of that file.
455
function build_revision_url(path, filename, revision)
457
bits = {'path': app_path(this_app, path, filename)};
458
if (current_revision)
460
bits['query_string'] = 'r=' + revision;
462
return build_url(bits);
465
365
/** Given a mime type, returns the path to the icon.
466
366
* \param type String, Mime type.
467
367
* \param sizelarge Boolean, optional.
735
585
+ "can be seen by anyone on the web");
736
586
publish.textContent = "Publish";
739
set_action_state(["publish", "submit"], pubcond);
588
submit.setAttribute("class", "choice");
589
submit.removeAttribute("disabled");
593
publish.setAttribute("class", "disabled");
594
publish.setAttribute("disabled", "disabled");
595
submit.setAttribute("class", "disabled");
596
submit.setAttribute("disabled", "disabled");
742
/* If exactly 1 non-directory file is selected, and its parent
600
/* If exactly 1 non-directory file is selected/opened, and its parent
743
601
* directory is published.
745
set_action_state("share", numsel == 1 && !file.isdir &&
746
current_file.published);
603
var share = document.getElementById("act_share");
604
if (numsel <= 1 && !file.isdir)
606
/* Work out if parent dir is published */
607
parentdir = current_file;
608
if (parentdir.published)
610
share.setAttribute("class", "choice");
611
share.removeAttribute("disabled");
613
share.setAttribute("class", "disabled");
614
share.setAttribute("disabled", "disabled");
619
share.setAttribute("class", "disabled");
620
share.setAttribute("disabled", "disabled");
749
624
/* If exactly 1 file is selected */
750
set_action_state("rename", numsel == 1);
625
var rename = document.getElementById("act_rename");
628
rename.setAttribute("class", "choice");
629
rename.removeAttribute("disabled");
633
rename.setAttribute("class", "disabled");
634
rename.setAttribute("disabled", "disabled");
752
637
/* Delete, cut, copy */
753
638
/* If >= 1 file is selected */
754
set_action_state(["delete", "cut", "copy"], numsel >= 1);
639
var act_delete = document.getElementById("act_delete");
640
var cut = document.getElementById("act_cut");
641
var copy = document.getElementById("act_copy");
644
act_delete.setAttribute("class", "choice");
645
act_delete.removeAttribute("disabled");
646
cut.setAttribute("class", "choice");
647
cut.removeAttribute("disabled");
648
copy.setAttribute("class", "choice");
649
copy.removeAttribute("disabled");
653
act_delete.setAttribute("class", "disabled");
654
act_delete.setAttribute("disabled", "disabled");
655
cut.setAttribute("class", "disabled");
656
cut.setAttribute("disabled", "disabled");
657
copy.setAttribute("class", "disabled");
658
copy.setAttribute("disabled", "disabled");
756
661
/* Paste, new file, new directory, upload */
757
662
/* Disable if the current file is not a directory */
758
set_action_state(["paste", "newfile", "mkdir", "upload"], current_file.isdir);
663
if (!current_file.isdir)
665
var paste = document.getElementById("act_paste");
666
var newfile = document.getElementById("act_newfile");
667
var mkdir = document.getElementById("act_mkdir");
668
var upload = document.getElementById("act_upload");
669
paste.setAttribute("class", "disabled");
670
paste.setAttribute("disabled", "disabled");
671
newfile.setAttribute("class", "disabled");
672
newfile.setAttribute("disabled", "disabled");
673
mkdir.setAttribute("class", "disabled");
674
mkdir.setAttribute("disabled", "disabled");
675
upload.setAttribute("class", "disabled");
676
upload.setAttribute("disabled", "disabled");
760
679
/* Subversion actions */
761
/* These are only useful if we are in a versioned directory and have some
763
set_action_state(["svnadd",], numsel >= 1 && current_file.svnstatus);
764
/* And these are only usefull is ALL the selected files are versioned */
765
set_action_state(["svnremove", "svnrevert", "svncommit", "svncopy",
766
"svncut"], numsel >= 1 && current_file.svnstatus && svn_selection);
768
/* Diff, log and update only support one path at the moment, so we must
769
* have 0 or 1 versioned files selected. If 0, the directory must be
771
single_versioned_path = (
773
(numsel == 1 && (svnst = file_listing[selected_files[0]].svnstatus)) ||
774
(numsel == 0 && (svnst = current_file.svnstatus))
775
) && svnst != "unversioned");
776
set_action_state(["svndiff", "svnupdate"], single_versioned_path);
778
/* We can resolve if we have a file selected and it is conflicted. */
779
set_action_state("svnresolved", single_versioned_path && numsel == 1 && svnst == "conflicted");
781
/* Log should be available for revisions as well. */
782
set_action_state("svnlog", single_versioned_path, true);
680
/* TODO: Work out when these are appropriate */
681
var svnadd = document.getElementById("act_svnadd");
682
var svnrevert = document.getElementById("act_svnrevert");
683
var svncommit = document.getElementById("act_svncommit");
686
svnadd.setAttribute("class", "choice");
687
svnadd.removeAttribute("disabled");
688
svnrevert.setAttribute("class", "choice");
689
svnrevert.removeAttribute("disabled");
690
svncommit.setAttribute("class", "choice");
691
svncommit.removeAttribute("disabled");
693
var svncheckout = document.getElementById("act_svncheckout");
694
/* current_path == username: We are at the top level */
695
if (current_path == username)
697
svncheckout.setAttribute("class", "choice");
698
svncheckout.removeAttribute("disabled");
702
svncheckout.setAttribute("class", "disabled");
703
svncheckout.setAttribute("disabled", "disabled");
784
706
/* There is currently nothing on the More Actions menu of use
785
707
* when the current file is not a directory. Hence, just remove
787
709
* (This makes some of the above decisions somewhat redundant).
788
* We also take this opportunity to show the appropriate actions2
789
* bar for this path. It should either be a save or upload widget.
791
if (current_file.isdir)
711
if (!(current_file.isdir))
793
var actions2_directory = document.getElementById("actions2_directory");
794
actions2_directory.setAttribute("style", "display: inline;");
795
713
var moreactions = document.getElementById("moreactions_area");
796
moreactions.setAttribute("style", "display: inline;");
800
var actions2_file = document.getElementById("actions2_file");
801
actions2_file.setAttribute("style", "display: inline;");
714
moreactions.setAttribute("style", "display: none;");