sensortoy/www/js/standards/capability.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-05-20 16:10:40 +00:00
/**
*
* User: Martin Donnelly
* Date: 2016-05-20
* Time: 10:32
*
*/
'use strict';
var CAPABILITY = function(p) {
this.name = '-CAPABILITY-';
this.capabilityID = p.capabilityID || null;
this.state = '';
this.serviceDef = p.service || null;
this.internalID = null;
this.frameID = null;
this.$id = null;
this.deviceID = null;
};
CAPABILITY.prototype.setInternalID = function() {
this.internalID = (Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1).toString(36);
this.frameID = 'f-' + this.internalID;
};
CAPABILITY.prototype.setDeviceID = function(dID) {
this.deviceID = dID;
};
CAPABILITY.prototype.getDeviceID = function() {
return this.deviceID ;
};
CAPABILITY.prototype.insertFrame = function() {
this.setInternalID();
console.log('FrameID: ' , this.frameID);
var title = [this.name, ' - ', this.deviceID].join(' ');
var frame = $('<div />', {
class: 'mui-panel',
id: this.frameID});
$('<div />', { class: 'mui-row'}).append($('<div />', { class: 'mui-col-xs-12 mui--text-title', text: title})).appendTo(frame);
$('#frames').append(frame);
this.$id = $('#' + this.frameID);
};
CAPABILITY.prototype.inherits = function(a, b) {
var c = function() {};
c.prototype = b.prototype;
a.superClass_ = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
};
CAPABILITY.prototype.onError = function(e) {
console.error(e);
};
var inheritsFrom = function(a, b) {
var c = function() {};
c.prototype = b.prototype;
a.superClass_ = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
a.prototype.superClass_ = b.prototype;
};