Skip to content

Instantly share code, notes, and snippets.

@KanyonKris
Created December 18, 2016 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KanyonKris/e7a65e1b685e23b110c267bd1f848919 to your computer and use it in GitHub Desktop.
Save KanyonKris/e7a65e1b685e23b110c267bd1f848919 to your computer and use it in GitHub Desktop.
<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