~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-07-21 14:02:47 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:925
Added "groups" app. No code within the app just yet.
    (Has help, icons, template CSS and Javascript, etc).

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
    }
250
241
        return;
251
242
    }
252
243
 
253
 
    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
 
    var top_level_dir = path==username;
258
 
    if (top_level_dir)
259
 
    {
260
 
        var req = ajax_call(null, "userservice", "get_enrolments", null, "GET")
261
 
        subjects = decode_response(req);
262
 
    }
263
 
 
264
 
 
265
244
    /* This will always return a listing, whether it is a dir or a file.
266
245
     */
267
246
    var listing = response.responseText;
319
298
    var isdir = response.getResponseHeader("X-IVLE-Return") == "Dir";
320
299
    if (isdir)
321
300
    {
322
 
        setup_for_listing();
323
 
        if (top_level_dir)
324
 
        {
325
 
            /* Top-level dir, with subjects */
326
 
            special_home_listing(listing, subjects, path);
327
 
        }
 
301
        handle_dir_listing(path, listing);
 
302
    }
 
303
    else
 
304
    {
 
305
        /* Need to make a 2nd ajax call, this time get the actual file
 
306
         * contents */
 
307
        callback = function(response)
 
308
            {
 
309
                /* Read the response and set up the page accordingly */
 
310
                handle_contents_response(path, response);
 
311
            }
 
312
        /* Call the server and request the listing. */
 
313
        if (url_args)
 
314
            args = shallow_clone_object(url_args);
328
315
        else
329
 
        {
330
 
            /* Not the top-level dir. Do a normal dir listing. */
331
 
            handle_dir_listing(path, listing.listing);
332
 
        }
333
 
    }
334
 
    else
335
 
    {
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
 
 
 
316
            args = {};
 
317
        /* This time, get the contents of the file, not its metadata */
 
318
        args['return'] = "contents";
 
319
        ajax_call(callback, service_app, path, args, "GET");
340
320
    }
341
321
    update_actions(isdir);
342
322
}
343
323
 
344
 
function handle_contents_response(path, content_type)
 
324
function handle_contents_response(path, response)
345
325
{
346
326
    /* Treat this as an ordinary file. Get the file type. */
347
 
    //var content_type = response.getResponseHeader("Content-Type");
 
327
    var content_type = response.getResponseHeader("Content-Type");
348
328
    var handler_type = get_handler_type(content_type);
 
329
    would_be_handler_type = handler_type;
349
330
    /* handler_type should now be set to either
350
 
     * "text", "image", "video", "audio" or "binary". */
 
331
     * "text", "image", "audio" or "binary". */
351
332
    switch (handler_type)
352
333
    {
353
334
    case "text":
354
 
        handle_text(path, content_type);
 
335
        handle_text(path, response.responseText,
 
336
            would_be_handler_type);
355
337
        break;
356
338
    case "image":
357
 
        handle_image(path);
358
 
        break;
359
 
    case "video":
360
 
        handle_html5_media(path, content_type, "video");
 
339
        /* TODO: Custom image handler */
 
340
        handle_binary(path, response.responseText);
361
341
        break;
362
342
    case "audio":
363
 
        handle_html5_media(path, content_type, "audio");
364
 
        break;
365
 
    case "object":
366
 
        handle_object(path, content_type);
 
343
        /* TODO: Custom audio handler */
 
344
        handle_binary(path, response.responseText);
367
345
        break;
368
346
    case "binary":
369
347
        handle_binary(path);
389
367
    upload_callback_count++;
390
368
    if (upload_callback_count >= 2)
391
369
    {
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
370
        document.getElementsByName('data')[0].value = '';
403
371
        refresh();
404
372
    }
421
389
function maybe_save(warning)
422
390
{
423
391
    if (warning == null) warning = '';
424
 
    if (current_file == null || current_file.isdir) return true;
 
392
    if (current_file.isdir) return true;
425
393
    if (document.getElementById("save_button").disabled) return true;
426
394
    return confirm("This file has unsaved changes. " + warning +
427
395
                   "\nAre you sure you wish to continue?");
524
492
        return default_svn_nice;
525
493
}
526
494
 
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
495
/** Displays a download link to the binary file.
535
496
 */
536
497
function handle_binary(path)
537
498
{
538
 
    // Disable save button
539
 
    using_codepress = false;
540
 
    disable_save();
541
 
 
542
 
    // Show download link
543
499
    var files = document.getElementById("filesbody");
544
500
    var div = document.createElement("div");
545
501
    files.appendChild(div);
546
502
    div.setAttribute("class", "padding");
547
 
    var download_link = app_url(download_app, path);
 
503
    var download_link = app_path(download_app, path);
548
504
    var par1 = dom_make_text_elem("p",
549
505
        "The file " + path + " is a binary file. To download this file, " +
550
506
        "click the following link:");
554
510
    div.appendChild(par2);
555
511
}
556
512
 
557
 
/** Displays an image file.
558
 
 */
559
 
function handle_image(path)
560
 
{
561
 
    /* Disable save button */
562
 
    using_codepress = false;
563
 
    disable_save();
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 media file using an HTML5 <audio> or <video> tag.
581
 
 * Falls back to <object> if the format is unsupported.
582
 
 */
583
 
function handle_html5_media(path, type, tag_name)
584
 
{
585
 
    /* Disable save button and hide the save panel */
586
 
    using_codepress = false;
587
 
    disable_save();
588
 
 
589
 
    /* URL */
590
 
    var url = app_url(service_app, path) + "?return=contents";
591
 
    var download_url = app_url(download_app, path);
592
 
 
593
 
    /* Fallback download link */
594
 
    var link = $(
595
 
        '<p>Could not play ' + tag_name + ' file. ' +
596
 
        'Try <a>downloading it</a> instead.</p>');
597
 
    link.find('a').attr("href", download_url);
598
 
 
599
 
    /* HTML 5 media element */
600
 
    var html5_element = $(
601
 
        '<' + tag_name + ' controls="true" autoplay="true" />');
602
 
    html5_element.attr("src", url);
603
 
    var support = (html5_element[0].canPlayType &&
604
 
                   html5_element[0].canPlayType(type));
605
 
 
606
 
    /* If the browser thinks it might be able to play it, use the HTML5
607
 
     * element. Otherwise, fall back to an <object>, which might work.
608
 
     */
609
 
    if (support == "probably" || support == "maybe") {
610
 
        var element = html5_element;
611
 
    } else {
612
 
        var element = $('<object />');
613
 
        element.attr("type", type);
614
 
        element.attr("data", url);
615
 
    }
616
 
    element.append(link);
617
 
 
618
 
    /* Show Preview */
619
 
    var div = $('<div class="padding" />');
620
 
    div.append('<h1>File preview</h1>');
621
 
    div.append(element);
622
 
    $("#filesbody").append(div);
623
 
}
624
 
 
625
 
/** Display generic object content
626
 
 */
627
 
function handle_object(path, content_type)
628
 
{
629
 
    /* Disable save button and hide the save panel */
630
 
    using_codepress = false;
631
 
    disable_save();
632
 
 
633
 
    /* URL */
634
 
    var url = app_url(service_app, path) + "?return=contents";
635
 
    var download_url = app_url(download_app, path);
636
 
 
637
 
    /* Fallback Download Link */
638
 
    var link = $('<p><a /></p>');
639
 
    var a = link.find('a');
640
 
    a.attr("href", download_url);
641
 
    a.text("Download " + path);
642
 
 
643
 
    /* Object Tag */
644
 
    var obj = $('<object width="100%" height="500px" />');
645
 
    obj.attr("type", content_type);
646
 
    obj.attr("data", url);
647
 
    obj.append('Could not load object');
648
 
 
649
 
    /* Show Preview */
650
 
    var div = $('<div class="padding" />');
651
 
    div.append('<h1>Preview</h1>');
652
 
    div.append(obj);
653
 
    div.append(link);
654
 
    $("#filesbody").append(div);
655
 
}
656
 
 
657
 
/* Present an element for the given path.
658
 
 * Gives it a title and download link.
659
 
 */
660
 
function present_custom_handler(path, type, element)
661
 
{
662
 
    /* Disable save button and hide the save panel */
663
 
    using_codepress = false;
664
 
    disable_save();
665
 
 
666
 
    /* URL */
667
 
    var url = app_url(service_app, path) + "?return=contents";
668
 
    var download_url = app_url(download_app, path);
669
 
 
670
 
    /* Fallback download link */
671
 
    var link = $(
672
 
        '<p>Could not play ' + tag_name + ' file. ' +
673
 
        'Try <a>downloading it</a> instead.</p>');
674
 
    link.find('a').attr("href", download_url);
675
 
 
676
 
    /* HTML 5 media element */
677
 
    var html5_element = $(
678
 
        '<' + tag_name + ' controls="true" autoplay="true" />');
679
 
    html5_element.attr("src", url);
680
 
    var support = (html5_element[0].canPlayType &&
681
 
                   html5_element[0].canPlayType(type));
682
 
 
683
 
    /* If the browser thinks it might be able to play it, use the HTML5
684
 
     * element. Otherwise, fall back to an <object>, which might work.
685
 
     */
686
 
    if (support == "probably" || support == "maybe") {
687
 
        var element = html5_element;
688
 
    } else {
689
 
        var element = $('<object />');
690
 
        element.attr("type", type);
691
 
        element.attr("data", url);
692
 
    }
693
 
    element.append(link);
694
 
 
695
 
    /* Show Preview */
696
 
    var div = $('<div class="padding" />');
697
 
    div.append('<h1>File preview</h1>');
698
 
    div.append(element);
699
 
    $("#filesbody").append(div);
700
 
}
701
 
 
702
513
/* Enable or disable actions1 moreactions actions. Takes either a single
703
514
 * name, or an array of them.*/
704
515
function set_action_state(names, which, allow_on_revision)
724
535
    }
725
536
}
726
537
 
727
 
/* Updates the list of available actions based on files selected */
728
538
function update_actions()
729
539
{
730
540
    var file;
731
541
    var numsel = selected_files.length;
732
 
    var svn_selection = false;
733
 
    
734
 
    if (numsel > 0)
735
 
    {
736
 
        svn_selection = true;
737
 
        for (var i = 0; i < selected_files.length; i++){
738
 
            if (!svnstatus_versioned(file_listing[selected_files[i]].svnstatus))
739
 
            {
740
 
                svn_selection = false;
741
 
            }
742
 
        }
743
 
    }
744
 
    
745
542
    if (numsel <= 1)
746
543
    {
747
544
        if (numsel == 0)
794
591
              "return maybe_save('The last saved version will be served.')");
795
592
        if (numsel == 0)
796
593
            serve.setAttribute("href",
797
 
                app_url(serve_app, current_path));
 
594
                app_path(serve_app, current_path));
798
595
        else
799
596
            serve.setAttribute("href",
800
 
                app_url(serve_app, current_path, filename));
 
597
                app_path(serve_app, current_path, filename));
801
598
    }
802
599
    else
803
600
    {
812
609
     */
813
610
    var run = document.getElementById("act_run");
814
611
     
815
 
    if (numsel <= 1 && !file.isdir && file.type == "text/x-python" 
816
 
            && current_file.svnstatus != 'revision')
 
612
    if (!file.isdir && file.type == "text/x-python" && numsel <= 1
 
613
        && current_file.svnstatus != 'revision')
817
614
    {
818
615
        if (numsel == 0)
819
616
        {
853
650
        if (numsel == 0)
854
651
        {
855
652
            download.setAttribute("href",
856
 
                app_url(download_app, current_path));
 
653
                app_path(download_app, current_path));
857
654
            if (file.isdir)
858
655
                download.setAttribute("title",
859
656
                    "Download the current directory as a ZIP file");
864
661
        else
865
662
        {
866
663
            download.setAttribute("href",
867
 
                app_url(download_app, current_path, filename));
 
664
                app_path(download_app, current_path, filename));
868
665
            if (file.isdir)
869
666
                download.setAttribute("title",
870
667
                    "Download the selected directory as a ZIP file");
876
673
    else
877
674
    {
878
675
        /* Make a query string with all the files to download */
879
 
        var dlpath = app_url(download_app, current_path) + "?";
 
676
        var dlpath = urlencode_path(app_path(download_app, current_path)) + "?";
880
677
        for (var i=0; i<numsel; i++)
881
678
            dlpath += "path=" + encodeURIComponent(selected_files[i]) + "&";
882
679
        dlpath = dlpath.substr(0, dlpath.length-1);
896
693
    var pubcond = numsel <= 1 && file.isdir;
897
694
    if (pubcond)
898
695
    {
 
696
        /* TODO: Work out of file is svn'd */
899
697
        /* If this dir is already published, call it "Unpublish" */
900
698
        if (file.published)
901
699
        {
902
700
            publish.setAttribute("value", "unpublish");
903
701
            publish.setAttribute("title" ,"Make it so this directory "
904
702
                + "can not be seen by anyone on the web");
905
 
            publish.firstChild.nodeValue = "Unpublish";
 
703
            publish.textContent = "Unpublish";
906
704
        } else {
907
705
            publish.setAttribute("value", "publish");
908
706
            publish.setAttribute("title","Make it so this directory "
909
707
                + "can be seen by anyone on the web");
910
 
            publish.firstChild.nodeValue = "Publish";
 
708
            publish.textContent = "Publish";
911
709
        }
912
710
    }
913
711
    set_action_state(["publish", "submit"], pubcond);
934
732
    /* Subversion actions */
935
733
    /* These are only useful if we are in a versioned directory and have some
936
734
     * files selected. */
937
 
    set_action_state(["svnrename"], numsel == 1 && current_file.svnstatus);
938
 
    set_action_state(["svnadd"], numsel >= 1 && current_file.svnstatus);
939
 
    /* And these are only useful is ALL the selected files are versioned */
940
 
    set_action_state(["svnremove", "svnrevert", "svncopy", "svncut"],
941
 
            numsel >= 1 && current_file.svnstatus && svn_selection);
942
 
    /* Commit is useful if ALL selected files are versioned, or the current
943
 
     * directory is versioned */
944
 
    set_action_state(["svncommit"], current_file.svnstatus &&
945
 
            (numsel >= 1 && svn_selection || numsel == 0));
 
735
    set_action_state(["svnadd", "svnremove", "svnrevert", "svncommit"], numsel >= 1 && current_file.svnstatus);
946
736
 
947
737
    /* Diff, log and update only support one path at the moment, so we must
948
738
     * have 0 or 1 versioned files selected. If 0, the directory must be
951
741
         (
952
742
          (numsel == 1 && (svnst = file_listing[selected_files[0]].svnstatus)) ||
953
743
          (numsel == 0 && (svnst = current_file.svnstatus))
954
 
         ) && svnstatus_versioned(svnst));
 
744
         ) && svnst != "unversioned");
955
745
    set_action_state(["svndiff", "svnupdate"], single_versioned_path);
956
746
 
957
747
    /* We can resolve if we have a file selected and it is conflicted. */
960
750
    /* Log should be available for revisions as well. */
961
751
    set_action_state("svnlog", single_versioned_path, true);
962
752
 
963
 
    /* Cleanup should be available for revisions as well. */
964
 
    set_action_state("svncleanup", single_versioned_path, true);
965
 
 
966
 
    single_ivle_versioned_path = (
967
 
         (
968
 
          (numsel == 1 && (stat = file_listing[selected_files[0]])) ||
969
 
          (numsel == 0 && (stat = current_file))
970
 
         ) && svnstatus_versioned(stat.svnstatus)
971
 
           && stat.svnurl
972
 
           && stat.svnurl.substr(0, svn_base.length) == svn_base);
973
 
    set_action_state(["submit"], single_ivle_versioned_path);
 
753
    /* current_path == username: We are at the top level */
 
754
    set_action_state("svncheckout", current_path == username);
974
755
 
975
756
    /* There is currently nothing on the More Actions menu of use
976
757
     * when the current file is not a directory. Hence, just remove
986
767
        var moreactions = document.getElementById("moreactions_area");
987
768
        moreactions.setAttribute("style", "display: inline;");
988
769
    }
 
770
    else
 
771
    {
 
772
        var actions2_file = document.getElementById("actions2_file");
 
773
        actions2_file.setAttribute("style", "display: inline;");
 
774
    }
989
775
 
990
776
    return;
991
777
}
1021
807
        action_unpublish(selected_files);
1022
808
        break;
1023
809
    case "share":
1024
 
        window.open(public_app_url("~" + current_path, filename), 'share')
 
810
        //alert("Not yet implemented: Sharing files");
 
811
        window.open(public_app_path(serve_app, current_path, filename), 'share')
1025
812
        break;
1026
813
    case "submit":
1027
 
        if (selected_files.length == 1)
1028
 
            stat = file_listing[selected_files[0]];
1029
 
        else
1030
 
            stat = current_file;
1031
 
        url = stat.svnurl.substr(svn_base.length);      // URL-encoded
1032
 
        path = decodeURIComponent(url);
1033
 
 
1034
 
        /* The working copy might not have an up-to-date version of the
1035
 
         * directory. While submitting like this could yield unexpected
1036
 
         * results, we should really submit the latest revision to minimise
1037
 
         * terrible mistakes - so we run off and ask fileservice for the
1038
 
         * latest revision.*/
1039
 
        $.post(app_path(service_app, current_path),
1040
 
            {"action": "svnrepostat", "path": path},
1041
 
            function(result)
1042
 
            {
1043
 
                window.location = path_join(app_path('+submit'), url) + '?revision=' + result.svnrevision;
1044
 
            },
1045
 
            "json");
1046
 
 
 
814
        // TODO
 
815
        alert("Not yet implemented: Submit");
1047
816
        break;
1048
817
    case "rename":
1049
818
        action_rename(filename);
1073
842
        action_add(selected_files);
1074
843
        break;
1075
844
    case "svnremove":
1076
 
        action_svnremove(selected_files);
1077
 
        break;
1078
 
    case "svnrename":
1079
 
        action_svnrename(selected_files);
 
845
        action_remove(selected_files);
1080
846
        break;
1081
847
    case "svnrevert":
1082
848
        action_revert(selected_files);
1083
849
        break;
1084
850
    case "svndiff":
1085
 
        window.location = path_join(app_url('diff'), current_path, selected_files[0] || '');
 
851
        window.location = path_join(app_path('diff'), current_path, selected_files[0] || '');
1086
852
        break;
1087
853
    case "svnupdate":
1088
854
        action_update(selected_files);
1094
860
        action_commit(selected_files);
1095
861
        break;
1096
862
    case "svnlog":
1097
 
        window.location = path_join(app_url('svnlog'), current_path, selected_files[0] || '');
1098
 
        break;
1099
 
    case "svncopy":
1100
 
        action_svncopy(selected_files);
1101
 
        break;
1102
 
    case "svncut":
1103
 
        action_svncut(selected_files);
1104
 
        break;
1105
 
    case "svncleanup":
1106
 
        action_svncleanup(".");
 
863
        window.location = path_join(app_path('svnlog'), current_path, selected_files[0] || '');
 
864
        break;
 
865
    case "svncheckout":
 
866
        action_checkout();
1107
867
        break;
1108
868
    }
1109
869
}
1132
892
     * This causes the page to be populated with whatever is at that address,
1133
893
     * whether it be a directory or a file.
1134
894
     */
1135
 
    var path = get_path();
1136
 
    navigate(path);
1137
 
}
1138
 
 
1139
 
/** Gets the current path of the window */
1140
 
function get_path() {
1141
895
    var path = parse_url(window.location.href).path;
1142
896
    /* Strip out root_dir + "/files" from the front of the path */
1143
897
    var strip = make_path(this_app);
1160
914
        path = username;
1161
915
    }
1162
916
 
1163
 
    return path;
 
917
    navigate(path);
1164
918
}