~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-03-05 04:34:27 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:647
phpBB3 - Added svn:ignore on autoconfigged file, config.php.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    "application/x-javascript" : "text",
44
44
    "application/javascript" : "text",
45
45
    "application/json" : "text",
46
 
    "application/xml" : "text",
 
46
    "application/xml" : "text"
47
47
};
48
48
 
49
49
/* Mapping MIME types to icons, just the file's basename */
50
50
type_icons = {
51
51
    "text/directory": "dir.png",
52
 
    "text/x-python": "py.png",
 
52
    "text/x-python": "py.png"
53
53
};
54
54
 
55
55
default_type_icon = "txt.png";
66
66
    "missing": "missing.png",
67
67
    "deleted": "deleted.png",
68
68
    "modified": "modified.png",
 
69
    "revision": "revision.png"
69
70
};
70
71
 
71
72
/* Mapping SVN status to "nice" strings */
79
80
    "modified": "Permanent file (modified)",
80
81
    "merged": "Permanent file (merged)",
81
82
    "conflicted": "Permanent file (conflicted)",
 
83
    "revision": "Past Permanent file (revision)"
82
84
};
83
85
 
84
86
default_svn_icon = null;
93
95
 * application can interpret them.
94
96
 */
95
97
types_exec = [
96
 
    "text/x-python",
 
98
    "text/x-python"
97
99
];
98
100
 
99
101
 
100
102
/* Global variables */
101
103
 
 
104
/** The listing object returned by the server as JSON */
 
105
file_listing = null;
 
106
current_file = null;
102
107
current_path = "";
103
108
 
 
109
/** Filenames of all files selected
 
110
 * (Only used by dir listings, but still needs to be [] for files, so that
 
111
 * update_actions knows that nothing is selected).
 
112
 */
 
113
selected_files = [];
 
114
 
 
115
upload_callback_count = 0;      /* See upload_callback */
 
116
 
104
117
/** Calls the server using Ajax, performing an action on the server side.
105
118
 * Receives the response from the server and performs a refresh of the page
106
119
 * contents, updating it to display the returned data (such as a directory
120
133
 *      Defaults to "application/x-www-form-urlencoded".
121
134
 *      "multipart/form-data" is recommended for large uploads.
122
135
 */
123
 
function do_action(action, path, args, content_type)
 
136
function do_action(action, path, args, content_type, ignore_response)
124
137
{
125
138
    args.action = action;
 
139
    /* Callback action, when the server returns */
 
140
    var callback = function(response)
 
141
        {
 
142
            /* Check for action errors reported by the server, and report them
 
143
             * to the user */
 
144
            var error = response.getResponseHeader("X-IVLE-Action-Error");
 
145
            if (error != null)
 
146
                alert("Error: " + error.toString() + ".");
 
147
            /* Now read the response and set up the page accordingly */
 
148
            if (ignore_response != true)
 
149
                handle_response(path, response);
 
150
        }
126
151
    /* Call the server and perform the action. This mutates the server. */
127
 
    response = ajax_call(service_app, path, args, "POST", content_type);
128
 
    /* Check for action errors reported by the server, and report them to the
129
 
     * user */
130
 
    error = response.getResponseHeader("X-IVLE-Action-Error");
131
 
    if (error != null)
132
 
        alert("Error: " + error.toString() + ".");
133
 
    /* Now read the response and set up the page accordingly */
134
 
    handle_response(path, response);
 
152
    ajax_call(callback, service_app, path, args, "POST", content_type);
135
153
}
136
154
 
137
155
/** Calls the server using Ajax, requesting a directory listing. This should
141
159
 * Called "navigate", can also be used for a simple refresh.
142
160
 * Always makes a GET request.
143
161
 * No return value.
144
 
 * \param editmode Optional boolean. If true, then the user navigated here
145
 
 * with an "edit" URL so we should favour using the editor.
146
 
 */
147
 
function navigate(path, editmode)
148
 
