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

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/browser/media/browser.js

  • Committer: William Grant
  • Date: 2010-02-23 08:48:09 UTC
  • mfrom: (1673 trunk)
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: grantw@unimelb.edu.au-20100223084809-du6dvsxrjhw15ytr
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
/* Mapping SVN status to icons, just the file's basename */
62
62
svn_icons = {
63
63
    "unversioned": "unversioned.png",
 
64
    "ignored": null,                    /* Supposed to be innocuous */
64
65
    "normal": "normal.png",
65
66
    "added": "added.png",
66
67
    "missing": "missing.png",
67
68
    "deleted": "deleted.png",
 
69
    "replaced": "replaced.png",
68
70
    "modified": "modified.png",
69
71
    "conflicted": "conflicted.png",
70
72
    "revision": "revision.png"
73
75
/* Mapping SVN status to "nice" strings */
74
76
svn_nice = {
75
77
    "unversioned": "Temporary file",
 
78
    "ignored": "Temporary file (ignored)",
76
79
    "normal": "Permanent file",
77
80
    "added": "Temporary file (scheduled to be added)",
78
81
    "missing": "Permanent file (missing)",
244
247
    }
245
248
 
246
249
    var subjects = null;
 
250
    /* Remove trailing slash (or path==username won't compare properly) */
 
251
    if (path[path.length-1] == "/")
 
252
        path = path.substr(0, path.length-1);
247
253
    var top_level_dir = path==username;
248
254
    if (top_level_dir)
249
255
    {
310
316
    if (isdir)
311
317
    {
312
318
        setup_for_listing();
313
 
        home_listing(listing, subjects, path);
 
319
        if (top_level_dir)
 
320
        {
 
321
            /* Top-level dir, with subjects */
 
322
            special_home_listing(listing, subjects, path);
 
323
        }
 
324
        else
 
325
        {
 
326
            /* Not the top-level dir. Do a normal dir listing. */
 
327
            handle_dir_listing(path, listing.listing);
 
328
        }
314
329
    }
315
330
    else
316
331
    {
410
425
function maybe_save(warning)
411
426
{
412
427
    if (warning == null) warning = '';
413
 
    if (current_file.isdir) return true;
 
428
    if (current_file == null || current_file.isdir) return true;
414
429
    if (document.getElementById("save_button").disabled) return true;
415
430
    return confirm("This file has unsaved changes. " + warning +
416
431
                   "\nAre you sure you wish to continue?");
513
528
        return default_svn_nice;
514
529
}
515
530
 
 
531
/** Returns true if a file is versioned (not unversioned or ignored).
 
532
 */
 
533
function svnstatus_versioned(svnstatus)
 
534
{
 
535
    return svnstatus != "unversioned" && svnstatus != "ignored";
 
536
}
 
537
 
516
538
/** Displays a download link to the binary file.
517
539
 */
518
540
function handle_binary(path)
521
543
    var div = document.createElement("div");
522
544
    files.appendChild(div);
523
545
    div.setAttribute("class", "padding");
524
 
    var download_link = app_path(download_app, path);
 
546
    var download_link = app_url(download_app, path);
525
547
    var par1 = dom_make_text_elem("p",
526
548
        "The file " + path + " is a binary file. To download this file, " +
527
549
        "click the following link:");
567
589
    {
568
590
        svn_selection = true;
569
591
        for (var i = 0; i < selected_files.length; i++){
570
 
            if (file_listing[selected_files[i]]["svnstatus"] == "unversioned")
 
592
            if (!svnstatus_versioned(file_listing[selected_files[i]].svnstatus))
571
593
            {
572
 
                svn_selection = false;        
 
594
                svn_selection = false;
573
595
            }
574
596
        }
575
597
    }
626
648
              "return maybe_save('The last saved version will be served.')");
627
649
        if (numsel == 0)
628
650
            serve.setAttribute("href",
629
 
                app_path(serve_app, current_path));
 
651
                app_url(serve_app, current_path));
630
652
        else
631
653
            serve.setAttribute("href",
632
 
                app_path(serve_app, current_path, filename));
 
654
                app_url(serve_app, current_path, filename));
633
655
    }
634
656
    else
