Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

could anyone explain the Webserver demo file

If you have a question or need help, this is the place to be.
Post Reply
Sonopanic
Posts: 22
Joined: Mon Dec 08, 2008 8:30 am

could anyone explain the Webserver demo file

Post by Sonopanic »

It works, but i don┬┤t know how. http://www.eventghost.org/downloads/Webserver_Demo.zip

Do i need all the cryptic functions ?

What is "case" in the KeyDownHandler function ?

I like to build a webpage with a few nice buttons (png).
Like Play, Stop, Rewind and Forward.
How do i manage the detection of the clicked button ?
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: could anyone explain the Webserver demo file

Post by jinxdone »

You can trigger events using the webserver by sending the event name and payload as parameters of the http request. so the url will be something like http://localhost/?foo=bar&something=else.

In the example's html:

TriggerEvent is an utility function that constructs an appropriate URL and then sends an http request to it using an ajax(in the background).

For example, if you want to create an image that will trigger an event when clicked all you should need to do is run the TriggerEvent function, something like

Code: Select all

<img src="myimage.png" onClick="TriggerEvent('myevent');">
The rest is related to handling keyboard input. Here a quick summary how that works in the example.
  • Pressing a key on your keyboard raises a javascript onkeydown event when the document is in focus
  • The onkeydown event is bound to run the function KeyDownHandler()
  • The 'event' parameter for KeyDownHandler contains information including a keycode of the key that was pressed (this is the event.which variable)
  • In KeyDownHandler the switch...case statement runs a piece of code when event.which matches a certain value. The switch...case is basically a more convenient way of writing a long list of if..then..elseif statements.
  • When you release a key on the keyboard it will send a "ButtonReleased" event.
This is not really EG specific, to learn more and get up to speed with your javascript 101 I would recommend the w3cschools tutorials on the subject.

-jinxdone
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: could anyone explain the Webserver demo file

Post by Livin »

I have not looked into it but is there a function that will query EG for all the Macros and any Comment objects (or something similar) inside it?

It would be cool to have a web page that would auto generate a list of Macros and create buttons for them. The reason for the association is so that users could add a Comment to the Macro to exclude it from the list. I could do this by Macro name, but that is not very clean.

I have a similar page I made for my Homeseer app that I may be able to port over if this is possible. I was hoping that the Android app would do this but I'm not sure how much more development will be done on it.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Sonopanic
Posts: 22
Joined: Mon Dec 08, 2008 8:30 am

Re: could anyone explain the Webserver demo file

Post by Sonopanic »

This Triggerevent looks interesting.

I have testet this :
<a href="?music"><img src="music.jpg"></a>

This send "html.music" to EG. So it works, but the Navibar in Firefox show the output too.
Post Reply