From 34757699d0b8e9d6b60fd4ec1b256283ca8855ea Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 3 Nov 2020 16:43:59 +0100 Subject: [PATCH] add perl/cgi web app --- index.cgi | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++ iro.min.js | 7 +++ 2 files changed, 144 insertions(+) create mode 100755 index.cgi create mode 100644 iro.min.js diff --git a/index.cgi b/index.cgi new file mode 100755 index 0000000..97012f6 --- /dev/null +++ b/index.cgi @@ -0,0 +1,137 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use 5.014; + +my $host = "10.42.0.74"; + +use IO::Socket; + +my $s = IO::Socket::INET->new( + Proto => 'udp', + PeerAddr => $host, + PeerPort => 1337, + Timeout => 1, +) or die "socket"; + + +if ($ENV{QUERY_STRING} =~ /o(n|ff)/) { + $s->send(pack("C*", 1, ($1 eq 'n'))); +} elsif ($ENV{QUERY_STRING} =~ /[0-9a-f]+/i) { + my ($r,$g,$b) = unpack("C*", pack("H*",$ENV{QUERY_STRING})); + $s->send(pack("C*", 2, $r, $g/2, $b/2)); +} + +if ($ENV{QUERY_STRING}) { + print "status: 204 no content\r\n\r\n"; + exit 0; +} + +my $buf = ""; +$s->send("\x00"); +$s->recv($buf,5); +my ($ok, $power, $r, $g, $b) = unpack("C*", $buf); +my $color = sprintf("%02x%02x%02x", $r, 2*$g, 2*$b); + +print "content-type: text/html\r\n\r\n"; +print ""; +print ; + + + +__DATA__ +ESP8266 Ledberg + + + + + + +
+
+ +
+
+
+ + diff --git a/iro.min.js b/iro.min.js new file mode 100644 index 0000000..147da15 --- /dev/null +++ b/iro.min.js @@ -0,0 +1,7 @@ +/*! + * iro.js v5.2.3 + * 2016-2020 James Daniel + * Licensed under MPL 2.0 + * github.com/jaames/iro.js + */ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).iro=t()}(this,function(){"use strict";var m,s,t,i,o,k={},M=[],r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;function j(n,t){for(var i in t)n[i]=t[i];return n}function y(n){var t=n.parentNode;t&&t.removeChild(n)}function d(n,t,i){var r,e,u,o,l=arguments;if(t=j({},t),3=r/i?u=t:e=t}return t},V.hsv.get=function(){var n=this.$;return{h:n.h,s:n.s,v:n.v}},V.hsv.set=function(n){var t=this.$;if(n=Object.assign({},t,n),this.onChange){var i={h:!1,v:!1,s:!1,a:!1};for(var r in t)i[r]=n[r]!=t[r];this.$=n,(i.h||i.s||i.v||i.a)&&this.onChange(this,i)}else this.$=n},V.hsva.get=function(){return Object.assign({},this.$)},V.hsva.set=function(n){this.hsv=n},V.hue.get=function(){return this.$.h},V.hue.set=function(n){this.hsv={h:n}},V.saturation.get=function(){return this.$.s},V.saturation.set=function(n){this.hsv={s:n}},V.value.get=function(){return this.$.v},V.value.set=function(n){this.hsv={v:n}},V.alpha.get=function(){return this.$.a},V.alpha.set=function(n){this.hsv=Object.assign({},this.hsv,{a:n})},V.kelvin.get=function(){return Q.rgbToKelvin(this.rgb)},V.kelvin.set=function(n){this.rgb=Q.kelvinToRgb(n)},V.red.get=function(){return this.rgb.r},V.red.set=function(n){this.rgb=Object.assign({},this.rgb,{r:n})},V.green.get=function(){return this.rgb.g},V.green.set=function(n){this.rgb=Object.assign({},this.rgb,{g:n})},V.blue.get=function(){return this.rgb.b},V.blue.set=function(n){this.rgb=Object.assign({},this.rgb,{b:n})},V.rgb.get=function(){var n=Q.hsvToRgb(this.$),t=n.r,i=n.g,r=n.b;return{r:L(t),g:L(i),b:L(r)}},V.rgb.set=function(n){this.hsv=Object.assign({},Q.rgbToHsv(n),{a:void 0===n.a?1:n.a})},V.rgba.get=function(){return Object.assign({},this.rgb,{a:this.alpha})},V.rgba.set=function(n){this.rgb=n},V.hsl.get=function(){var n=Q.hsvToHsl(this.$),t=n.h,i=n.s,r=n.l;return{h:L(t),s:L(i),l:L(r)}},V.hsl.set=function(n){this.hsv=Object.assign({},Q.hslToHsv(n),{a:void 0===n.a?1:n.a})},V.hsla.get=function(){return Object.assign({},this.hsl,{a:this.alpha})},V.hsla.set=function(n){this.hsl=n},V.rgbString.get=function(){var n=this.rgb;return"rgb("+n.r+", "+n.g+", "+n.b+")"},V.rgbString.set=function(n){var t,i,r,e,u=1;if((t=b.exec(n))?(i=q(t[1],255),r=q(t[2],255),e=q(t[3],255)):(t=p.exec(n))&&(i=q(t[1],255),r=q(t[2],255),e=q(t[3],255),u=q(t[4],1)),!t)throw new Error("Invalid rgb string");this.rgb={r:i,g:r,b:e,a:u}},V.rgbaString.get=function(){var n=this.rgba;return"rgba("+n.r+", "+n.g+", "+n.b+", "+n.a+")"},V.rgbaString.set=function(n){this.rgbString=n},V.hexString.get=function(){var n=this.rgb;return"#"+K(n.r)+K(n.g)+K(n.b)},V.hexString.set=function(n){var t,i,r,e,u=255;if((t=W.exec(n))?(i=17*J(t[1]),r=17*J(t[2]),e=17*J(t[3])):(t=C.exec(n))?(i=17*J(t[1]),r=17*J(t[2]),e=17*J(t[3]),u=17*J(t[4])):(t=D.exec(n))?(i=J(t[1]),r=J(t[2]),e=J(t[3])):(t=F.exec(n))&&(i=J(t[1]),r=J(t[2]),e=J(t[3]),u=J(t[4])),!t)throw new Error("Invalid hex string");this.rgb={r:i,g:r,b:e,a:u/255}},V.hex8String.get=function(){var n=this.rgba;return"#"+K(n.r)+K(n.g)+K(n.b)+K(B(255*n.a))},V.hex8String.set=function(n){this.hexString=n},V.hslString.get=function(){var n=this.hsl;return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},V.hslString.set=function(n){var t,i,r,e,u=1;if((t=P.exec(n))?(i=q(t[1],360),r=q(t[2],100),e=q(t[3],100)):(t=z.exec(n))&&(i=q(t[1],360),r=q(t[2],100),e=q(t[3],100),u=q(t[4],1)),!t)throw new Error("Invalid hsl string");this.hsl={h:i,s:r,l:e,a:u}},V.hslaString.get=function(){var n=this.hsla;return"hsl("+n.h+", "+n.s+"%, "+n.l+"%, "+n.a+")"},V.hslaString.set=function(n){this.hslString=n},Object.defineProperties(Q.prototype,V);var X;function Y(n){var t=n.width,i=n.sliderSize,r=n.borderWidth,e=n.handleRadius,u=n.padding,o=n.sliderShape,l="horizontal"===n.layoutDirection;return i=i||2*u+2*e+2*r,"circle"===o?{handleStart:n.padding+n.handleRadius,handleRange:t-2*u-2*e-2*r,width:t,height:t,cx:t/2,cy:t/2,radius:t/2-r/2}:{handleStart:i/2,handleRange:t-i,radius:i/2,x:0,y:0,width:l?i:t,height:l?t:i}}function Z(n,t){var i=Y(n),r=i.width,e=i.height,u=i.handleRange,o=i.handleStart,l="horizontal"===n.layoutDirection,s=l?r/2:e/2,c=o+function(n,t){var i=t.hsva,r=t.rgb;switch(n.sliderType){case"red":return r.r/2.55;case"green":return r.g/2.55;case"blue":return r.b/2.55;case"alpha":return 100*i.a;case"kelvin":var e=n.minTemperature,u=n.maxTemperature-e,o=(t.kelvin-e)/u*100;return Math.max(0,Math.min(o,100));case"hue":return i.h/=3.6;case"saturation":return i.s;case"value":default:return i.v}}(n,t)/100*u;return l&&(c=-1*c+u+2*o),{x:l?s:c,y:l?c:s}}function nn(n){var t=n.width/2;return{width:n.width,radius:t-n.borderWidth,cx:t,cy:t}}function tn(n,t,i){var r=n.wheelAngle,e=n.wheelDirection;return((t=!i&&"clockwise"===e||i&&"anticlockwise"===e?(i?180:360)-(r-t):r+t)%360+360)%360}function rn(n,t,i){var r=nn(n),e=r.cx,u=r.cy,o=n.width/2-n.padding-n.handleRadius-n.borderWidth;t=e-t,i=u-i;var l=tn(n,Math.atan2(-i,-t)*(180/Math.PI)),s=Math.min(Math.sqrt(t*t+i*i),o);return{h:Math.round(l),s:Math.round(100/o*s)}}function en(n){var t=n.width;return{width:t,height:t,radius:n.padding+n.handleRadius}}function un(n,t,i){var r=en(n),e=r.width,u=r.height,o=r.radius,l=(t-o)/(e-2*o)*100,s=(i-o)/(u-2*o)*100;return{s:Math.max(0,Math.min(l,100)),v:Math.max(0,Math.min(100-s,100))}}function on(n){X=X||document.getElementsByTagName("base");var t=window.navigator.userAgent,i=/^((?!chrome|android).)*safari/i.test(t),r=/iPhone|iPod|iPad/i.test(t),e=window.location;return(i||r)&&0