aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/history.js
blob: 0fed043b725042e74516897c275853e3e5f5d816 (plain) (blame)
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
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";

function HistoryItem(historyRaw) {
  // FIXME is this same format as Comment.date ? I.e.,
  // this.date = parseBZCommentDate(timeSpan.textContent.trim());
  this.date = 0;
}

History.prototype.getText = function getText() {
  return this.element.getElementsByTagName("pre")[0].textContent.trim();
}

// FIXME Getter .applied (type Boolean)

function HistoryList(raw) {
  this.formatVersion = raw.version;
  this.bugs = [];
  this.faults = [];
  raw.result.bugs.forEach(function (historyBugItemRaw) {
    historyBugItemRaw.history.forEach(function (historyRawItem) {
      var tmpHsItem = new HistoryItem(historyRawItem);
      if (tmpHsItem) {
        this.bugs.push(tmpHsItem);
      }
    });
  });
  raw.result.faults.forEach(function (faultItemRaw) {
    console.log("HistoryList init: fault = " +
      faultItemRaw.toSource());
  });
  console.log("HistoryList: this.bugs = " +
    this.bugs.toSource());
}

HistoryList.prototype.forEach = function forEach(fnc) {
  this.bugs.forEach(fnc); // this is not right
  // I am not dealing with parameters right, should be
  // probably some kind of call/apply magic FIXME
};

HistoryList.prototype.filter = function filter(fnc) {
  // Ditto
};