~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 05:25:48 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:920
userdb: Added to table "offering" fields max_students_per_group and
    max_groups_per_student.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
default_type_icon = "txt.png";
56
56
 
57
57
/* Relative to IVLE root */
58
 
type_icons_path = "+media/ivle.webapp.core/images/mime";
59
 
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";
60
60
 
61
61
/* Mapping SVN status to icons, just the file's basename */
62
62
svn_icons = {
87
87
default_svn_icon = null;
88
88
default_svn_nice = "Unknown status";
89
89
 
90
 
svn_icons_path = "+media/ivle.webapp.core/images/svn";
 
90
svn_icons_path = "media/images/svn";
91
91
 
92
 
published_icon = "+media/ivle.webapp.core/images/interface/published.png";
 
92
published_icon = "media/images/interface/published.png";
93
93
 
94
94
/* List of MIME types considered "executable" by the system.
95
95
 * Executable files offer a "run" link, implying that the "serve"
144
144
            /* Check for action errors reported by the server, and report them
145
145
             * to the user */
146
146
            var error = response.getResponseHeader("X-IVLE-Action-Error");
147
 
            if (error != null && error != "")
 
147
            if (error != null)
148
148
                /* Note: This header (in particular) comes URI-encoded, to
149
149
                 * allow multi-line error messages. Decode */
150
150
                alert("Error: " + decodeURIComponent(error.toString()) + ".");
241
241
        return;
242
242
    }
243
243
 
244
 
    var subjects = null;
245
 
    var top_level_dir = path==username;
246
 
    if (top_level_dir)
247
 
    {
248
 
        var req = ajax_call(null, "userservice", "get_enrolments", null, "GET")
249
 
        subjects = decode_response(req);
250
 
    }
251
 
 
252
 
 
253
244
    /* This will always return a listing, whether it is a dir or a file.
254
245
     */
255
246
    var listing = response.responseText;
307
298
    var isdir = response.getResponseHeader("X-IVLE-Return") == "Dir";
308
299
    if (isdir)
309
300
    {
310
 
        setup_for_listing();
311
 
        home_listing(listing, subjects, path);
 
301
        handle_dir_listing(path, listing);
312
302
    }
313
303
    else
314
304
    {
377
367
    upload_callback_count++;
378
368
    if (upload_callback_count >= 2)
379
369
    {
380
 
        myFrame = frames['upload_iframe'].document;
381
 
        data = myFrame.firstChild.childNodes[1].firstChild.firstChild.nodeValue;
382
 
        data = JSON.parse(data);
383
 
        if ('Error' in data)
384
 
            alert("Error: " + decodeURIComponent(data['Error']));
385
370
        document.getElementsByName('data')[0].value = '';
386
371
        refresh();
387
372
    }
550
535
    }
551
536
}
552
537
 
553
 
