Add js click handlers for the web UI buttons added in
b1f9c9a6e0a3dce73507e6b60782987ee2459f48 in the esphome repository.
Since this change doesn't make the .js file incompatible with esphome
versions before the referenced commit I guess there's no need to
rename the file to -v2.
There are probably better ways to write those click handlers, for
example we could have a common function to launch the POST request to a
URL that it reads from the button object like this:
var button_onclick = function(evt) {
const xhr = new XMLHttpRequest();
xhr.open("POST", evt.target.onlick_post_url, true);
xhr.send();
};
row.children[2].children[0].addEventListener('click', button_onlick);
row.children[2].children[0].onclick_post_url = '/light/' + id.substr(6) + '/toggle';
The only problem with this is that iirc ``evt.target`` is
browser-specific.
* ifan02 cookbook
* removed spaces
* removed spaces
* indent codeblock, newline at end
* fixes
* add seo :image:
* spaces...
* Complete the example code & fix compilation errors
Tried compiling this code today using ESPHome 1.13.6.. it would not compile.
* The ifan02.h file was the main culprit and I was able to fix the issue.
* The .yaml example was missing a few declarations at the beginning so I added them.
* I fixed an error related to using ```light``` for the light id since that is a reserved name.
* I added an ```on_boot``` declaration to turn off the light as early as possible after power is restored. (if mains power is restored in the middle of the night and the light turns on while you are sleeping it can be quite annoying, this turns it off during the boot process).
* removed blank spaces on line 66
Those blank spaces get me every time ;-)
* fix doc links (hopefully)
I think my last PR was made against the wrong fork/branch/etc... sorry, I'm still learning github.
I currently have the time and really want to see this make it into the cookbook. I think if you add me as a collaborator I would be able to push the changes and help get the errors sorted more quickly; if not, no worries, I'll take no offense and do my best to continue helping as we are doing now.
* fix fan link
replace
```
:doc:`/components/fan`
```
with
```
:doc:`/components/fan/index`
```
Co-authored-by: mjoshd <35782597+mjoshd@users.noreply.github.com>
Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>