aboutsummaryrefslogtreecommitdiffstats
path: root/example/buzz/buzz.js
blob: 7e7f2f664429f1ed226d659ce53fee978b1e9979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
angular.module.ng('myApplication', function($resource){
  this.Activity = $resource(
      'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
      {alt:'json', callback:'JSON_CALLBACK'},
      {
        get:     {method:'JSON', params:{visibility:'@self'}},
        replies: {method:'JSON', params:{visibility:'@self', comments:'@comments'}}
      });
}, {inject:['$resource']});

function BuzzController() {
  this.$watch('$location.hashPath', this.userChange);
}
BuzzController.prototype = {
  userChange: function() {
    this.userId = this.$location.hashPath;
    this.activities = this.Activity.get({userId:this.userId});
  },

  expandReplies: function(activity) {
    var self = this;
    if (activity.replies) {
      activity.replies.show = !activity.replies.show;
    } else {
      activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function() {
        activity.replies.show = true;
      });
    }
  }
};

angular.widget('my:expand', function(element){
  element.css('display', 'block');
  this.descend(true);
  return function(element) {
    element.hide();
    var watch = element.attr('expand');
    this.$watch(watch, function(value){
      if (value) {
        element.delay(0).slideDown('slow');
      } else {
        element.slideUp('slow');
      }
    });
  };
});
="n">outdated_versions = outdated_kegs .group_by { |keg| Formulary.from_keg(keg).full_name } .sort_by { |full_name, _kegs| full_name } .map do |full_name, kegs| "#{full_name} (#{kegs.map(&:version).join(", ")})" end.join(", ") puts "#{outdated_versions} < #{current_version}" else puts f.full_installed_specified_name end end end def print_outdated_json(formulae) json = [] fetch_head = ARGV.fetch_head? outdated_formulae = formulae.select { |f| f.outdated?(fetch_head: fetch_head) } outdated = outdated_formulae.each do |f| outdated_versions = f.outdated_kegs(fetch_head: fetch_head).map(&:version) current_version = if f.head? && outdated_versions.any? { |v| v.to_s == f.pkg_version.to_s } "HEAD" else f.pkg_version.to_s end json << { name: f.full_name, installed_versions: outdated_versions.collect(&:to_s), current_version: current_version } end puts JSON.generate(json) outdated end end