From: Michael J. Rubinsky Date: Sat, 27 Nov 2010 05:35:24 +0000 (-0500) Subject: Begin checking for errors, messages, session time out etc... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=db42f9361a14238e733e27fd97ff000b44bb24a9;p=horde.git Begin checking for errors, messages, session time out etc... --- diff --git a/kronolith/js/mobile.js b/kronolith/js/mobile.js index 25ebcdbcc..554542356 100644 --- a/kronolith/js/mobile.js +++ b/kronolith/js/mobile.js @@ -41,6 +41,8 @@ */ date: null, + serverError: 0, + /** * Perform an Ajax action * @@ -50,7 +52,46 @@ */ doAction: function(action, params, callback) { - $.post(Kronolith.conf.URI_AJAX + action, params, callback, 'json'); + var options = { + 'url': Kronolith.conf.URI_AJAX + action, + 'data': params, + 'error': KronolithMobile.errorCallback, + 'success': function(d, t, x) { KronolithMobile.doActionComplete(d, callback); }, + 'type': 'post' + }; + $.ajax(options); + }, + + doActionComplete: function(d, callback) + { + var r = d.response; + if (r && $.isFunction(callback)) { + callback(r); + } + + KronolithMobile.server_error = 0; + KronolithMobile.showNotifications(d.msgs || []); + KronolithMobile.inAjaxCallback = false; + }, + + showNotifications: function(m) + { + $.each(m, function(key, msg) { + if (msg.type == 'horde.ajaxtimeout') { + KronolithMobile.logout(msg.message); + } + }); + }, + + logout: function(url) + { + KronolithMobile.is_logout = true; + window.location = (url || (Kronolith.conf.URI_AJAX + 'logOut')); + }, + + errorCallback: function(x, t, e) + { + }, /** @@ -139,11 +180,10 @@ */ loadEventsCallback: function(data) { - var start = KronolithMobile.parseDate(data.response.sig.substr(0, 8)), - end = KronolithMobile.parseDate(data.response.sig.substr(8, 8)), - dates = [start, end], view = data.response.view, list, events; + var start = KronolithMobile.parseDate(data.sig.substr(0, 8)), + end = KronolithMobile.parseDate(data.sig.substr(8, 8)), + dates = [start, end], view = data.view, list, events; - data = data.response; KronolithMobile.storeCache(data.events, data.cal, dates, true); KronolithMobile.loadedCalendars.push(data.cal); KronolithMobile.insertEvents(dates, view, data.cal); @@ -269,12 +309,12 @@ */ loadEventCallback: function(data) { - if (!data.response.event) { + if (!data.event) { // @TODO: Error handling. return; } - var event = data.response.event; + var event = data.event; var ul = KronolithMobile.buildEventView(event); $('#eventview [data-role=content]').append(ul); }, diff --git a/kronolith/mobile.php b/kronolith/mobile.php index b7455c33b..b1391f648 100644 --- a/kronolith/mobile.php +++ b/kronolith/mobile.php @@ -39,4 +39,5 @@ echo $view->render('day'); echo $view->render('event'); echo $view->render('month'); echo $view->render('summary'); +echo $view->render('notice'); $registry->get('templates', 'horde') . '/common-footer-mobile.inc'; diff --git a/kronolith/templates/mobile/notice.html.php b/kronolith/templates/mobile/notice.html.php new file mode 100644 index 000000000..b00cab50e --- /dev/null +++ b/kronolith/templates/mobile/notice.html.php @@ -0,0 +1,7 @@ +
+
+

+
+
+
+
\ No newline at end of file