Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<script src="js/jquery.knob.min.js"></script>
<script>
var sc;
var msgOut = false;
var data = {Dial1: 0, Dial2: 0};
(function(scope) {
scope.$watch('msg.payload', function(data) {
msgOut = false;
for (var key in data) {
if (data.hasOwnProperty(key)) {
// console.log(key + " -> " + data[key]);
$("#" + key).val(data[key]);
$("#" + key).change();
}
}
});
sc = scope;
})(scope);
var sendData = function(data){
sc.send({payload:data});
}
$(".cDial1").knob({
change : function (value) {
msgOut = true;
//console.log("change : " + value);
},
release : function (value) {
// console.log("release1 : "+value+" msgOut : "+msgOut);
data.Dial1 = value;
if (msgOut == true) {
sendData(data);
//msgOut = true;
}
//console.log(this.$.attr('value'));
},
cancel : function () {
// console.log("cancel : ", this);
},
/*format : function (value) {
return value + '%';
},*/
draw : function () { }
});
$(".cDial2").knob({
change : function (value) {
msgOut = true;
//console.log("change : " + value);
},
release : function (value) {
// console.log("release2 : "+value+" msgOut : "+msgOut);
data.Dial2 = value;
if (msgOut == true) {
sendData(data);
//msgOut = true;
}
//console.log(this.$.attr('value'));
},
cancel : function () {
// console.log("cancel : ", this);
},
/*format : function (value) {
return value + '%';
},*/
draw : function () { }
});
</script>
<input class="cDial1" id="Dial1" data-angleOffset=-90 data-angleArc=180 data-width="120" data-cursor=true data-fgColor="#00FF00" data-thickness=.3 value="0">
<input class="cDial2" id="Dial2" data-angleOffset=-90 data-angleArc=180 data-width="120" data-cursor=true data-fgColor="#0000FF" data-thickness=.3 value="0">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.