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

« back to all changes in this revision

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

  • Committer: wagrant
  • Date: 2008-07-24 04:45:12 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:945
specialhome: Rebrand personal to mywork (by majority), refactor a bit,
             and improve error handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 */
27
27
 
28
28
/* The name of the personal file directory */
29
 
PERSONALDIR="personal"
 
29
PERSONALDIR="mywork"
30
30
 
31
31
/* LAYOUT FUNCTIONS */
32
32
 
57
57
        /* Print the file listing */
58
58
        ul = document.createElement("ul");
59
59
        // Stuff
60
 
        ul.appendChild(make_subject_item(path, "personal", "Your personal files here"));
 
60
        ul.appendChild(make_subject_item(path, PERSONALDIR, "Your personal files here"));
61
61
        // Groups
62
62
        /* TODO: List groups */
63
63
            
132
132
                button.addEventListener("click", function(event)
133
133
                {
134
134
                    action_rename(path_join(path, name));
135
 
 
136
 
                    // FIXME: Also do checkout here?
137
135
                },
138
136
                false);
139
137
                button.setAttribute("type", "button");
152
150
            var button = document.createElement("input");
153
151
            button.addEventListener("click", function(event)
154
152
            {   
155
 
                // Get repository stat
156
 
                response = ajax_call(null, service_app, current_path,
157
 
                    {
158
 
                        "action": "svnrepostat",
159
 
                        "path": path_join(username, path, name)
160
 
                    }, "POST");
161
 
 
162
 
                if (response.status == 200)
 
153
                if (create_if_needed(path_join(username, name)))
163
154
                {
164
155
                    // Try a checkout
165
156
                    do_action("svncheckout", current_path, {"path":
168
159
                            path_join(path, name) // localpath
169
160
                        ]});
170
161
                }
171
 
                else if (response.status == 404)
172
 
                {
173
 
                    // Try a mkdir
174
 
                    do_action("svnrepomkdir", current_path,
175
 
                        {
176
 
                            "path": path_join(username, path, name),
177
 
                            "logmsg": "Automated creation of '" + name + "' work directory"
178
 
                        });
179
 
                }
180
 
                else
181
 
                {
182
 
                    alert("Error: Could not Create repository");
183
 
                }
184
162
            },
185
163
            false);
186
164
            button.setAttribute("type", "button");
194
172
    return li;
195
173
}
196
174
 
 
175
function create_if_needed(path)
 
176
{
 
177
    response = ajax_call(null, service_app, current_path,
 
178
            {
 
179
                "action": "svnrepostat",
 
180
                "path": path
 
181
            }, "POST");
 
182
 
 
183
 
 
184
    if (response.status == 200)
 
185
    {
 
186
        return;
 
187
    }
 
188
    else if (response.status == 404)
 
189
    {
 
190
        // Try a mkdir
 
191
        r2 = ajax_call(null, service_app, current_path,
 
192
                {
 
193
                    "action": "svnrepomkdir",
 
194
                    "path": path,
 
195
                    "logmsg": "Automated creation of '" + name + "' work directory"
 
196
                }, "POST");
 
197
 
 
198
        if (r2.status == 200)
 
199
        {
 
200
            return true;
 
201
        }
 
202
    }
 
203
    alert("Error: Could not create Subversion directory");
 
204
    return false;
 
205
}