~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-11 03:12:16 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:175
dispatch.html: HTML headers for all pages now include a JavaScript
declarations section where variables are defined with server-config values.
Included is root_dir, needed by the client to create URLs relative to IVLE.
util: Added path_join and make_path functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
303
303
        return [r];
304
304
}
305
305
 
 
306
/** Joins one or more paths together. Accepts 1 or more arguments.
 
307
 */
 
308
function path_join(path1 /*, path2, ... */)
 
309
{
 
310
    var arg;
 
311
    path = path1;
 
312
    for (var i=1; i<arguments.length; i++)
 
313
    {
 
314
        arg = arguments[i];
 
315
        if (arg.length == 0) continue;
 
316
        if (arg[0] == '/')
 
317
            path = arg;
 
318
        else
 
319
        {
 
320
            if (path[path.length-1] != '/')
 
321
                path += '/';
 
322
            path += arg;
 
323
        }
 
324
    }
 
325
    return path;
 
326
}
 
327
 
 
328
/** Given a path relative to the IVLE root, gives a path relative to
 
329
 * the site root.
 
330
 */
 
331
function make_path(path)
 
332
{
 
333
    return path_join(root_dir, path);
 
334
}
 
335