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

« back to all changes in this revision

Viewing changes to ivle/webapp/coremedia/util.js

  • Committer: William Grant
  • Date: 2009-02-23 23:47:02 UTC
  • mfrom: (1099.1.211 new-dispatch)
  • Revision ID: grantw@unimelb.edu.au-20090223234702-db4b1llly46ignwo
Merge from lp:~ivle-dev/ivle/new-dispatch.

Pretty much everything changes. Reread the setup docs. Backup your databases.
Every file is now in a different installed location, the configuration system
is rewritten, the dispatch system is rewritten, URLs are different, the
database is different, worksheets and exercises are no longer on the
filesystem, we use a templating engine, jail service protocols are rewritten,
we don't repeat ourselves, we have authorization rewritten, phpBB is gone,
and probably lots of other things that I cannot remember.

This is certainly the biggest commit I have ever made, and hopefully
the largest I ever will.

Show diffs side-by-side

added added

removed removed

Lines of Context:
622
622
 * \param app IVLE app to call (such as "fileservice").
623
623
 * \param path URL path to make the request to, within the application.
624
624
 * \param args Argument object, as described in parse_url and friends.
625
 
 * \param method String; "GET" or "POST"
626
 
 * \param content_type String, optional. Only applies if method is "POST".
627
 
 *      May be "application/x-www-form-urlencoded" or "multipart/form-data".
 
625
 * \param method String; "GET", "POST", "PUT", or "PATCH"
 
626
 * \param content_type String, optional.
628
627
 *      Defaults to "application/x-www-form-urlencoded".
629
628
 */
630
629
function ajax_call(callback, app, path, args, method, content_type)
631
630
{
632
 
    if (content_type != "multipart/form-data")
 
631
    if (!content_type)
633
632
        content_type = "application/x-www-form-urlencoded";
634
633
    path = app_path(app, path);
635
634
    var url;
659
658
    }
660
659
    else
661
660
    {
662
 
        /* POST sends the args in application/x-www-form-urlencoded */
 
661
        /* POST & PUT & PATCH sends the args in the request body */
663
662
        url = encodeURI(path);
664
663
        xhr.open(method, url, asyncronous);
665
664
        var message;
669
668
                "multipart/form-data; boundary=" + boundary);
670
669
            message = make_multipart_formdata(args, boundary);
671
670
        }
672
 
        else
 
671
        else if (content_type == "application/x-www-form-urlencoded")
673
672
        {
674
673
            xhr.setRequestHeader("Content-Type", content_type);
675
674
            message = make_query_string(args);
676
675
        }
 
676
        else if (content_type == "application/json")
 
677
        {
 
678
            xhr.setRequestHeader("Content-Type", content_type);
 
679
            message = JSON.stringify(args);
 
680
        }
 
681
        else
 
682
        {
 
683
            xhr.setRequestHeader("Content-Type", content_type);
 
684
            message = args;
 
685
        }
677
686
        xhr.send(message);
678
687
    }
679
688
    /* Only return the XHR for syncronous requests */