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

« back to all changes in this revision

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

  • Committer: mattgiuca
  • Date: 2008-03-15 11:40:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:705
tutorial (Python & JS)
    Submit now behaves like Save in that it greys out the button while waiting
    for a response from the server, and activates it again once a response
    comes back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 */
63
63
function submitexercise(exerciseid, filename)
64
64
{
 
65
    set_submit_status(exerciseid, filename, "Submitting...");
 
66
    set_saved_status(exerciseid, filename, "Saving...");
65
67
    /* Get the source code the student is submitting */
66
68
    var exercisediv = document.getElementById(exerciseid);
67
69
    var exercisebox = exercisediv.getElementsByTagName("textarea")[0];
76
78
        {
77
79
            var testresponse = JSON.parse(xhr.responseText);
78
80
            handle_testresponse(exercisediv, testresponse);
 
81
            set_saved_status(exerciseid, filename, "Saved");
 
82
            set_submit_status(exerciseid, filename, "Submit");
79
83
        }
80
84
    ajax_call(callback, "tutorialservice", "", args, "POST",
81
85
        "multipart/form-data");
152
156
    }
153
157
}
154
158
 
 
159
/** Changes the state of the submit button, so it can appear disabled during
 
160
 * the submission process (to avoid multiple clicks).
 
161
 * stat is a string which specifies the status, and also the button text.
 
162
 * If stat == "Submit", then it indicates it is available for submission.
 
163
 * This will enable the "Submit" button.
 
164
 * Any other value (recommended: "Submitting...") will disable the "Submit"
 
165
 * button.
 
166
 */
 
167
function set_submit_status(exerciseid, filename, stat)
 
168
{
 
169
    var button = document.getElementById("submitbutton_" + exerciseid);
 
170
    button.disabled = stat != "Submit";
 
171
    button.value = stat;
 
172
}
 
173
 
155
174
/** Given a exercise div, return the testoutput div which is its child.
156
175
 * (The div which is its child whose class is "testoutput".
157
176
 */