1 tr
.models
.Radar = function() {
2 var self
, quadrants
, blipNumber
;
5 quadrants
= { I
: null, II
: null, III
: null, IV
: null };
8 function setNumbers(blips
) {
9 blips
.forEach(function (blip
) {
10 blip
.setNumber(++blipNumber
);
14 self
.setFirstQuadrant = function (quadrant
) {
15 quadrants
.I
= quadrant
;
16 setNumbers(quadrants
.I
.blips());
19 self
.setSecondQuadrant = function (quadrant
) {
20 quadrants
.II
= quadrant
;
21 setNumbers(quadrants
.II
.blips());
24 self
.setThirdQuadrant = function (quadrant
) {
25 quadrants
.III
= quadrant
;
26 setNumbers(quadrants
.III
.blips());
29 self
.setFourthQuadrant = function (quadrant
) {
30 quadrants
.IV
= quadrant
;
31 setNumbers(quadrants
.IV
.blips());
34 function allQuadrants() {
37 for (var p
in quadrants
) {
38 if (quadrants
.hasOwnProperty(p
) && quadrants
[p
] != null) {
39 all
.push(quadrants
[p
]);
47 return allQuadrants().reduce(function (blips
, quadrant
) {
48 return blips
.concat(quadrant
.blips());
52 self
.hasQuadrants = function () {
53 return !!quadrants
.I
|| !!quadrants
.II
|| !!quadrants
.III
|| !!quadrants
.IV
;
56 self
.cycles = function () {
57 var cycleHash
, cycleArray
;
62 allBlips().forEach(function (blip
) {
63 cycleHash
[blip
.cycle().name()] = blip
.cycle();
66 for (var p
in cycleHash
) {
67 if (cycleHash
.hasOwnProperty(p
)) {
68 cycleArray
.push(cycleHash
[p
]);
72 return cycleArray
.slice(0).sort(function (a
, b
) { return a
.order() - b
.order(); });
75 self
.quadrants = function () {