store last called gearman function and args in hashPath
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 15 Mar 2011 17:28:27 +0000 (17:28 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 15 Mar 2011 17:28:27 +0000 (17:28 +0000)
public/gearman.html

index 411aad3..ef9f78a 100644 (file)
@@ -3,19 +3,24 @@
  <script src="http://code.angularjs.org/angular-0.9.12.min.js" ng:autobind></script>
  <body>
   <script>
-    function GearmanCntl($xhr) {
+    function GearmanCntl($xhr,$location) {
       var self = this;
-  
       this.status_update = function() {
         $xhr('JSON', '/_g/status?callback=JSON_CALLBACK', function(code,response) {
           self.g = response;
         });
       }
       this.status_update();
+
+       var a = $location.hashPath.split('/');
+       self.function_name = a[0];
+       self.args = a[1];
  
       this.fetch = function() {
         self.clear();
-       self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
+        $location.hashPath = self.function_name + '/' + self.args;
+       self.url = '/g/' + $location.hashPath + '?callback=JSON_CALLBACK';
         $xhr('JSON', self.url, function(code, response) {
           self.code = code;
           self.response = response;
@@ -27,7 +32,7 @@
         self.response = null;
       };
     }
-    GearmanCntl.$inject = ['$xhr'];
+    GearmanCntl.$inject = ['$xhr','$location'];
   </script>
   <div ng:controller="GearmanCntl">
     <select name="function_name">