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

« back to all changes in this revision

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

  • Committer: wagrant
  • Date: 2008-07-09 05:37:59 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:839
Prompt on Save As if it would overwrite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
function save_file_as(default_filename)
24
24
{
25
 
    filename = prompt('Path to save to:', default_filename);
26
 
    /* TODO: Confirm overwriting. */
27
 
    save_file(filename);
 
25
    filename = prompt("Path to save to:", default_filename);
 
26
    if (!filename) return;
 
27
 
 
28
    /* The filename will be path_joined with the app name, so needs to not
 
29
     * be absolute, lest it clobber the app name. */
 
30
    if (filename.charAt(0) == "/") filename = filename.substring(1);
 
31
    ajax_call(save_file_as_callback, "fileservice", filename, {}, "POST");
 
32
}
 
33
 
 
34
function save_file_as_callback(response)
 
35
{
 
36
    if (response.status == 404 || confirm("Are you sure you want to overwrite " + filename + "?"))
 
37
        save_file(filename);
28
38
}
29
39
 
30
40
function edit_text()