Advertisement
robofred310

irene.js

Oct 26th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * View model for OctoPrint-Irene
  3.  *
  4.  * Author: robofred
  5.  * License: AGPLv3
  6.  */
  7.  
  8.  
  9. $(function() {
  10.     function ireneViewModel(parameters) {
  11.         var self = this;
  12.         self.settings = parameters[0];
  13.         self.servoCmd = ko.observable();
  14.  
  15.         self.cmdServo = function(element, event) {
  16.             var newSpeed = event.servoCmd.value
  17.             if(newSpeed) {
  18.                 self.speed(newSpeed)
  19.                 OctoPrint.simpleApiCommand('irene', 'update_speed', {'speed': newSpeed})
  20.             }
  21.         }
  22.    
  23.         self.onBeforeBinding = function() {  
  24.         }
  25.  
  26.         self.onDataUpdaterPluginMessage = function(plugin, data) {
  27.             if(plugin != 'irene') { return }
  28.             if(data.hasOwnProperty('speed')) {
  29.                 self.speed(data.speed)
  30.             }
  31.         }
  32.     }
  33.  
  34.     OCTOPRINT_VIEWMODELS.push({
  35.         construct: ireneViewModel,
  36.         dependencies: ["settingsViewModel"],
  37.         elements: ["#sidebar_plugin_irene"]
  38.     });
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement