changeset 4511:8b394bbd551c

javascript: ypjax callback is optional and do not have any parameters In files, read cache value from DOM.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 08 Sep 2014 13:38:56 +0200
parents a40994692ddb
children 72747179701a
files kallithea/public/js/base.js kallithea/templates/admin/settings/settings_system.html kallithea/templates/files/files.html
diffstat 3 files changed, 9 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/public/js/base.js	Mon Sep 08 13:38:56 2014 +0200
@@ -384,8 +384,8 @@
             $container.html(o.responseText);
             $container.css('opacity','1.0');
             //execute the given original callback
-            if (s_call !== undefined){
-                s_call(o);
+            if (s_call !== undefined && s_call){
+                s_call();
             }
         }
     })()
--- a/kallithea/templates/admin/settings/settings_system.html	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/templates/admin/settings/settings_system.html	Mon Sep 08 13:38:56 2014 +0200
@@ -38,6 +38,6 @@
     $('#check_for_update').click(function(e){
         $('#update_notice').show();
         ypjax("${h.url('admin_settings_system_update')}",
-              "update_notice", function(){});
+              "update_notice");
     })
 </script>
--- a/kallithea/templates/files/files.html	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/templates/files/files.html	Mon Sep 08 13:38:56 2014 +0200
@@ -199,6 +199,7 @@
 $(document).ready(function(){
     ypjax_links();
     var container = 'files_data';
+    var $files_data = $('#files_data');
     //Bind to StateChange Event
     History.Adapter.bind(window,'statechange',function(){
         var State = History.getState();
@@ -215,15 +216,11 @@
             callbacks(State);
         }
         else{
-          ypjax(State.url,container,function(o){
-              //callbacks after ypjax call
-              callbacks(State);
-              if (o !== undefined){
-                //store our request in cache
-                var _expire_on = new Date().getTime()+CACHE_EXPIRE;
-              CACHE[cache_key] = [_expire_on, o.responseText];
-            }
-          });
+            ypjax(State.url, container, function(){
+                    callbacks(State);
+                    var expire_on = new Date().getTime() + CACHE_EXPIRE;
+                    CACHE[cache_key] = [expire_on, $files_data.html()];
+                });
         }
     });