Created
December 18, 2016 23:42
-
-
Save KanyonKris/e7a65e1b685e23b110c267bd1f848919 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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