1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 window.buildbot = window.buildbot || {};
9 buildbot.ActiveIssues = function() {
11 this.eventCallback_ = null;
14 buildbot.ActiveIssues.prototype = {
15 forEach: function(callback) {
16 for (var key in this.issues_)
17 callback(this.issues_[key]);
20 getIssue: function(number) {
21 return this.issues_[number];
24 updateIssue: function(issue) {
25 var eventType = this.issues_.hasOwnProperty(issue.issue) ?
26 "issueUpdated" : "issueAdded";
27 this.issues_[issue.issue] = issue;
28 this.postEvent_({event: eventType, issue: issue.issue});
31 removeIssue: function(issue) {
32 delete this.issues_[issue.issue];
33 this.postEvent_({event: "issueRemoved", issue: issue.issue});
36 setEventCallback: function(callback) {
37 this.eventCallback_ = callback;
40 postEvent_: function(obj) {
41 if (this.eventCallback_)
42 this.eventCallback_(obj);
46 buildbot.getActiveIssues = function() {
47 var background = chrome.extension.getBackgroundPage();
48 if (!background.buildbot.hasOwnProperty("activeIssues"))
49 background.buildbot.activeIssues = new buildbot.ActiveIssues;
51 return background.buildbot.activeIssues;