~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/common/util.js

  • Committer: mattgiuca
  • Date: 2008-01-13 10:24:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:208
dispatch.html, ivle.css: "apptabs" is now an ID, not a class.
    This is so JavaScript code can easily identify it.
editor: Replaced dummy stub with a simple call to browser.handle.
    Editor and File Browser are now integrated with each other.
util.js: New functions, endswith and path_basename.
browser.js: Major changes to accomodate merging editor with file browser.
    Now detects "edit" URLs and handles files slightly-differently.
    In "edit mode", all files are edited even if they are binary.
    There is a warning for editing files that are binary files.
    Changes the styling of the tabs so that the "selected" tab is
    either the file browser or editor depending on whether the editor
    panel is open or not. (So the actual contents of the page determine
    which tab is selected, not the URL or the server).
    Sets the window title to the name of the directory or file being browsed.`

Show diffs side-by-side

added added

removed removed

Lines of Context:
451
451
    return path_join(root_dir, path);
452
452
}
453
453
 
 
454
/** Given a path, gets the "basename" (the last path segment).
 
455
 */
 
456
function path_basename(path)
 
457
{
 
458
    segments = path.split("/");
 
459
    if (segments[segments.length-1].length == 0)
 
460
        return segments[segments.length-2];
 
461
    else
 
462
        return segments[segments.length-1];
 
463
}
 
464
 
 
465
/** Given a string str, determines whether it ends with substr */
 
466
function endswith(str, substring)
 
467
{
 
468
    if (str.length < substring.length) return false;
 
469
    return str.substr(str.length - substring.length) == substring;
 
470
}
 
471
 
454
472
/** Makes an XMLHttpRequest call to the server. Waits (synchronously) for a
455
473
 * response, and returns an XMLHttpRequest object containing the completed
456
474
 * response.