How to obtain a webserver variable's value from webpage?
Posted: Wed Jul 06, 2016 6:27 pm
Hi everyone!
This is my first time posting, although I've been observing for awhile now. My issue/inquiry is in reference to the Webserver plugin. I have a webserver running locally and are port-forwarding it so I can access it online. On the (simple) webpage I have up, there is a button that when clicked sends an HTTP request to EG and runs a few scripts. What I've been looking to do is when I click the button I would like Eventghost to somehow be able to send me a response in some (any) way letting me know what percentage of the macro is complete. My original thought/idea was to have a progress bar appear maybe below the button and fill it as each process completes. However, after aimlessly scouring search engines and this forum I haven't come across a solution that matches what I'd like to do. The best I got was a vague idea of how I might be able to do it:
1. Clicking the button on the webpage > sends HTTP request > triggers macro that runs scripts
2. As each script completes, update a Webserver temporary variable (scriptProgress) by increments of 5 until it reaches 100 (when all the scripts have been run)
3. Each time a script complete, have EG return a JSON string containing the scriptProgress' updated value > Update the progress bar on the webpage accordingly.
Is this even possible though? I've also heard about doing Ajax calls to accomplish something like this, but am clueless about Ajax
As is probably obvious, I'm completely new to EG and have only been messing with it for a few weeks in my free time. If what I've explained isn't possible is there any other way that you could suggest that would help me achieve the same result (or close to it)? Examples of how to make this happen would be greatly appreciated.
Here's what I have so far:
1. I'm able to trigger a macro by making the HTTP call. I know it works because it shows up in the EG Log and also the popup is produced on my main computer
2. I think I figured out how to create and adjust a temporary webserver variable's value

3. As I stated above, I have a simple mock website with the following html
It's not supposed to be anything fancy; especially since my wife and I are the only ones who are going to be using it from our home to run scripts on our computers in the office. The idea is to help avoid our employees from having to touch (and inevitably screw up) the server when there are issues.
1. Clicking the button on the webpage > sends HTTP request > triggers macro that runs scripts
2. As each script completes, update a Webserver temporary variable (scriptProgress) by increments of 5 until it reaches 100 (when all the scripts have been run)
3. Each time a script complete, have EG return a JSON string containing the scriptProgress' updated value > Update the progress bar on the webpage accordingly.
Is this even possible though? I've also heard about doing Ajax calls to accomplish something like this, but am clueless about Ajax
Here's what I have so far:
1. I'm able to trigger a macro by making the HTTP call. I know it works because it shows up in the EG Log and also the popup is produced on my main computer
2. I think I figured out how to create and adjust a temporary webserver variable's value

3. As I stated above, I have a simple mock website with the following html
Code: Select all
<html>
<head>
<title>Action Button</title>
<style>
body{
background-repeat:no-repeat;
background-attachment:absolute;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
background-size: 100% 100%;
}
#top{
width:100%;
height:38%;
margin: 0 auto;
}
.image-blurred-edge{
opacity:.5;
width: 40%;
height:100%;
background-image: url('http://www.finedesigndine.us/wp-content/uploads/2012/03/exterior.jpg');
background-size: 100% 100%;
background-repeat:no-repeat;
display:block;
margin-left: auto;
margin-right: auto;
box-shadow: 0 0 8px 8px rgba(255, 255, 255, 0.5) inset;
-moz-box-shadow: 0 0 8px 8px rgba(255, 255, 255, 0.5) inset;
-webkit-box-shadow: 0 0 8px 8px rgba(255, 255, 255, 0.5) inset;
}
</style>
</head>
<body background='http://i.imgur.com/Gj7b3Ms.jpg'>
<div id="content">
<div id="top"><div class='image-blurred-edge'></div></div>
Ready on your command<br>
<a id='startscripts' href="eventghost.html?nuke">
<img border="0" src="http://img-aws.ehowcdn.com/640/cme/photography.prod.demandstudios.com/dcfb57aa-671d-4a56-af65-005280736c15.jpg" />
</a>
</div>
</body>
</html>