UNPKG

node-red-contrib-pitft

Version:
96 lines (93 loc) 4.17 kB
<script type="text/x-red" data-template-name="pitft out"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-device"><i class="icon-tag"></i> Device</label> <input type="text" id="node-input-device" placeholder="Device"> </div> <div class="form-row" style="margin-bottom: 0px;"> <label for="node-input-script"><i class="fa fa-wrench"></i> Code</label> <input type="hidden" id="node-input-script" autofocus="autofocus"> <input type="hidden" id="node-input-noerr"> </div> <div class="form-row node-text-editor-row"> <div style="height: 250px;" class="node-text-editor" id="node-input-script-editor" ></div> </div> </script> <script type="text/javascript"> RED.nodes.registerType('pitft out',{ category: "output", icon: "feed.png", color: "#AAFFAA", inputs: 1, defaults: { name: { value: "LCD" }, device: {value: "/dev/fb1", required: true}, script: {value: "", required: true }, }, label: function() { return this.name || "LCD"; }, oneditprepare: function() { var that = this; function functionDialogResize() { var rows = $("#dialog-form>div:not(.node-text-editor-row)"); var height = $("#dialog-form").height(); for (var i=0;i<rows.size();i++) { height -= $(rows[i]).outerHeight(true); } var editorRow = $("#dialog-form>div.node-text-editor-row"); height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom"))); $(".node-text-editor").css("height",height+"px"); that.editor.resize(); } $( "#dialog" ).on("dialogresize", functionDialogResize); $( "#dialog" ).one("dialogopen", function(ev) { var size = $( "#dialog" ).dialog('option','sizeCache-function'); if (size) { $("#dialog").dialog('option','width',size.width); $("#dialog").dialog('option','height',size.height); functionDialogResize(); } }); $( "#dialog" ).one("dialogclose", function(ev,ui) { var height = $( "#dialog" ).dialog('option','height'); $( "#dialog" ).off("dialogresize",functionDialogResize); }); this.editor = RED.editor.createEditor({ id: 'node-input-script-editor', mode: 'ace/mode/javascript', value: $("#node-input-script").val() }); RED.library.create({ url:"lcdfunctions", // where to get the data from type:"functions", // the type of object the library is for editor:this.editor, // the field name the main text body goes to mode:"ace/mode/javascript", fields:['name','device'] }); this.editor.focus(); }, oneditsave: function() { var annot = this.editor.getSession().getAnnotations(); this.noerr = 0; $("#node-input-noerr").val(0); for (var k=0; k < annot.length; k++) { //console.log(annot[k].type,":",annot[k].text, "on line", annot[k].row); if (annot[k].type === "error") { $("#node-input-noerr").val(annot.length); this.noerr = annot.length; } } $("#node-input-script").val(this.editor.getValue()); delete this.editor; } }); </script> <script type="text/x-red" data-help-name="pitft out"> <p>Node to use ir receiver in banana pi</p> <p>Outputs an object called <b>msg</b> containing <b>msg.payload</b>. msg.payload is a key code or mapped value if exists in configuration.</p> </script>