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

« back to all changes in this revision

Viewing changes to www/media/browser/browser.js

  • Committer: mattgiuca
  • Date: 2008-01-12 15:32:54 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:200
fileservice.listing: Now returns a nicer date format for mtime_nice.
    Applies an intuitive algorithm to make the date even shorter,
    (eg. "today" or "3 days ago") and returns this as mtime_short.
util.js: Fixed path_join if the first path is empty. (Was incorrectly adding
    a leading slash).
    Added optional "title" arguments to dom_make_text_elem and
    dom_make_link_elem.
browser.js: Displays mtime_short in the file table instead of mtime_nice
    (it was always too long). Displays the full date as a tooltip.
    Auto-navigates to the user's home directory if accessed from the root.
    (This may be a temporary measure, but it was giving a mean error before).
    Various code makes use of util's new optional "title" arguments.
dispatch.html: Writes a new JavaScript variable, "username", so JavaScript
    code knows which user is logged in.
    Cleaned up JS variables repr (previously they did bad escapes in some
    cases).

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
function presentpath(path)
253
253
{
254
254
    var dom_path = document.getElementById("path");
255
 
    var navlist = [];
256
255
    var href_path = make_path(this_app);
 
256
    var nav_path = "";
257
257
 
258
258
    /* Create all of the paths */
259
259
    for each (dir in path.split("/"))
260
260
    {
261
261
        if (dir == "") continue;
262
 
        navlist.push(dir);
263
262
        /* Make an 'a' element */
264
263
        href_path = path_join(href_path, dir);
265
 
        var link = dom_make_link_elem("a", dir, href_path,
266
 
                "navigate(" + href_path + ")");
 
264
        nav_path = path_join(nav_path, dir);
 
265
        var link = dom_make_link_elem("a", dir, "Navigate to " + nav_path,
 
266
                href_path, "navigate(" + href_path + ")");
267
267
        dom_path.appendChild(link);
268
268
        dom_path.appendChild(document.createTextNode("/"));
269
269
    }
354
354
            row.appendChild(td);
355
355
            /* Column 3: Filename */
356
356
            row.appendChild(dom_make_link_elem("td", filename,
 
357
                "Navigate to " + path_join(path, filename),
357
358
                make_path(path_join(this_app, path, filename)),
358
359
                "navigate(" + path_join(path, filename) + ")"));
359
360
        }
377
378
        /* Column 4: Size */
378
379
        row.appendChild(dom_make_text_elem("td", nice_filesize(file.size)));
379
380
        /* Column 4: Date */
380
 
        row.appendChild(dom_make_text_elem("td", file.mtime_nice));
 
381
        row.appendChild(dom_make_text_elem("td", file.mtime_short,
 
382
            file.mtime_nice));
381
383
        files.appendChild(row);
382
384
    }
383
385
 
412
414
    strip_chars = make_path(this_app).length + 1;
413
415
    path = path.substr(strip_chars);
414
416
 
 
417
    if (path.length == 0)
 
418
    {
 
419
        /* Navigate to the user's home directory by default */
 
420
        /* TEMP? */
 
421
        path = username;
 
422
    }
 
423
 
415
424
    navigate(path);
416
425
}