{
149
 
    /* Call the server and request the listing. This mutates the server. */
150
 
    response = ajax_call(service_app, path, null, "GET");
151
 
    /* Now read the response and set up the page accordingly */
152
 
    handle_response(path, response, editmode);
 
162
 */
 
163
function navigate(path)
 
164
{
 
165
    callback = function(response)
 
166
        {
 
167
            /* Read the response and set up the page accordingly */
 
168
            handle_response(path, response, url.args);
 
169
        }
 
170
    /* Get any query strings */
 
171
    url = parse_url(window.location.href);
 
172
    
 
173
    /* Call the server and request the listing. */
 
174
    ajax_call(callback, service_app, path, url.args, "GET");
 
175
}
 
176
 
 
177
/* Refreshes the current view.
 
178
 * Calls navigate on the current path.
 
179
 */
 
180
function refresh()
 
181
{
 
182
    navigate(current_path);
153
183
}
154
184
 
155
185
/** Determines the "handler type" from a MIME type.
181
211
 * things) be used to update the URL in the location bar.
182
212
 * \param response XMLHttpRequest object returned by the server. Should
183
213
 * contain all the response data.
184
 
 * \param editmode Optional boolean. If true, then the user navigated here
185
 
 * with an "edit" URL so we should favour using the editor.
 
214
 * \param url_args Arguments dict, for the arguments passed to the URL
 
215
 * in the browser's address bar (will be forwarded along).
186
216
 */
187
 
function handle_response(path, response, editmode)
 
217
function handle_response(path, response, url_args)
188
218
{
189
219
    /* TODO: Set location bar to "path" */
190
220
    current_path = path;
191
221
 
192
222
    /* Clear away the existing page contents */
193
223
    clearpage();
194
 
    /* Display the path at the top, for navigation */
195
 
    presentpath(path);
196
224
 
197
225
    /* Check the status, and if not 200, read the error and handle this as an
198
226
     * error. */
205
233
        return;
206
234
    }
207
235
 
 
236
    /* This will always return a listing, whether it is a dir or a file.
 
237
     */
 
238
    var listing = response.responseText;
 
239
    /* The listing SHOULD be valid JSON text. Parse it into an object. */
 
240
    try
 
241
    {
 
242
        listing = JSON.parse(listing);
 
243
        file_listing = listing.listing;     /* Global */
 
244
    }
 
245
    catch (e)
 
246
    {
 
247
        handle_error("The server returned an invalid directory listing");
 
248
        return;
 
249
    }
 
250
    /* Get "." out, it's special */
 
251
    current_file = file_listing["."];     /* Global */
 
252
    delete file_listing["."];
 
253
 
208
254
    /* Check if this is a directory listing or file contents */
209
255
    var isdir = response.getResponseHeader("X-IVLE-Return") == "Dir";
210
 
    if (!editmode && isdir)
 
256
    if (isdir)
211
257
    {
212
 
        var listing = response.responseText;
213
 
        /* The listing SHOULD be valid JSON text. Parse it into an object. */
214
 
        try
215
 
        {
216
 
            listing = JSON.parse(listing);
217
 
        }
218
 
        catch (e)
219
 
        {
220
 
            handle_error("The server returned an invalid directory listing");
221
 
            return;
222
 
        }
223
258
        handle_dir_listing(path, listing);
224
259
    }
225
260
    else
226
261
    {
227
 
        /* Treat this as an ordinary file. Get the file type. */
228
 
        var content_type = response.getResponseHeader("Content-Type");
229
 
        var handler_type = get_handler_type(content_type);
230
 
        /* If we're in "edit mode", always treat this file as text */
231
 
        would_be_handler_type = handler_type;
232
 
        if (editmode) handler_type = "text";
233
 
        /* handler_type should now be set to either
234
 
         * "text", "image", "audio" or "binary". */
235
 
        switch (handler_type)
236
 
        {
237
 
        case "text":
238
 
            if (isdir)
239
 
            {
240
 
                handle_text(path_join(path, "untitled"), "",
241
 
                    would_be_handler_type);
242
 
            }
243
 
            else
244
 
            {
245
 
                handle_text(path, response.responseText,
246
 
                    would_be_handler_type);
247
 
            }
248
 
            break;
249
 
        case "image":
250
 
            /* TODO: Custom image handler */
251
 
            handle_binary(path, response.responseText);
252
 
            break;
253
 
        case "audio":
254
 
            /* TODO: Custom audio handler */
255
 
            handle_binary(path, response.responseText);
256
 
            break;
257
 
        case "binary":
258
 
            handle_binary(path);
259
 
            break;
260
 
        }
261
 
    }
 
262
        /* Need to make a 2nd ajax call, this time get the actual file
 
263
         * contents */
 
264
        callback = function(response)
 
265
            {
 
266
                /* Read the response and set up the page accordingly */
 
267
                handle_contents_response(path, response);
 
268
            }
 
269
        /* Call the server and request the listing. */
 
270
        if (url_args)
 
271
            args = shallow_clone_object(url_args);
 
272
        else
 
273
            args = {};
 
274
        /* This time, get the contents of the file, not its metadata */
 
275
        args['return'] = "contents";
 
276
        ajax_call(callback, service_app, path, args, "GET");
 
277
    }
 
