Ignore:
Timestamp:
03/13/12 14:10:32 (13 years ago)
Author:
hendrikvanantwerpen
Message:

[Client] Use toaster to show errors from server
[Client] Create widget for mainmenu, cleaner loading of index.html now.
[Server] Renamed answerset datetime to more meaningful creationdate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/api.js

    r274 r311  
    1 define(['dojo/_base/xhr','dojo/_base/json','dojo/_base/Deferred','./auth'],function(xhr,json,Deferred){
    2     return {
    3         post: function(path,args) {
    4             return xhr.post({
    5                 url: "../server/api.php/"+path,
    6                 handleAs: "json",
    7                 headers: {
    8                     "Content-Type": "application/json"
    9                 },
    10                 rawBody: json.toJson(args)
    11             });
    12         }
    13     };
    14 });
     1define(['dojo/_base/xhr','dojo/_base/json','dojo/_base/connect'],
     2    function(xhr,json,connect){
     3        return new (function(){
     4            var self = this;
     5            this.post = function(path,args) {
     6                var dfd = xhr.post({
     7                    url: "../server/api.php/"+path,
     8                    handleAs: "json",
     9                    headers: {
     10                        "Content-Type": "application/json"
     11                    },
     12                    rawBody: json.toJson(args)
     13                });
     14                dfd.then(
     15                    function(){},
     16                    self.defaultErrorHandler);
     17                return dfd;
     18            };
     19            this.defaultErrorHandler = function(error) {
     20                var msg = "An error occured!";
     21                try {
     22                    msg = json.fromJson(error.responseText).errorMsg;
     23                } catch (ex) {
     24                    msg = error.message;
     25                }
     26                self.notify(msg,'error');
     27            };
     28            this.notify =  function(text,type) {
     29                connect.publish('/rft/notify',{
     30                    text: text,
     31                    type: type
     32                });
     33            };
     34        })();
     35    });
Note: See TracChangeset for help on using the changeset viewer.