/* Updates the list of available actions based on files selected */
554
538
function update_actions()
555
539
{
556
540
    var file;
557
541
    var numsel = selected_files.length;
558
 
    var svn_selection = false;
559
 
    
560
 
    if (numsel > 0)
561
 
    {
562
 
        svn_selection = true;
563
 
        for (var i = 0; i < selected_files.length; i++){
564
 
            if (file_listing[selected_files[i]]["svnstatus"] == "unversioned")
565
 
            {
566
 
                svn_selection = false;        
567
 
            }
568
 
        }
569
 
    }
570
 
    
571
542
    if (numsel <= 1)
572
543
    {
573
544
        if (numsel == 0)
638
609
     */
639
610
    var run = document.getElementById("act_run");
640
611
     
641
 
    if (numsel <= 1 && !file.isdir && file.type == "text/x-python" 
642
 
            && current_file.svnstatus != 'revision')
 
612
    if (!file.isdir && file.type == "text/x-python" && numsel <= 1
 
613
        && current_file.svnstatus != 'revision')
643
614
    {
644
615
        if (numsel == 0)
645
616
        {
722
693
    var pubcond = numsel <= 1 && file.isdir;
723
694
    if (pubcond)
724
695
    {
 
696
        /* TODO: Work out of file is svn'd */
725
697
        /* If this dir is already published, call it "Unpublish" */
726
698
        if (file.published)
727
699
        {
728
700
            publish.setAttribute("value", "unpublish");
729
701
            publish.setAttribute("title" ,"Make it so this directory "
730
702
                + "can not be seen by anyone on the web");
731
 
            publish.firstChild.nodeValue = "Unpublish";
 
703
            publish.textContent = "Unpublish";
732
704
        } else {
733
705
            publish.setAttribute("value", "publish");
734
706
            publish.setAttribute("title","Make it so this directory "
735
707
                + "can be seen by anyone on the web");
736
 
            publish.firstChild.nodeValue = "Publish";
 
708
            publish.textContent = "Publish";
737
709
        }
738
710
    }
739
711
    set_action_state(["publish", "submit"], pubcond);
760
732
    /* Subversion actions */
761
733
    /* These are only useful if we are in a versioned directory and have some
762
734
     * files selected. */
763
 
    set_action_state(["svnadd"], numsel >= 1 && current_file.svnstatus);
764
 
    /* And these are only usefull is ALL the selected files are versioned */
765
 
    set_action_state(["svnremove", "svnrevert", "svncommit", "svncopy", 
766
 
            "svncut"], numsel >= 1 && current_file.svnstatus && svn_selection);
767
 
    
 
735
    set_action_state(["svnadd", "svnrevert", "svncommit"], numsel >= 1 && current_file.svnstatus);
 
736
 
768
737
    /* Diff, log and update only support one path at the moment, so we must
769
738
     * have 0 or 1 versioned files selected. If 0, the directory must be
770
739
     * versioned. */
781
750
    /* Log should be available for revisions as well. */
782
751
    set_action_state("svnlog", single_versioned_path, true);
783
752
 
784
 
    single_ivle_versioned_path = (
785
 
         (
786
 
          (numsel == 1 && (stat = file_listing[selected_files[0]])) ||
787
 
          (numsel == 0 && (stat = current_file))
788
 
         ) && stat.svnstatus != "unversioned"
789
 
           && stat.svnurl
790
 
           && stat.svnurl.substr(0, svn_base.length) == svn_base);
791
 
    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);
792
755
 
793
756
    /* There is currently nothing on the More Actions menu of use
794
757
     * when the current file is not a directory. Hence, just remove
844
807
        action_unpublish(selected_files);
845
808
        break;
846
809
    case "share":
847
 
        window.open(public_app_path("~" + current_path, filename), 'share')
 
810
        //alert("Not yet implemented: Sharing files");
 
811
        window.open(public_app_path(serve_app, current_path, filename), 'share')
848
812
        break;
849
813
    case "submit":
850
 
        if (selected_files.length == 1)
851
 
            stat = file_listing[selected_files[0]];
852
 
        else
853
 
            stat = current_file;
854
 
        path = stat.svnurl.substr(svn_base.length);
855
 
 
856
 
        /* The working copy might not have an up-to-date version of the
857
 
         * directory. While submitting like this could yield unexpected
858
 
         * results, we should really submit the latest revision to minimise
859
 
         * terrible mistakes - so we run off and ask fileservice for the
860
 
         * latest revision.*/
861
 
        $.post(app_path(service_app, current_path),
862
 
            {"action": "svnrepostat", "path": path},
863
 
            function(result)
864
 
            {
865
 
                window.location = path_join(app_path('+submit'), path) + '?revision=' + result.svnrevision;
866
 
            },
867
 
            "json");
868
 
 
 
814
        // TODO
 
815
        alert("Not yet implemented: Submit");
869
816
        break;
870
817
    case "rename":
871
818
        action_rename(filename);
872
819
        break;
873
820
    case "delete":
874
 
        action_delete(selected_files);
 
821
        action_remove(selected_files);
875
822
        break;
876
823
    case "copy":
877
824
        action_copy(selected_files);
894
841
    case "svnadd":
895
842
        action_add(selected_files);
896
843
        break;
897
 
    case "svnremove":
898
 
        action_remove(selected_files);
899
 
        break;
900
844
    case "svnrevert":
901
845
        action_revert(selected_files);
902
846
        break;
915
859
    case "svnlog":
916
860
        window.location = path_join(app_path('svnlog'), current_path, selected_files[0] || '');
917
861
        break;
918
 
    case "svncopy":
919
 
        action_svncopy(selected_files);
920
 
        break;
921
 
    case "svncut":
922
 
        action_svncut(selected_files);
 
862
    case "svncheckout":
 
863
        action_checkout();
923
864
        break;
924
865
    }
925
866
}