Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Last revision Both sides next revision | ||
blocks:app-note:basic-interaction-from-a-custom-web-page [2021-05-01 15:20] admin created |
blocks:app-note:basic-interaction-from-a-custom-web-page [2021-05-01 15:33] admin Added illustration |
||
---|---|---|---|
Line 16: | Line 16: | ||
- Open a second browser window to the same address as the editor window, but replace /edit/xxx with / | - Open a second browser window to the same address as the editor window, but replace /edit/xxx with / | ||
- Click the //One// button. | - Click the //One// button. | ||
+ | |||
+ | {{ : | ||
When you click the button, the " | When you click the button, the " | ||
Line 63: | Line 65: | ||
This // | This // | ||
- | :!: The URL specified in the //fetch// request omits the protocol and server name. That's OK since the web page is served from the same source as the fetch request calling out to. If your web page isn't hosted on your Blocks server, you need to prefix the URL with the protocol and host name (or IP address), like this: | + | :!: The URL specified in the //fetch// request omits the protocol and server name. That's OK since the fetch request is calling back to same server as the web page is served from the. If your web page isn't hosted on your Blocks server, you need to prefix the URL with the protocol and host name (or IP address), like this: |
< | < | ||
Line 69: | Line 71: | ||
</ | </ | ||
+ | Here, the server is assumed to be at IP address 10.1.0.10, and responding to the standard http port 80. If you're running on your laptop, you may need to add //:8080// after that IP address (see the URL used in the blocks editor web page). | ||
==== User Script ==== | ==== User Script ==== | ||
- | Code also exists on the server side (in the files script/ | + | Code also exists on the server side (in the files script/ |
Much of the script file is comments, with the most interesting part being the //start// function. As you can see, the name of this function corresponds to the last word in the URL called from the custom web page. Likewise, the name of the user script (WebTask) corresponds to the second last part of the URL (see above). Here's the start function that does the heavy lifting in this script: | Much of the script file is comments, with the most interesting part being the //start// function. As you can see, the name of this function corresponds to the last word in the URL called from the custom web page. Likewise, the name of the user script (WebTask) corresponds to the second last part of the URL (see above). Here's the start function that does the heavy lifting in this script: | ||
Line 105: | Line 108: | ||
==== Next Step ==== | ==== Next Step ==== | ||
- | While the above example may be perfectly adequate for what you want to accomplish, the application note titled " | + | While the above example may be perfectly adequate for what you want to accomplish, the application note titled "[[blocks: |