635
657
    {
685
707
        if (numsel == 0)
686
708
        {
687
709
            download.setAttribute("href",
688
 
                app_path(download_app, current_path));
 
710
                app_url(download_app, current_path));
689
711
            if (file.isdir)
690
712
                download.setAttribute("title",
691
713
                    "Download the current directory as a ZIP file");
696
718
        else
697
719
        {
698
720
            download.setAttribute("href",
699
 
                app_path(download_app, current_path, filename));
 
721
                app_url(download_app, current_path, filename));
700
722
            if (file.isdir)
701
723
                download.setAttribute("title",
702
724
                    "Download the selected directory as a ZIP file");
708
730
    else
709
731
    {
710
732
        /* Make a query string with all the files to download */
711
 
        var dlpath = urlencode_path(app_path(download_app, current_path)) + "?";
 
733
        var dlpath = app_url(download_app, current_path) + "?";
712
734
        for (var i=0; i<numsel; i++)
713
735
            dlpath += "path=" + encodeURIComponent(selected_files[i]) + "&";
714
736
        dlpath = dlpath.substr(0, dlpath.length-1);
767
789
    /* These are only useful if we are in a versioned directory and have some
768
790
     * files selected. */
769
791
    set_action_state(["svnadd"], numsel >= 1 && current_file.svnstatus);
770
 
    /* And these are only usefull is ALL the selected files are versioned */
771
 
    set_action_state(["svnremove", "svnrevert", "svncommit", "svncopy", 
772
 
            "svncut"], numsel >= 1 && current_file.svnstatus && svn_selection);
773
 
    
 
792
    /* And these are only useful is ALL the selected files are versioned */
 
793
    set_action_state(["svnremove", "svnrevert", "svncopy", "svncut"],
 
794
            numsel >= 1 && current_file.svnstatus && svn_selection);
 
795
    /* Commit is useful if ALL selected files are versioned, or the current
 
796
     * directory is versioned */
 
797
    set_action_state(["svncommit"], current_file.svnstatus &&
 
798
            (numsel >= 1 && svn_selection || numsel == 0));
 
799
 
774
800
    /* Diff, log and update only support one path at the moment, so we must
775
801
     * have 0 or 1 versioned files selected. If 0, the directory must be
776
802
     * versioned. */
778
804
         (
779
805
          (numsel == 1 && (svnst = file_listing[selected_files[0]].svnstatus)) ||
780
806
          (numsel == 0 && (svnst = current_file.svnstatus))
781
 
         ) && svnst != "unversioned");
 
807
         ) && svnstatus_versioned(svnst));
782
808
    set_action_state(["svndiff", "svnupdate"], single_versioned_path);
783
809
 
784
810
    /* We can resolve if we have a file selected and it is conflicted. */
794
820
         (
795
821
          (numsel == 1 && (stat = file_listing[selected_files[0]])) ||
796
822
          (numsel == 0 && (stat = current_file))
797
 
         ) && stat.svnstatus != "unversioned"
 
823
         ) && svnstatus_versioned(stat.svnstatus)
798
824
           && stat.svnurl
799
825
           && stat.svnurl.substr(0, svn_base.length) == svn_base);
800
826
    set_action_state(["submit"], single_ivle_versioned_path);
853
879
        action_unpublish(selected_files);
854
880
        break;
855
881
    case "share":
856
 
        window.open(public_app_path("~" + current_path, filename), 'share')
 
882
        window.open(public_app_url("~" + current_path, filename), 'share')
857
883
        break;
858
884
    case "submit":
859
885
        if (selected_files.length == 1)
860
886
            stat = file_listing[selected_files[0]];
861
887
        else
862
888
            stat = current_file;
863
 
        path = stat.svnurl.substr(svn_base.length);
 
889
        url = stat.svnurl.substr(svn_base.length);      // URL-encoded
 
890
        path = decodeURIComponent(url);
864
891
 
865
892
        /* The working copy might not have an up-to-date version of the
866
893
         * directory. While submitting like this could yield unexpected
871
898
            {"action": "svnrepostat", "path": path},
872
899
            function(result)
873
900
            {
874
 
                window.location = path_join(app_path('+submit'), path) + '?revision=' + result.svnrevision;
 
901
                window.location = path_join(app_path('+submit'), url) + '?revision=' + result.svnrevision;
875
902
            },
876
903
            "json");
877
904
 
910
937
        action_revert(selected_files);
911
938
        break;
912
939
    case "svndiff":
913
 
        window.location = path_join(app_path('diff'), current_path, selected_files[0] || '');
 
940
        window.location = path_join(app_url('diff'), current_path, selected_files[0] || '');
914
941
        break;
915
942
    case "svnupdate":
916
943
        action_update(selected_files);
922
949
        action_commit(selected_files);
923
950
        break;
924
951
    case "svnlog":
925
 
        window.location = path_join(app_path('svnlog'), current_path, selected_files[0] || '');
 
952
        window.location = path_join(app_url('svnlog'), current_path, selected_files[0] || '');
926
953
        break;
927
954
    case "svncopy":
928
955
        action_svncopy(selected_files);