278
    update_actions(isdir);
 
279
}
 
280
 
 
281
function handle_contents_response(path, response)
 
282
{
 
283
    /* Treat this as an ordinary file. Get the file type. */
 
284
    var content_type = response.getResponseHeader("Content-Type");
 
285
    var handler_type = get_handler_type(content_type);
 
286
    would_be_handler_type = handler_type;
 
287
    /* handler_type should now be set to either
 
288
     * "text", "image", "audio" or "binary". */
 
289
    switch (handler_type)
 
290
    {
 
291
    case "text":
 
292
        handle_text(path, response.responseText,
 
293
            would_be_handler_type);
 
294
        break;
 
295
    case "image":
 
296
        /* TODO: Custom image handler */
 
297
        handle_binary(path, response.responseText);
 
298
        break;
 
299
    case "audio":
 
300
        /* TODO: Custom audio handler */
 
301
        handle_binary(path, response.responseText);
 
302
        break;
 
303
    case "binary":
 
304
        handle_binary(path);
 
305
        break;
 
306
    }
 
307
}
 
308
 
 
309
/* Called when a form upload comes back (from an iframe).
 
310
 * Refreshes the page.
 
311
 */
 
312
function upload_callback()
 
313
{
 
314
    /* This has a pretty nasty hack, which happens to work.
 
315
     * upload_callback is set as the "onload" callback for the iframe which
 
316
     * receives the response from the server for uploading a file.
 
317
     * This means it gets called twice. Once when initialising the iframe, and
 
318
     * a second time when the actual response comes back.
 
319
     * All we want to do is call navigate to refresh the page. But we CAN'T do
 
320
     * that on the first load or it will just go into an infinite cycle of
 
321
     * refreshing. We need to refresh the page ONLY on the second refresh.
 
322
     * upload_callback_count is reset to 0 just before the iframe is created.
 
323
     */
 
324
    upload_callback_count++;
 
325
    if (upload_callback_count >= 2)
 
326
        refresh();
262
327
}
263
328
 
264
329
/** Deletes all "dynamic" content on the page.
267
332
 */
268
333
function clearpage()
269
334
{
270
 
    dom_removechildren(document.getElementById("path"));
271
335
    dom_removechildren(document.getElementById("filesbody"));
272
336
}
273
337
 
284
348
    dom_removechildren(document.getElementById("sidepanel"));
285
349
}
286
350
 
287
 
/** Sets the mode to either "file browser" or "text editor" mode.
288
 
 * This modifies the window icon, and selected tab.
289
 
 * \param editmode If True, editor mode. Else, file browser mode.
290
 
 */
291
 
function setmode(editmode)
292
 
{
293
 
    /* Find the DOM elements for the file browser and editor tabs */
294
 
    var tabs = document.getElementById("apptabs");
295
 
    var tab_files = null;
296
 
    var tab_edit = null;
297
 
    var a;
298
 
    var href;
299
 
    for (var i=0; i<tabs.childNodes.length; i++)
300
 
    {
301
 
        /* Find the href of the link within */
302
 
        if (!tabs.childNodes[i].getElementsByTagName) continue;
303
 
        a = tabs.childNodes[i].getElementsByTagName("a");
304
 
        if (a.length == 0) continue;
305
 
        href = a[0].getAttribute("href");
306
 
        if (href == null) continue;
307
 
        if (endswith(href, this_app))
308
 
            tab_files = tabs.childNodes[i];
309
 
        else if (endswith(href, edit_app))
310
 
            tab_edit = tabs.childNodes[i];
311
 
    }
312
 
 
313
 
    if (editmode)
314
 
    {
315
 
        tab_files.removeAttribute("class");
316
 
        tab_edit.setAttribute("class", "thisapp");
317
 
    }
318
 
    else
319
 
    {
320
 
        tab_edit.removeAttribute("class");
321
 
        tab_files.setAttribute("class", "thisapp");
322
 
    }
323
 
}
324
 
 
325
351
/*** HANDLERS for different types of responses (such as dir listing, file,
326
352
 * etc). */
327
353
 
