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

« back to all changes in this revision

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

  • Committer: dcoles
  • Date: 2008-04-14 03:52:13 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:731
Help: Wrote a small help document for the console app. Now one less glaring 
'TODO:' in IVLE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
487
487
    /* Available if exactly one file is selected,
488
488
     * and it is a Python file.
489
489
     */
490
 
    /* TODO */
 
490
    var run = document.getElementById("act_run");
 
491
     
 
492
    if (numsel == 0 && !file.isdir && file.type == "text/x-python")
 
493
    {
 
494
        // In the edit window
 
495
        run.setAttribute("class", "choice");
 
496
        localpath = app_path('home',current_path);
 
497
        run.setAttribute("onclick", "runfile('" + localpath + "')");
 
498
    }
 
499
    else if (numsel == 1 && !file.isdir && file.type == "text/x-python")
 
500
    {
 
501
        // In the browser window
 
502
        run.setAttribute("class", "choice");
 
503
        localpath = app_path('home',current_path,filename);
 
504
        run.setAttribute("onclick", "runfile('" + localpath + "')");
 
505
    }
 
506
    else
 
507
    {
 
508
        run.setAttribute("class", "disabled");
 
509
        run.removeAttribute("onclick");
 
510
    }
491
511
 
492
512
    /* Download */
493
513
    /* Always available.
544
564
    if (numsel <= 1 && file.isdir)
545
565
    {
546
566
        /* TODO: Work out of file is svn'd */
547
 
        /* TODO: If this dir is already published, call it "Unpublish" */
548
567
        publish.setAttribute("class", "choice");
549
568
        publish.removeAttribute("disabled");
 
569
        /* If this dir is already published, call it "Unpublish" */
 
570
        if (file.published)
 
571
        {
 
572
            publish.setAttribute("value", "unpublish");
 
573
            publish.setAttribute("title" ,"Make it so this directory "
 
574
                + "can not be seen by anyone on the web");
 
575
            publish.textContent = "Unpublish";
 
576
        } else {
 
577
            publish.setAttribute("value", "publish");
 
578
            publish.setAttribute("title","Make it so this directory "
 
579
                + "can be seen by anyone on the web");
 
580
            publish.textContent = "Publish";
 
581
        }
550
582
        submit.setAttribute("class", "choice");
551
583
        submit.removeAttribute("disabled");
552
584
    }
565
597
    var share = document.getElementById("act_share");
566
598
    if (numsel <= 1 && !file.isdir)
567
599
    {
568
 
        /* TODO: Work out if parent dir is published */
569
 
        share.setAttribute("class", "choice");
570
 
        share.removeAttribute("disabled");
 
600
        /* Work out if parent dir is published */
 
601
        parentdir = current_file;
 
602
        if (parentdir.published)
 
603
        {
 
604
            share.setAttribute("class", "choice");
 
605
            share.removeAttribute("disabled");
 
606
        } else {
 
607
            share.setAttribute("class", "disabled");
 
608
            share.setAttribute("disabled", "disabled");
 
609
        }
571
610
    }
572
611
    else
573
612
    {
677
716
        action_unpublish(selected_files);
678
717
        break;
679
718
    case "share":
680
 
        // TODO
681
 
        alert("Not yet implemented: Sharing files");
 
719
        //alert("Not yet implemented: Sharing files");
 
720
        window.open(public_app_path(serve_app, current_path, filename), 'share')
682
721
        break;
683
722
    case "submit":
684
723
        // TODO
723
762
    }
724
763
}
725
764
 
 
765
/** User clicks "Run" button.
 
766
 * Do an Ajax call and print the test output.
 
767
 */
 
768
function runfile(localpath)
 
769
{
 
770
    /* Dump the entire file to the console */
 
771
    var callback = function()
 
772
    {
 
773
        console_enter_line("execfile('" + localpath + "')", "block");
 
774
    }
 
775
    start_server(callback)
 
776
    return;
 
777
}
 
778
 
726
779
/** Called when the page loads initially.
727
780
 */
728
781
window.onload = function()
754
807
    }
755
808
 
756
809
    navigate(path);
 
810
 
 
811
    /* Set up the console plugin to display as a popup window */
 
812
    console_init(true);
757
813
}