github.com/docker/compose-on-kubernetes@v0.5.0/samples/web/static/app.js (about)

     1  "use strict";
     2  
     3  var lab = angular.module('lab', []);
     4  
     5  lab.controller('LabCtrl', function ($scope, $http, $timeout) {
     6    $scope.noun1 = "";
     7    $scope.noun2 = "";
     8    $scope.adjective1 = "";
     9    $scope.adjective2 = "";
    10    $scope.verb = "";
    11  
    12    getWord($http, $timeout, '/words/noun', function(resp) {
    13      $scope.noun1 = word(resp);
    14    });
    15    getWord($http, $timeout, '/words/noun', function(resp) {
    16      $scope.noun2 = word(resp);
    17    });
    18    getWord($http, $timeout, '/words/adjective', function(resp) {
    19      var adj = word(resp);
    20      adj.word = adj.word.charAt(0).toUpperCase() + adj.word.substr(1)
    21      $scope.adjective1 = adj;
    22    });
    23    getWord($http, $timeout, '/words/adjective', function(resp) {
    24      $scope.adjective2 = word(resp);
    25    });
    26    getWord($http, $timeout, '/words/verb', function(resp) {
    27      $scope.verb = word(resp);
    28    });
    29  });
    30  
    31  function getWord($http, $timeout, url, callback) {
    32    $http.get(url).then(callback, function(resp) {
    33      $timeout(function() {
    34        console.log("Retry: " + url);
    35        getWord($http, $timeout, url, callback);
    36      }, 500);
    37    });
    38  }
    39  
    40  function word(resp) {
    41    return {
    42      word: resp.data.word,
    43      hostname: resp.headers()["source"]
    44    };
    45  }