328
354
function handle_error(message)
329
355
{
330
 
    setmode(false);
331
356
    var files = document.getElementById("filesbody");
332
357
    var txt_elem = dom_make_text_elem("div", "Error: "
333
358
        + message.toString() + ".")
335
360
    files.appendChild(txt_elem);
336
361
}
337
362
 
338
 
/** Presents a path list (address bar inside the page) for clicking.
339
 
 */
340
 
function presentpath(path)
341
 
{
342
 
    var dom_path = document.getElementById("path");
343
 
    var href_path = make_path(this_app);
344
 
    var nav_path = "";
345
 
    var dir;
346
 
 
347
 
    /* Also set the document title */
348
 
    document.title = path_basename(path) + " - IVLE";
349
 
    /* Create all of the paths */
350
 
    var pathlist = path.split("/");
351
 
    for (var i=0; i<pathlist.length; i++)
352
 
    {
353
 
        dir = pathlist[i];
354
 
        if (dir == "") continue;
355
 
        /* Make an 'a' element */
356
 
        href_path = path_join(href_path, dir);
357
 
        nav_path = path_join(nav_path, dir);
358
 
        var link = dom_make_link_elem("a", dir, "Navigate to " + nav_path,
359
 
                href_path/*, "navigate(" + repr(href_path) + ")"*/);
360
 
        dom_path.appendChild(link);
361
 
        dom_path.appendChild(document.createTextNode("/"));
362
 
    }
363
 
    dom_path.removeChild(dom_path.lastChild);
364
 
}
365
 
 
366
363
/** Given a mime type, returns the path to the icon.
367
364
 * \param type String, Mime type.
368
365
 * \param sizelarge Boolean, optional.
412
409
 */
413
410
function handle_binary(path)
414
411
{
415
 
    setmode(false);
416
412
    var files = document.getElementById("filesbody");
417
413
    var div = document.createElement("div");
418
414
    files.appendChild(div);
427
423
    div.appendChild(par2);
428
424
}
429
425
 
 
426
function update_actions()
 
427
{
 
428
    var file;
 
429
    var numsel = selected_files.length;
 
430
    if (numsel <= 1)
 
431
    {
 
432
        if (numsel == 0)
 
433
        {
 
434
            /* Display information about the current directory instead */
 
435
            filename = path_basename(current_path);
 
436
            file = current_file;
 
437
        }
 
438
        else if (numsel == 1)
 
439
        {
 
440
            filename = selected_files[0];
 
441
            file = file_listing[filename];
 
442
        }
 
443
 
 
444
        /* Update each action node in the topbar.
 
445
         * This includes enabling/disabling actions as appropriate, and
 
446
         * setting href/onclick attributes. */
 
447
    }
 
448
 
 
449
    /* Open */
 
450
    /* Available if exactly one file is selected */
 
451
    var open = document.getElementById("act_open");
 
452
    if (numsel == 1)
 
453
    {
 
454
        open.setAttribute("class", "choice");
 
455
        if (file.isdir)
 
456
            open.setAttribute("title",
 
457
                "Navigate to this directory in the file browser");
 
458
        else
 
459
            open.setAttribute("title",
 
460
                "Edit or view this file");
 
461
        open.setAttribute("href", app_path(this_app, current_path, filename));
 
462
    }
 
463
    else
 
464
    {
 
465
        open.setAttribute("class", "disabled");
 
466
        open.removeAttribute("title");
 
467
        open.removeAttribute("href");
 
468
    }
 
469
 
 
470
    /* Serve */
 
471
    /* Available if exactly one file is selected,
 
472
     * and only if this is a file, not a directory */
 
473
    var serve = document.getElementById("act_serve");
 
474
    if (numsel == 1 && !file.isdir)
 
475
    {
 
476
        serve.setAttribute("class", "choice");
 
477
        serve.setAttribute("href",
 
478
            app_path(serve_app, current_path, filename));
 
479
    }
 
480
    else
 
481
    {
 
482
        serve.setAttribute("class", "disabled");
 
483
        serve.removeAttribute("href");
 
484
    }
 
485
 
 
486
    /* Run */
 
487
    /* Available if exactly one file is selected,
 
488
     * and it is a Python file.
 
489
     */
 
490
    /* TODO */
 
491
 
 
492
    /* Download */
 
493
    /* Always available.
 
494
     * If 0 files selected, download the current file or directory as a ZIP.
 
495
     * If 1 directory selected, download it as a ZIP.
 
496
     * If 1 non-directory selected, download it.
 
497
     * If >1 files selected, download them all as a ZIP.
 
498
     */
 
499
    var download = document.getElementById("act_download");
 
500
    if (numsel <= 1)
 
501
    {
 
502
        if (numsel == 0)
 
503
        {
 
504
            download.setAttribute("href",
 
505
                app_path(download_app, current_path));
 
506
            if (file.isdir)
 
507
                download.setAttribute("title",
 
508
                    "Download the current directory as a ZIP file");
 
509
            else
 
510
                download.setAttribute("title",
 
511
                    "Download the current file");
 
512
        }
 
513
        else
 
514
        {
 
515
            download.setAttribute("href",
 
516
                app_path(download_app, current_path, filename));
 
517
            if (file.isdir)
 
518
                download.setAttribute("title",
 
519
                    "Download the selected directory as a ZIP file");
 
520
            else
 
521
                download.setAttribute("title",
 
522
                    "Download the selected file");
 
523
        }
 
524
    }
 
525
    else
 
526
    {
 
527
        /* Make a query string with all the files to download */
 
528
        var dlpath = urlencode_path(app_path(download_app, current_path)) + "?";
 
529
        for (var i=0; i<numsel; i++)
 
530
            dlpath += "path=" + encodeURIComponent(selected_files[i]) + "&";
 
531
        dlpath = dlpath.substr(0, dlpath.length-1);
 
532
        download.setAttribute("href", dlpath);
 
533
        download.setAttribute("title",
 
534
            "Download the selected files as a ZIP file");
 
535
    }
 
536
 
 
537
    /* Refresh - No changes required */
 
538
 
 
539
    /* Publish and Submit */
 
540
    /* If this directory is under subversion and selected/unselected file is a
 
541
     * directory. */
 
542
    var publish = document.getElementById("act_publish");
 
543
    var submit = document.getElementById("act_submit");
 
544
    if (numsel <= 1 && file.isdir)
 
545
    {
 
546
        /* TODO: Work out of file is svn'd */
 
547
        /* TODO: If this dir is already published, call it "Unpublish" */
 
548
        publish.setAttribute("class", "choice");
 
549
        publish.removeAttribute("disabled");
 
550
        submit.setAttribute("class", "choice");
 
551
        submit.removeAttribute("disabled");
 
552
    }
 
553
    else
 
554
    {
 
555
        publish.setAttribute("class", "disabled");
 
556
        publish.setAttribute("disabled", "disabled");
 
557
        submit.setAttribute("class", "disabled");
 
558
        submit.setAttribute("disabled", "disabled");
 
559
    }
 
560
 
 
561
    /* Share */
 
562
    /* If exactly 1 non-directory file is selected/opened, and its parent
 
563
     * directory is published.
 
564
     */
 
565
    var share = document.getElementById("act_share");
 
566
    if (numsel <= 1 && !file.isdir)
 
567
    {
 
568
        /* TODO: Work out if parent dir is published */
 
569
        share.setAttribute("class", "choice");
 
570
        share.removeAttribute("disabled");
 
571
    }
 
572
    else
 
573
    {
 
574
        share.setAttribute("class", "disabled");
 
575
        share.setAttribute("disabled", "disabled");
 
576
    }
 
577
 
 
578
    /* Rename */
 
579
    /* If exactly 1 file is selected */
 
580
    var rename = document.getElementById("act_rename");
 
581
    if (numsel == 1)
 
582
    {
 
583
        rename.setAttribute("class", "choice");
 
584
        rename.removeAttribute("disabled");
 
585
    }
 
586
    else
 
587
    {
 
588
        rename.setAttribute("class", "disabled");
 
589
        rename.setAttribute("disabled", "disabled");
 
590
    }
 
591
 
 
592
    /* Delete, cut, copy */
 
593
    /* If >= 1 file is selected */
 
594
    var act_delete = document.getElementById("act_delete");
 
595
    var cut = document.getElementById("act_cut");
 
596
    var copy = document.getElementById("act_copy");
 
597
    if (numsel >= 1)
 
598
    {
 
599
        act_delete.setAttribute("class", "choice");
 
600
        act_delete.removeAttribute("disabled");
 
601
        cut.setAttribute("class", "choice");
 
602
        cut.removeAttribute("disabled");
 
603
        copy.setAttribute("class", "choice");
 
604
        copy.removeAttribute("disabled");
 
605
    }
 
606
    else
 
607
    {
 
608
        act_delete.setAttribute("class", "disabled");
 
609
        act_delete.setAttribute("disabled", "disabled");
 
610
        cut.setAttribute("class", "disabled");
 
611
        cut.setAttribute("disabled", "disabled");
 
612
        copy.setAttribute("class", "disabled");
 
613
        copy.setAttribute("disabled", "disabled");
 
614
    }
 
615
 
 
616
    /* Paste, new file, new directory, upload */
 
617
    /* Always enabled (assuming this is a directory) */
 
618
 
 
619
    /* Subversion actions */
 
620
    /* TODO: Work out when these are appropriate */
 
621
    var svnadd = document.getElementById("act_svnadd");
 
622
    var svnrevert = document.getElementById("act_svnrevert");
 
623
    var svncommit = document.getElementById("act_svncommit");
 
624
    if (true)
 
625
    {
 
626
        svnadd.setAttribute("class", "choice");
 
627
        svnadd.removeAttribute("disabled");
 
628
        svnrevert.setAttribute("class", "choice");
 
629
        svnrevert.removeAttribute("disabled");
 
630
        svncommit.setAttribute("class", "choice");
 
631
        svncommit.removeAttribute("disabled");
 
632
    }
 
633
 
 
634
    return;
 
635
}
 
636
 
 
637
/** Event handler for when an item of the "More actions..." dropdown box is
 
638
 * selected. Performs the selected action. */
 
639
function handle_moreactions()
 
640
{
 
641
    var moreactions = document.getElementById("moreactions");
 
642
    if (moreactions.value == "top")
 
643
        return;
 
644
    var selectedaction = moreactions.value;
 
645
    /* Reset to "More actions..." */
 
646
    moreactions.selectedIndex = 0;
 
647
 
 
648
    /* If 0 files selected, filename is the name of the current dir.
 
649
     * If 1 file selected, filename is that file.
 
650
     */
 
651
    if (selected_files.length == 0)
 
652
        filename = path_basename(current_path);
 
653
    else if (selected_files.length == 1)
 
654
        filename = selected_files[0];
 
655
    else
 
656
        filename = null;
 
657
 
 
658
    /* Now handle the selected action */
 
659
    switch(selectedaction)
 
660
    {
 
661
    case "publish":
 
662
        action_publish(selected_files);
 
663
        break;
 
664
    case "unpublish":
 
665
        action_unpublish(selected_files);
 
666
        break;
 
667
    case "share":
 
668
        // TODO
 
669
        alert("Not yet implemented: Sharing files");
 
670
        break;
 
671
    case "submit":
 
672
        // TODO
 
673
        alert("Not yet implemented: Submit");
 
674
        break;
 
675
    case "rename":
 
676
        action_rename(filename);
 
677
        break;
 
678
    case "delete":
 
679
        action_remove(selected_files);
 
680
        break;
 
681
    case "copy":
 
682
        action_copy(selected_files);
 
683
        break;
 
684
    case "cut":
 
685
        action_cut(selected_files);
 
686
        break;
 
687
    case "paste":
 
688
        action_paste();
 
689
        break;
 
690
    case "newfile":
 
691
        action_newfile();
 
692
        break;
 
693
    case "mkdir":
 
694
        action_mkdir();
 
695
        break;
 
696
    case "upload":
 
697
        show_uploadpanel(true);
 
698
        break;
 
699
    case "svnadd":
 
700
        action_add(selected_files);
 
701
        break;
 
702
    case "svnrevert":
 
703
        action_revert(selected_files);
 
704
        break;
 
705
    case "svncommit":
 
706
        action_commit(selected_files);
 
707
        break;
 
708
    }
 
709
}
 
710
 
430
711
/** Called when the page loads initially.
431
712
 */
432
713
window.onload = function()
438
719
    var path = parse_url(window.location.href).path;
439
720
    /* Strip out root_dir + "/files" from the front of the path */
440
721
    var strip = make_path(this_app);
441
 
    var editmode = false;
442
722
    if (path.substr(0, strip.length) == strip)
443
723
        path = path.substr(strip.length+1);
444
724
    else
448
728
        if (path.substr(0, strip.length) == strip)
449
729
        {
450
730
            path = path.substr(strip.length+1);
451
 
            editmode = true;
452
731
        }
453
732
    }
454
733
 
459
738
        path = username;
460
739
    }
461
740
 
462
 
    navigate(path, editmode);
 
741
    navigate(path);
463
742
}