Hello,
currently I'm using this code in a template_ui node to create a color selector on my dashboard. This is working fine so far.
But I don't want it to be shown permanently on the dashboard, but rather in a browser popup, when triggered.
My first idea was to inject the hole code into a notification with " Accept raw HTML/JavaScript input..." activated. Sadly this doesn't worked. (Could have been so easy ;))
Example:
[{"id":"e237defc.5d472","type":"template","z":"7510731b.b51ddc","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"plain","template":"<script src=\"/iro.min.js\"></script>\n<script>\n var theScope = scope;\n var storedStateColor = getLastColor(theScope);\n var colorPicker;\n function initIroJs(){if(typeof(iro) === 'object'){colorPicker = new iro.ColorPicker(\"#color-picker-container\",{width: 300,color: storedStateColor,layout: [{component: iro.ui.Wheel,},]});colorPicker.on('input:end', onColorChange);}else{setTimeout(function() { initIroJs(); }, 250);}}\n function onColorChange(){theScope.send({ payload: colorPicker.color.rgb });}function messageReceived(payload){if(typeof(colorPicker) === 'object'){colorPicker.color.rgb = payload;}}\n function getLastColor(theScope){if(typeof(theScope.msg) === 'object'){if(typeof(theScope.msg.payload) === 'object' &&theScope.msg.payload.match(/r:/)){return theScope.msg.payload;}}return 'rgb(255, 255, 0)';}\n theScope.$watch('msg.payload', messageReceived);\n initIroJs();\n</script>\n<div id=\"color-picker-container\" style=\"min-height: 350px;\"></div>","output":"str","x":420,"y":520,"wires":[["77e8efa1.ae8f7"]]},{"id":"29bdc443.b3722c","type":"inject","z":"7510731b.b51ddc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":270,"y":520,"wires":[["e237defc.5d472"]]},{"id":"77e8efa1.ae8f7","type":"ui_toast","z":"7510731b.b51ddc","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":true,"topic":"","name":"","x":610,"y":520,"wires":[[]]}]
Do you have any suggestions to get this work?
Thanks