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

« back to all changes in this revision

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

  • Committer: mattgiuca
  • Date: 2008-02-28 21:54:45 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:614
browser/listing: Added a confirmation message for deleting files
    (a very informative context-based one).

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
function action_remove(files)
53
53
{
 
54
    var conf_msg;
 
55
    /* A heavy nesty bit of logic to determine the confirmation message.
 
56
     */
 
57
    if (files.length == 0)
 
58
        return;
 
59
    else if (files.length == 1)
 
60
    {
 
61
        if (file_listing[files[0]].isdir)
 
62
            conf_msg = "Are you sure you want to delete the directory \""
 
63
                + files[0] + "\"?\n"
 
64
                + "All of the files in this directory will be lost.";
 
65
        else
 
66
            conf_msg = "Are you sure you want to delete the file \""
 
67
                + files[0] + "\"?";
 
68
    }
 
69
    else
 
70
    {
 
71
        var confirm_filelist = "";
 
72
        var num_dirs = 0;
 
73
        for (var i=0; i<files.length; i++)
 
74
        {
 
75
            if (file_listing[files[i]].isdir)
 
76
                num_dirs++;
 
77
            confirm_filelist += "  - " + files[i] + "\n";
 
78
        }
 
79
        conf_msg = "Are you sure you want to delete all of the "
 
80
            + "following ";
 
81
        if (num_dirs > 0)
 
82
        {
 
83
            if (files.length == num_dirs)
 
84
                conf_msg += "directories";
 
85
            else
 
86
                conf_msg += "files and directories";
 
87
        }
 
88
        else
 
89
            conf_msg += "files";
 
90
        conf_msg += ":\n" + confirm_filelist;
 
91
        if (num_dirs > 0)
 
92
            conf_msg += "\nAll of the files in these directories "
 
93
                     + "will be lost.";
 
94
    }
 
95
    /* Now we have the conf message */
 
96
 
 
97
    var confirmed = confirm(conf_msg);
 
98
    if (!confirmed) return;
54
99
    do_action("remove", current_path, {"path":files});
55
100
    return false;
56
101
}