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

« back to all changes in this revision

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

  • Committer: me at id
  • Date: 2009-01-15 05:53:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1161
bin/ivle-showenrolment: Switch to ivle.database.User.enrolments from
    ivle.db.get_enrolment, removing the dependency on ivle.db.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 * "text" : When navigating to a text file, the text editor is opened.
32
32
 * "image" : When navigating to an image, the image is displayed (rather than
33
33
 *              going to the text editor).
34
 
 * "video" : When navigation to a video file, a "play" button is presented.
35
34
 * "audio" : When navigating to an audio file, a "play" button is presented.
36
35
 * "binary" : When navigating to a binary file, offer it as a download through
37
36
 *              "serve".
44
43
    "application/x-javascript" : "text",
45
44
    "application/javascript" : "text",
46
45
    "application/json" : "text",
47
 
    "application/xml" : "text",
48
 
    "application/ogg" : "audio",
49
 
    "image/svg+xml": "object"
 
46
    "application/xml" : "text"
50
47
};
51
48
 
52
49
/* Mapping MIME types to icons, just the file's basename */
58
55
default_type_icon = "txt.png";
59
56
 
60
57
/* Relative to IVLE root */
61
 
type_icons_path = "+media/ivle.webapp.core/images/mime";
62
 
type_icons_path_large = "+media/ivle.webapp.core/images/mime/large";
 
58
type_icons_path = "media/images/mime";
 
59
type_icons_path_large = "media/images/mime/large";
63
60
 
