File size: 1,677 Bytes
ae4627d | 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | (function() {
var Device, FakeDevice;
Device = (function() {
function Device(ip, port) {
this.ip = ip;
this.port = port;
}
Device.prototype.getBusinessMusics = function() {
return this.get("http://" + this.ip + ":" + this.port + "/bm", function() {});
};
Device.prototype.setLevel = function(id, level) {
return this.put("http://" + this.ip + ":" + this.port + "/bm/" + id, function() {});
};
return Device;
})();
FakeDevice = (function() {
function FakeDevice(ip, port) {
this.ip = ip;
this.port = port;
this.programs = [
{
id: 1,
name: "Program 1",
zones: [1, 2, 3]
}, {
id: 2,
name: "Program 1",
zones: []
}, {
id: 3,
name: "Program 1",
zones: [100]
}, {
id: 4,
name: "Program 1",
zones: []
}
];
}
FakeDevice.prototype.getBusinessMusics = function(success) {
return success(this.programs);
};
FakeDevice.prototype.setLevel = function(id, level) {
console.log("Set level " + level + " to device " + id);
return this.programs[0];
};
FakeDevice.prototype.setZones = function(id, zones) {
var text;
text = "This program is currently not assigned to any zone!";
if (zones.length > 0) {
return $(".program-container[data-id=" + id + "] .program-zones").html("This zone is currently assigned to " + zones.length + " zones: " + (zones.sort().join(", ")));
}
};
return FakeDevice;
})();
window.FakeDevice = FakeDevice;
}).call(this);
|