/* libdirbrowser.js * * Library of functions needed for the AJAX dirbrowser item. */ // ----------- Global variable declarations ------------------ // -------- Change as needed if you want to tweak ------------ // ----------- the file browser's operation. ----------------- // What's the base directory to start in? (Note that this is // relative to the $base_dir configured in getsubdirs.php var Base_Dir = '/'; // What's the URL to query for subdirectory information? This may // be absolute or relative, but should point to the getsubdirs.php // script in some way or another. var Query_URL = '/getsubdirs.php'; // How wide are your folder images, in pixels? (You may want // to add a couple of extra pixels for spacing; it won't // distort the images.) var Img_Width = 18; // How many spaces do you want to use for each indent level? var Num_Spaces = 5; // What's the local URL for the open folder image? var Folder_Open = '/icons/folder-open.gif'; // And the URL for the closed folder image? var Folder_Closed = '/icons/folder-closed.gif'; // What text to use to show an open folder? var Text_Open = "(-) "; // And what text to use for a closed folder? var Text_Closed = '(+) '; // ---------------- End global declarations. ----------------- // Define our XMLHttpRequest object, "xhobj", in the global scope. var xhobj = get_XH_obj(); // Also define a global id number to be passed to the event handler. var global_id; // And a global click counter variable. This will increment on // every user click, and be used to ensure the uniqueness of // option element IDs. var click_count = 0; // Make sure these variables get treated as integers, rather // than strings. (We need them to be added, not concatenated!) Img_Width = parseInt(Img_Width); Num_Spaces = parseInt(Num_Spaces); // ------------------------------------------------------------- // --------- Begin functions, in alphabetical order ---------- // ------------------------------------------------------------- function add_dirs() { // Event handler for XMLHttpRequest object, triggered by // readyStateChange event. Collects subdirectory list // returned by server, and inserts it all after the OPTION // with the global_id that was set before the event handler // call in open_item(). var level = parseInt(get_level(global_id)) + 1; var lead_dir = document.getElementById(global_id).value; while (lead_dir.substr(-1) == '/') { lead_dir = lead_dir.substring(0, lead_dir.length - 1); } if (xhobj.readyState == 4) { var stat = xhobj.status; var stat_text = xhobj.statusText; var resp_xml = xhobj.responseXML; var dir_list = resp_xml.getElementsByTagName("dir"); // Set up a blank array to hold the actual OPTION tags // that will be inserted into the SELECT box. var opt_list = new Array(); // Now insert them, in reverse order. (That way, the // index we're inserting after remains constant.) for (i = dir_list.length - 1; i >= 0; i--) { var dirname = dir_list[i].firstChild.nodeValue; var opt_val = lead_dir + '/' + dirname; create_new_item(global_id, opt_val); } document.getElementById(global_id).scrollIntoView(); } } // ------------------------------------------------------------- function can_indent_options() { // Returns a Boolean describing whether the user's browser // can use the CSS padding-left or margin-left property // to "indent"