64
61
/* Mapping SVN status to icons, just the file's basename */
65
62
svn_icons = {
66
 
    "unversioned": "unversioned.png",
67
 
    "ignored": null,                    /* Supposed to be innocuous */
 
63
    "unversioned": null,
68
64
    "normal": "normal.png",
69
65
    "added": "added.png",
70
66
    "missing": "missing.png",
71
67
    "deleted": "deleted.png",
72
 
    "replaced": "replaced.png",
73
68
    "modified": "modified.png",
74
69
    "conflicted": "conflicted.png",
75
70
    "revision": "revision.png"
78
73
/* Mapping SVN status to "nice" strings */
79
74
svn_nice = {
80
75
    "unversioned": "Temporary file",
81
 
    "ignored": "Temporary file (ignored)",
82
76
    "normal": "Permanent file",
83
77
    "added": "Temporary file (scheduled to be added)",
84
78
    "missing": "Permanent file (missing)",
93
87
default_svn_icon = null;
94
88
default_svn_nice = "Unknown status";
95
89
 
96
 
svn_icons_path = "+media/ivle.webapp.core/images/svn";
 
90
svn_icons_path = "media/images/svn";
97
91
 
98
 
published_icon = "+media/ivle.webapp.core/images/interface/published.png";
 
92
published_icon = "media/images/interface/published.png";
99
93
 
100
94
/* List of MIME types considered "executable" by the system.
101
95
 * Executable files offer a "run" link, implying that the "serve"
140
134
 *      May be "application/x-www-form-urlencoded" or "multipart/form-data".
141
135
 *      Defaults to "application/x-www-form-urlencoded".
142
136
 *      "multipart/form-data" is recommended for large uploads.
143
 
 * \param callback, optional.
144
 
 *      A callback function for after the action has been handled.
145
137
 */
146
 
function do_action(action, path, args, content_type, callback)
 
138
function do_action(action, path, args, content_type, ignore_response)
147
139
{
148
140
    args.action = action;
149
141
    /* Callback action, when the server returns */
150
 
    var callback_inner = function(response)
 
142
    var callback = function(response)
151
143
        {
152
144
            /* Check for action errors reported by the server, and report them
153
145
             * to the user */
154
146
            var error = response.getResponseHeader("X-IVLE-Action-Error");
155
 
            if (error != null && error != "")
 
147
            if (error != null)
156
148
                /* Note: This header (in particular) comes URI-encoded, to
157
149
                 * allow multi-line error messages. Decode */
158
150
                alert("Error: " + decodeURIComponent(error.toString()) + ".");
159
151
            /* Now read the response and set up the page accordingly */
160
 
            if (callback != null)
161
 
                callback(path, response);
 
152
            if (ignore_response != true)
 
153
                handle_response(path, response, true);
162
154
        }
163
155
    /* Call the server and perform the action. This mutates the server. */
164
 
    ajax_call(callback_inner, service_app, path, args, "POST", content_type);
 
156
    ajax_call(callback, service_app, path, args, "POST", content_type);
165
157
}
166
158
 
167
159
/** Calls the server using Ajax, requesting a directory listing. This should
196
188
}
197
189
 
198
190
/** Determines the "handler type" from a MIME type.
199
 
 * The handler type is a string, either "text", "image", "video", "audio", 
200
 
 * "object" or "binary".
 
191
 * The handler type is a string, either "text", "image", "audio" or "binary".
201
192
 */
202
193
function get_handler_type(content_type)
203
194
{
209
200
    {   /* Based on the first part of the MIME type */
210
201
        var handler_type = content_type.split('/')[0];
211
202
        if (handler_type != "text" && handler_type != "image" &&
212
 
            handler_type != "video" && handler_type != "audio")
 
203
            handler_type != "audio")
213
204
            handler_type = "binary";
214
205
        return handler_type;
215
206
    }
251
242
    }
252
243
 
253
244
    var subjects = null;
254
 
    /* Remove trailing slash (or path==username won't compare properly) */
255
 
    if (path[path.length-1] == "/")
256
 
        path = path.substr(0, path.length-1);
257
245
    var top_level_dir = path==username;
258
246
    if (top_level_dir)
259
247
    {
320
308
    if (isdir)
321
309
    {
322
310
        setup_for_listing();
323
 
        if (top_level_dir)
324
 
        {
325
 
            /* Top-level dir, with subjects */
326
 
            special_home_listing(listing, subjects, path);
327
 
        }
328
 
        else
329
 
        {
330
 
            /* Not the top-level dir. Do a normal dir listing. */
331
 
            handle_dir_listing(path, listing.listing);
332
 
        }
 
311
        home_listing(listing, subjects, path);
333
312
    }
334
313
    else
335
314
    {
336
 
        /* Read the response and set up the page accordingly */
337
 
        var content_type = current_file.type;
338
 
        handle_contents_response(path, content_type, url_args);
339
 
 
 
315
        /* Need to make a 2nd ajax call, this time get the actual file
 
316
         * contents */
 
317
        callback = function(response)
 
318
            {
 
319
                /* Read the response and set up the page accordingly */
 
320
                handle_contents_response(path, response);
 
321
            }
 
322
        /* Call the server and request the listing. */
 
323
        if (url_args)
 
324
            args = shallow_clone_object(url_args);
 
325
        else
 
326
            args = {};
 
327
        /* This time, get the contents of the file, not its metadata */
 
328
        args['return'] = "contents";
 
329
        ajax_call(callback, service_app, path, args, "GET");
340
330
    }
341
331
    update_actions(isdir);
342
332
}
343
333
 
344
 
function handle_contents_response(path, content_type)
 
334
function handle_contents_response(path, response)
345
335
{
346
336
    /* Treat this as an ordinary file. Get the file type. */
347
 
    //var content_type = response.getResponseHeader("Content-Type");
 
337
    var content_type = response.getResponseHeader("Content-Type");
348
338
    var handler_type = get_handler_type(content_type);
 
339
    would_be_handler_type = handler_type;
349
340
    /* handler_type should now be set to either
350
 
     * "text", "image", "video", "audio" or "binary". */
 
341
     * "text", "image", "audio" or "binary". */
351
342
    switch (handler_type)
352
343
    {
353
344
    case "text":
354
 
        handle_text(path, content_type);
 
345
        handle_text(path, response.responseText,
 
346
            would_be_handler_type);
355
347
        break;
356
348
    case "image":
357
 
        handle_image(path);
358
 
        break;
359
 
    case "video":
360
 
        handle_video(path, content_type);
 
349
        /* TODO: Custom image handler */
 
350
        handle_binary(path, response.responseText);
361
351
        break;
362
352
    case "audio":
363
 
        handle_audio(path, content_type);
364
 
        break;
365
 
    case "object":
366
 
        handle_object(path, content_type);
 
353
        /* TODO: Custom audio handler */
 
354
        handle_binary(path, response.responseText);
367
355
        break;
368
356
    case "binary":
369
357
        handle_binary(path);
389
377
    upload_callback_count++;
390
378
    if (upload_callback_count >= 2)
391
379
    {
392
 
        myFrame = frames['upload_iframe'].document;
393
 
        /* Browsers will turn the raw returned JSON into an HTML document. We
394
 
         * need to get the <pre> from inside the <body>, and look at its text.
395
 
         */
396
 
        var pre = myFrame.firstChild.getElementsByTagName(
397
 
            'body')[0].firstChild;
398
 
        var data = pre.innerText || pre.textContent;
399
 
        data = JSON.parse(data);
400
 
        if ('Error' in data)
401
 
            alert("Error: " + decodeURIComponent(data['Error']));
402
380
        document.getElementsByName('data')[0].value = '';
403
381
        refresh();
404
382
    }
421
399
function maybe_save(warning)
422
400
{
423
401
    if (warning == null) warning = '';
424
 
    if (current_file == null || current_file.isdir) return true;
 
402
    if (current_file.isdir) return true;
425
403
    if (document.getElementById("save_button").disabled) return true;
426
404
    return confirm("This file has unsaved changes. " + warning +
427
405
                   "\nAre you sure you wish to continue?");
524
502
        return default_svn_nice;
525
503
}
526
504
 
527
 
/** Returns true if a file is versioned (not unversioned or ignored).
528
 
 */
529
 
function svnstatus_versioned(svnstatus)
530
 
{
531
 
    return svnstatus != "unversioned" && svnstatus != "ignored";
532
 
}
533
 
 
534
505
/** Displays a download link to the binary file.
535
506
 */
536
507
function handle_binary(path)
537
508
{
538
 
    // Disable save button
539
 
    using_codepress = false;
540
 
    disable_save_if_safe();
541
 
 
542
 
    // Show download link
543
509
    var files = document.getElementById("filesbody");
544
510
    var div = document.createElement("div");
545
511
    files.appendChild(div);
546
512
    div.setAttribute("class", "padding");
547
 
    var download_link = app_url(download_app, path);
 
513
    var download_link = app_path(download_app, path);
548
514
    var par1 = dom_make_text_elem("p",
549
515
        "The file " + path + " is a binary file. To download this file, " +
550
516
        "click the following link:");
554
520
    div.appendChild(par2);
555
521
}
556
522
 
557
 
/** Displays an image file.
558
 
 */
559
 
function handle_image(path)
560
 
{
561
 
    /* Disable save button */
562
 
    using_codepress = false;
563
 
    disable_save_if_safe();
564
 
 
565
 
    /* URL */
566
 
    var url = app_url(service_app, path) + "?return=contents";
567
 
 
568
 
    /* Image Preview */
569
 
    var img = $("<img />");
570
 
    img.attr("alt", path);
571
 
    img.attr("src", url);
572
 
 
573
 
    /* Show Preview */
574
 
    var div = $('<div class="padding" />');
575
 
    div.append('<h1>Image Preview</h1>');
576
 
    div.append(img);
577
 
    $("#filesbody").append(div);
578
 
}
579
 
 
580
 
/** Displays a video.
581
 
 */
582
 
function handle_video(path, type)
583
 
{
584
 
    /* Disable save button and hide the save panel */
585
 
    using_codepress = false;
586
 
    disable_save_if_safe();
587
 
 
588
 
    /* URL */
589
 
    var url = app_url(service_app, path) + "?return=contents";
590
 
    var download_url = app_url(download_app, path);
591
 
 
592
 
    /* Fallback Download Link */
593
 
    var link = $('<p>Could not display video in browser.<p><p><a /></p>');
594
 
    var a = link.find('a');
595
 
    a.attr("href", download_url);
596
 
    a.text("Download " + path);
597
 
 
598
 
    /* Fallback Object Tag */
599
 
    var obj = $('<object />');
600
 
    obj.attr("type", type);
601
 
    obj.attr("data", url);
602
 
    obj.append(link);
603
 
 
604
 
    /* HTML 5 Video Tag */
605
 
    var video = $('<video controls="true" autoplay="true" />');
606
 
    video.attr("src", url);
607
 
    var support = video[0].canPlayType && video[0].canPlayType(type);
608
 
    if (support != "probably" && support != "maybe") {
609
 
        // Use Fallback
610
 
        video = obj;
611
 
    }
612
 
 
613
 
    /* Show Preview */
614
 
    var div = $('<div class="padding" />');
615
 
    div.append('<h1>Video Preview</h1>');
616
 
    div.append(video);
617
 
    $("#filesbody").append(div);
618
 
}
619
 
 
620
 
/** Display audio content
621
 
 */
622
 
function handle_audio(path, type)
623
 
{
624
 
    /* Disable save button and hide the save panel */
625
 
    using_codepress = false;
626
 
    disable_save_if_safe();
627
 
 
628
 
    /* URL */
629
 
    var url = app_url(service_app, path) + "?return=contents";
630
 
    var download_url = app_url(download_app, path);
631
 
 
632
 
    /* Fallback Download Link */
633
 
    var link = $('<p>Could not display audio in browser.<p><p><a /></p>');
634
 
    var a = link.find('a');
635
 
    a.attr("href", download_url);
636
 
    a.text("Download " + path);
637
 
 
638
 
    /* Fallback Object Tag */
639
 
    var obj = $('<object />');
640
 
    obj.attr("type", type);
641
 
    obj.attr("data", url);
642
 
    obj.append(link);
643
 
 
644
 
    /* HTML 5 Audio Tag */
645
 
    var audio = $('<audio controls="true" autoplay="true" />');
646
 
    audio.attr("src", url);
647
 
    var support = audio[0].canPlayType && audio[0].canPlayType(type);
648
 
    if (support != "probably" && support != "maybe") {
649
 
        // Use Fallback
650
 
        audio = obj;
651
 
    }
652
 
 
653
 
    /* Show Preview */
654
 
    var div = $('<div class="padding" />');
655
 
    div.append('<h1>Audio Preview</h1>');
656
 
    div.append(audio);
657
 
    $("#filesbody").append(div);
658
 
}
659
 
 
660
 
/** Display generic object content
661
 
 */
662
 
function handle_object(path, content_type)
663
 
{
664
 
    /* Disable save button and hide the save panel */
665
 
    using_codepress = false;
666
 
    disable_save_if_safe();
667
 
 
668
 
    /* URL */
669
 
    var url = app_url(service_app, path) + "?return=contents";
670
 
    var download_url = app_url(download_app, path);
671
 
 
672
 
    /* Fallback Download Link */
673
 
    var link = $('<p><a /></p>');
674
 
    var a = link.find('a');
675
 
    a.attr("href", download_url);
676
 
    a.text("Download " + path);
677
 
 
678
 
    /* Object Tag */
679
 
    var obj = $('<object width="100%" height="500px" />');
680
 
    obj.attr("type", content_type);
681
 
    obj.attr("data", url);
682
 
    obj.append('Could not load object');
683
 
 
684
 
    /* Show Preview */
685
 
    var div = $('<div class="padding" />');
686
 
    div.append('<h1>Preview</h1>');
687
 
    div.append(obj);
688
 
    div.append(link);
689
 
    $("#filesbody").append(div);
690
 
}
691
 
 
692
523
/* Enable or disable actions1 moreactions actions. Takes either a single
693
524
 * name, or an array of them.*/
694
525
function set_action_state(names, which, allow_on_revision)
714
545
    }
715
546
}
716
547
 
717
 
/* Updates the list of available actions based on files selected */
718
548
function update_actions()
719
549
{
720
550
    var file;
721
551
    var numsel = selected_files.length;
722
 
    var svn_selection = false;
723
 
    
724
 
    if (numsel > 0)
725
 
    {
726
 
        svn_selection = true;
727
 
        for (var i = 0; i < selected_files.length; i++){
728
 
            if (!svnstatus_versioned(file_listing[selected_files[i]].svnstatus))
729
 
            {
730
 
                svn_selection = false;
731
 
            }
732
 
        }
733
 
    }
734
 
    
735
552
    if (numsel <= 1)
736
553
    {
737
554
        if (numsel == 0)
784
601
              "return maybe_save('The last saved version will be served.')");
785
602
        if (numsel == 0)
786
603
            serve.setAttribute("href",
787
 
                app_url(serve_app, current_path));
 
604
                app_path(serve_app, current_path));
788
605
        else
789
606
            serve.setAttribute("href",
790
 
                app_url(serve_app, current_path, filename));
 
607
                app_path(serve_app, current_path, filename));
791
608
    }
792
609
    else
793
610
    {
802
619
     */
803
620
    var run = document.getElementById("act_run");
804
621
     
805
 
    if (numsel <= 1 && !file.isdir && file.type == "text/x-python" 
806
 
            && current_file.svnstatus != 'revision')
 
622
    if (!file.isdir && file.type == "text/x-python" && numsel <= 1
 
623
        && current_file.svnstatus != 'revision')
807
624
    {
808
625
        if (numsel == 0)
809
626
        {
843
660
        if (numsel == 0)
844
661
        {
845
662
            download.setAttribute("href",
846
 
                app_url(download_app, current_path));
 
663
                app_path(download_app, current_path));
847
664
            if (file.isdir)
848
665
                download.setAttribute("title",
849
666
                    "Download the current directory as a ZIP file");
854
671
        else
855
672
        {
856
673
            download.setAttribute("href",
857
 
                app_url(download_app, current_path, filename));
 
674
                app_path(download_app, current_path, filename));
858
675
            if (file.isdir)
859
676
                download.setAttribute("title",
860
677
                    "Download the selected directory as a ZIP file");
866
683
    else
867
684
    {
868
685
        /* Make a query string with all the files to download */
869
 
        var dlpath = app_url(download_app, current_path) + "?";
 
686
        var dlpath = urlencode_path(app_path(download_app, current_path)) + "?";
870
687
        for (var i=0; i<numsel; i++)
871
688
            dlpath += "path=" + encodeURIComponent(selected_files[i]) + "&";
872
689
        dlpath = dlpath.substr(0, dlpath.length-1);
886
703
    var pubcond = numsel <= 1 && file.isdir;
887
704
    if (pubcond)
888
705
    {
 
706
        /* TODO: Work out of file is svn'd */
889
707
        /* If this dir is already published, call it "Unpublish" */
890
708
        if (file.published)
891
709
        {
892
710
            publish.setAttribute("value", "unpublish");
893
711
            publish.setAttribute("title" ,"Make it so this directory "
894
712
                + "can not be seen by anyone on the web");
895
 
            publish.firstChild.nodeValue = "Unpublish";
 
713
            publish.textContent = "Unpublish";
896
714
        } else {
897
715
            publish.setAttribute("value", "publish");
898
716
            publish.setAttribute("title","Make it so this directory "
899
717
                + "can be seen by anyone on the web");
900
 
            publish.firstChild.nodeValue = "Publish";
 
718
            publish.textContent = "Publish";
901
719
        }
902
720
    }
903
721
    set_action_state(["publish", "submit"], pubcond);
924
742
    /* Subversion actions */
925
743
    /* These are only useful if we are in a versioned directory and have some
926
744
     * files selected. */
927
 
    set_action_state(["svnrename"], numsel == 1 && current_file.svnstatus);
928
 
    set_action_state(["svnadd"], numsel >= 1 && current_file.svnstatus);
929
 
    /* And these are only useful is ALL the selected files are versioned */
930
 
    set_action_state(["svnremove", "svnrevert", "svncopy", "svncut"],
931
 
            numsel >= 1 && current_file.svnstatus && svn_selection);
932
 
    /* Commit is useful if ALL selected files are versioned, or the current
933
 
     * directory is versioned */
934
 
    set_action_state(["svncommit"], current_file.svnstatus &&
935
 
            (numsel >= 1 && svn_selection || numsel == 0));
 
745
    set_action_state(["svnadd", "svnremove", "svnrevert", "svncommit"], numsel >= 1 && current_file.svnstatus);
936
746
 
937
747
    /* Diff, log and update only support one path at the moment, so we must
938
748
     * have 0 or 1 versioned files selected. If 0, the directory must be
941
751
         (
942
752
          (numsel == 1 && (svnst = file_listing[selected_files[0]].svnstatus)) ||
943
753
          (numsel == 0 && (svnst = current_file.svnstatus))
944
 
         ) && svnstatus_versioned(svnst));
 
754
         ) && svnst != "unversioned");
945
755
    set_action_state(["svndiff", "svnupdate"], single_versioned_path);
946
756
 
947
757
    /* We can resolve if we have a file selected and it is conflicted. */
950
760
    /* Log should be available for revisions as well. */
951
761
    set_action_state("svnlog", single_versioned_path, true);
952
762
 
953
 
    /* Cleanup should be available for revisions as well. */
954
 
    set_action_state("svncleanup", single_versioned_path, true);
955
 
 
956
 
    single_ivle_versioned_path = (
957
 
         (
958
 
          (numsel == 1 && (stat = file_listing[selected_files[0]])) ||
959
 
          (numsel == 0 && (stat = current_file))
960
 
         ) && svnstatus_versioned(stat.svnstatus)
961
 
           && stat.svnurl
962
 
           && stat.svnurl.substr(0, svn_base.length) == svn_base);
963
 
    set_action_state(["submit"], single_ivle_versioned_path);
964
 
 
965
763
    /* There is currently nothing on the More Actions menu of use
966
764
     * when the current file is not a directory. Hence, just remove
967
765
     * it entirely.
976
774
        var moreactions = document.getElementById("moreactions_area");
977
775
        moreactions.setAttribute("style", "display: inline;");
978
776
    }
 
777
    else
 
778
    {
 
779
        var actions2_file = document.getElementById("actions2_file");
 
780
        actions2_file.setAttribute("style", "display: inline;");
 
781
    }
979
782
 
980
783
    return;
981
784
}
1011
814
        action_unpublish(selected_files);
1012
815
        break;
1013
816
    case "share":
1014
 
        window.open(public_app_url("~" + current_path, filename), 'share')
 
817
        //alert("Not yet implemented: Sharing files");
 
818
        window.open(public_app_path(serve_app, current_path, filename), 'share')
1015
819
        break;
1016
820
    case "submit":
1017
 
        if (selected_files.length == 1)
1018
 
            stat = file_listing[selected_files[0]];
1019
 
        else
1020
 
            stat = current_file;
1021
 
        url = stat.svnurl.substr(svn_base.length);      // URL-encoded
1022
 
        path = decodeURIComponent(url);
1023
 
 
1024
 
        /* The working copy might not have an up-to-date version of the
1025
 
         * directory. While submitting like this could yield unexpected
1026
 
         * results, we should really submit the latest revision to minimise
1027
 
         * terrible mistakes - so we run off and ask fileservice for the
1028
 
         * latest revision.*/
1029
 
        $.post(app_path(service_app, current_path),
1030
 
            {"action": "svnrepostat", "path": path},
1031
 
            function(result)
1032
 
            {
1033
 
                window.location = path_join(app_path('+submit'), url) + '?revision=' + result.svnrevision;
1034
 
            },
1035
 
            "json");
1036
 
 
 
821
        // TODO
 
822
        alert("Not yet implemented: Submit");
1037
823
        break;
1038
824
    case "rename":
1039
825
        action_rename(filename);
1063
849
        action_add(selected_files);
1064
850
        break;
1065
851
    case "svnremove":
1066
 
        action_svnremove(selected_files);
1067
 
        break;
1068
 
    case "svnrename":
1069
 
        action_svnrename(selected_files);
 
852
        action_remove(selected_files);
1070
853
        break;
1071
854
    case "svnrevert":
1072
855
        action_revert(selected_files);
1073
856
        break;
1074
857
    case "svndiff":
1075
 
        window.location = path_join(app_url('diff'), current_path, selected_files[0] || '');
 
858
        window.location = path_join(app_path('diff'), current_path, selected_files[0] || '');
1076
859
        break;
1077
860
    case "svnupdate":
1078
861
        action_update(selected_files);
1084
867
        action_commit(selected_files);
1085
868
        break;
1086
869
    case "svnlog":
1087
 
        window.location = path_join(app_url('svnlog'), current_path, selected_files[0] || '');
1088
 
        break;
1089
 
    case "svncopy":
1090
 
        action_svncopy(selected_files);
1091
 
        break;
1092
 
    case "svncut":
1093
 
        action_svncut(selected_files);
1094
 
        break;
1095
 
    case "svncleanup":
1096
 
        action_svncleanup(".");
 
870
        window.location = path_join(app_path('svnlog'), current_path, selected_files[0] || '');
1097
871
        break;
1098
872
    }
1099
873
}
1122
896
     * This causes the page to be populated with whatever is at that address,
1123
897
     * whether it be a directory or a file.
1124
898
     */
1125
 
    var path = get_path();
1126
 
    navigate(path);
1127
 
}
1128
 
 
1129
 
/** Gets the current path of the window */
1130
 
function get_path() {
1131
899
    var path = parse_url(window.location.href).path;
1132
900
    /* Strip out root_dir + "/files" from the front of the path */
1133
901
    var strip = make_path(this_app);
1150
918
        path = username;
1151
919
    }
1152
920
 
1153
 
    return path;
 
921
    navigate(path);
1154
922
}