615
/* Unrefactored Code */
623
/* Publish/unpublish */
624
if (selected_files.length == 0)
628
if ("published" in file && file.published)
630
p = dom_make_link_elem("p", "Unpublish",
631
"Make it so this directory cannot be seen by anyone but you",
633
"return action_unpublish(" + repr(path) + ")");
634
sidepanel.appendChild(p);
638
p = dom_make_link_elem("p", "Publish",
639
"Make it so this directory can be seen by anyone on the web",
641
"return action_publish(" + repr(path) + ")");
642
sidepanel.appendChild(p);
646
var handler_type = null;
648
handler_type = get_handler_type(file.type);
649
/* Action: Use the "files" app */
651
if (selected_files.length == 1)
653
/* Don't have "Browse" if this is the current dir */
655
p = dom_make_link_elem("p", "Browse",
656
"Navigate to this directory in the file browser",
657
app_path(this_app, current_path, filename));
658
else if (handler_type == "text")
659
p = dom_make_link_elem("p", "Edit", "Edit this file",
660
app_path(this_app, current_path, filename));
662
p = dom_make_link_elem("p", "Browse",
663
"View this file in the file browser",
664
app_path(this_app, current_path, filename));
665
sidepanel.appendChild(p);
668
/* Action: Use the "serve" app */
669
/* TODO: Figure out if this file is executable,
670
* and change the link to "Run" */
672
if (file.isdir || handler_type == "binary") {}
674
p = dom_make_link_elem("p", "View",
676
app_path(serve_app, current_path, filename));
678
sidepanel.appendChild(p);
680
/* Action: Use the "download" app */
682
if (selected_files.length == 0)
683
path = app_path(download_app, current_path);
685
path = app_path(download_app, current_path, filename);
687
p = dom_make_link_elem("p", "Download as zip",
688
"Download this directory as a ZIP file", path);
690
p = dom_make_link_elem("p", "Download",
691
"Download this file to your computer", path);
693
sidepanel.appendChild(p);
695
if (selected_files.length > 0)
696
{ /* Can't rename if we're in it */
697
p = dom_make_link_elem("p", "Rename",
698
"Change the name of this file", null,
699
"return action_rename(" + repr(filename) + ")");
700
sidepanel.appendChild(p);
705
path = urlencode_path(app_path(download_app, current_path)) + "?";
706
for (var i=0; i<selected_files.length; i++)
707
path += "path=" + encodeURIComponent(selected_files[i]) + "&";
708
path = path.substr(0, path.length-1);
709
/* Multiple files selected */
710
p = dom_make_link_elem("p", "Download as zip",
711
"Download the selected files as a ZIP file", path, null, true);
712
sidepanel.appendChild(p);
716
if (selected_files.length > 0)
718
p = dom_make_link_elem("p", "Delete",
719
"Delete the selected files", null,
720
"return action_remove(selected_files)");
721
sidepanel.appendChild(p);
722
p = dom_make_link_elem("p", "Cut",
723
"Prepare to move the selected files to another directory", null,
724
"return action_cut(selected_files)");
725
sidepanel.appendChild(p);
726
p = dom_make_link_elem("p", "Copy",
727
"Prepare to copy the selected files to another directory", null,
728
"return action_copy(selected_files)");
729
sidepanel.appendChild(p);
731
p = dom_make_link_elem("p", "Paste",
732
"Paste the copied or cut files to the current directory", null,
733
"return action_paste()");
734
sidepanel.appendChild(p);
735
p = dom_make_link_elem("p", "Make Directory",
736
"Make a new subdirectory in the current directory", null,
737
"return action_mkdir()");
738
sidepanel.appendChild(p);
739
p = dom_make_link_elem("p", "Upload",
740
"Upload a file to the current directory", null,
741
"return show_uploadpanel()");
742
sidepanel.appendChild(p);
743
/* The "Upload" button expands the following panel with upload tools */
744
/* This panel has a form for submitting the file to, and an iframe to load
745
* the target page in (this avoids the entire page being refreshed) */
746
div = document.createElement("div");
747
div.setAttribute("id", "uploadpanel");
748
/* This deliberately hides the upload panel whenever the selection
749
* changes. It can be re-shown by clicking "upload". */
750
div.setAttribute("style", "display: none;");
751
sidepanel.appendChild(div);
752
p = dom_make_text_elem("h3", "Upload File");
754
var form = document.createElement("form");
755
form.setAttribute("method", "POST");
756
form.setAttribute("enctype", "multipart/form-data");
757
form.setAttribute("action", app_path("fileservice", current_path));
758
form.setAttribute("target", "upload_iframe");
759
div.appendChild(form);
761
input = document.createElement("input");
762
input.setAttribute("type", "hidden");
763
input.setAttribute("name", "action");
764
input.setAttribute("value", "putfiles");
765
form.appendChild(input);
767
input = document.createElement("input");
768
input.setAttribute("type", "hidden");
769
input.setAttribute("name", "path");
770
input.setAttribute("value", "");
771
form.appendChild(input);
773
p = document.createElement("p");
775
input = document.createElement("input");
776
input.setAttribute("type", "file");
777
input.setAttribute("name", "data");
778
p.appendChild(input);
780
p = document.createElement("p");
782
input = document.createElement("input");
783
input.setAttribute("type", "checkbox");
784
input.setAttribute("name", "unpack");
785
input.setAttribute("value", "true");
786
input.setAttribute("checked", "on");
787
p.appendChild(input);
788
p.appendChild(document.createTextNode(" Unpack zip file"));
790
p = document.createElement("p");
792
input = document.createElement("input");
793
input.setAttribute("type", "button");
794
input.setAttribute("value", "Hide");
795
input.setAttribute("onclick", "show_uploadpanel(false)");
796
p.appendChild(input);
797
p.appendChild(document.createTextNode(" "));
798
input = document.createElement("input");
799
input.setAttribute("type", "submit");
800
input.setAttribute("value", "Send");
801
p.appendChild(input);
803
/* Now we create an invisible iframe which will receive the upload.
804
* The form submits to fileservice, loading the result into this iframe
805
* instead of the whole browser window (this is an alternative to Ajax,
806
* since Ajax doesn't allow reading the file from the user's disk).
807
* Note this iframe's id is the same as the form's target.
809
var upload_iframe = document.createElement("iframe");
810
upload_iframe.setAttribute("id", "upload_iframe");
811
upload_iframe.setAttribute("name", "upload_iframe");
812
upload_iframe.setAttribute("style", "display: none;");
813
/* When we get a callback, simply cause a nav to the current path, so we
814
* update the directory listing. */
815
upload_callback_count = 0; /* See upload_callback */
816
upload_iframe.setAttribute("onload", "upload_callback()");
817
div.appendChild(upload_iframe);
818
/* END Upload panel */
820
if (under_subversion)
822
/* TODO: Only show relevant links */
823
p = dom_make_text_elem("h3", "Subversion");
824
sidepanel.appendChild(p);
826
/* TODO: if any selected files are unversioned */
827
p = dom_make_link_elem("p", "Add",
828
"Schedule the selected temporary files to be added permanently",
830
"return action_add(selected_files)");
831
sidepanel.appendChild(p);
832
p = dom_make_link_elem("p", "Revert",
833
"Restore the selected files back to their last committed state",
835
"return action_revert(selected_files)");
836
sidepanel.appendChild(p);
838
p = dom_make_link_elem("p", "Commit",
839
"Commit any changes to the permanent repository",
841
"return action_commit(selected_files)");
842
sidepanel.appendChild(p);
847
615
/** Event handler for when an item of the "More actions..." dropdown box is