Advertisement
robofred310

irene.js

Oct 26th, 2021
371
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.                 console.log("hey kir2koon")  // nothing happens in console
  19.                 self.servoCmd(newSpeed)
  20.                 OctoPrint.simpleApiCommand('irene', 'update_speed', {'servoCmd': newSpeed})
  21.             }
  22.         }
  23.    
  24.         self.onBeforeBinding = function() {  
  25.         }
  26.  
  27.         self.onDataUpdaterPluginMessage = function(plugin, data) {
  28.             if(plugin != 'irene') { return }
  29.             if(data.hasOwnProperty('servoCmd')) {
  30.                 self.servoCmd(data.servoCmd)
  31.             }
  32.         }
  33.     }
  34.  
  35.     OCTOPRINT_VIEWMODELS.push({
  36.         construct: ireneViewModel,
  37.         dependencies: ["settingsViewModel"],
  38.         elements: ["#sidebar_plugin_irene"]
  39.     });
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement