Nice. Was going to do a scrolling one next. Want a sports version and a news one too. Wonder if I can get my solar panel production - there is an app but not sure if they have some kind of API call.
My solar setup has a web info page that gets updated with my info. So Ill need to parse the info I want displayed then put it into the ticker tape. My solar setup is mostly magnum stuff thougth I do have a morning star charge controler which has a serial port to get info also have a outback controler but I donât have a way to pull info from it yet. There is very little to change to what you have for a scrolling ticker for the stock info!
I had a bit of time to play last night with this and although I donât follow the stock market I thought Iâd see how much I could strip this down and customize it to match my other widgets look wise.
You can remove all code starting with the line that starts off with <div class=âtradingview-widget-copyrightâ to the line " TradingView Widget END -->" with out affecting the performance.
that should help when you start to add options
I happened to notice this morning when I was playing with this that the URL inside the iframe definition is what is controlling the stock symbols and description that appear.
So I have been trying to figure out how to have a JavaScript defined variable for the iframe src and then define that using some widget params.
But not having much luck with that.
If I have a chance Iâll look at that. I suspect youâd have to list the stocks available and just have users select them.
I also started to play with having the ticker tape go from one side of HG to the other side using the groups bar and it is possible.
Here is the latest widget I have.
At the end of the HTML code, I have this code:
The iframe in the body of the widget has src=âblank.hlmlâ
This is updating the src with that link (I used some text here for illustration purposes as the actual link is very long).
In the JavaScript code for the Widget, I have vars defined with the ConfigureOptions from the Program - 5 sets of them, one each for a symbol and a description so a total of 5 stocks.
I am trying to build the url to pass to the aforementioned script code in the HTML portion of the widget with a variable called source.- using an encore url function.
Trying to get the variable to work, at this point I just have the hardcoded url example from the site assigned to variable source.
However, I cannot seem to reference that variable in the HTML portion. I have tried the following but each gives me an error when I try and run the widget code:
- document.getElementById(âstocksâ).src=source;
- document.getElementById(âstocksâ).src=data-ui-field=âsourceâ
- document.getElementById(âstocksâ).src=widget.find(â[data-ui-field=source]â).Value
Assuming I can reference the variable on the HTML page, then its just a matter of building the url and passing it along (also want to base the width of the widget on the number of symbols defined).
Any assistance would be appreciated. Thanks
1037-Stock_Ticker.hgx (1.7 KB)
homegenie_generic_ticker (1).zip (2.6 KB)
I believe your options should be handled by the program not the widget.
Build a string in the program then pass that to the java script part of the widget
Look at the homegenie/generic/status widget to see how info is passed from the JavaScript to html
in order to pass the info from the java script to the html part you need to define in the html section a ui field
<div data-ui-field="stockstatus"></div>
Then in your java script side add the line after youâve defined your source
widget.find('[data-ui-field=stockstatus]').html(source)
;
that should give you a starting point
Ok, that makes sense - not sure why but I was making it more complicated than it needed to be.
Thatâs the good news.
Bad news - doesnât look like it takes an actual URL but needs it to be structured more like the embedded code they give you - each stock looks like a separate div in the end. I need to play with it some more - but making some progress.
I found a different source to use for the actual ticker widget - it allows customization of the contents etc and then its more a straightforward plug and play into the widget I created.
This is a working version, still could use some tweaking which I will work on next.
1037-Stock_Ticker.hgx (1.5 KB)
homegenie_generic_ticker.zip (1.7 KB)
I found a free code generator for RSS feeds it will allow up to 5 RSS feeds. You may wish to look at it for your RSS feed ideas https://surfing-waves.com/feed.htm
Maybe allow combining all your needs into one widget.
I finally got around to finishing the sports score one - will post that in a separate thread. When I get a chance I will try the RSS feed one.
I was hoping to create a RSS reader to display my Off grid status but since it didnât supply a RSS feed I thought Iâd just display the web page then I found this https://politepol.com/en/ it will make a RSS feed from any site.
tested this tool with my off grid web page and it works great.