Updated to support script inside a tag
Updated tradeview sample
This commit is contained in:
Mikael Svenson 2020-06-22 14:16:12 +02:00
parent 3dd0ee134c
commit 1fe2cd381b
3 changed files with 44 additions and 41 deletions

View File

@ -31,26 +31,28 @@ As an example add the following scripts to the web part in order to show stock t
```html
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_ab4e5"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-MSFT/" rel="noopener" target="_blank"><span class="blue-text">MSFT chart</span></a> by TradingView</div>
</div>
<div id="tradingview_e7aa0"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-AAPL/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
"width": 400,
"height": 200,
"symbol": "NASDAQ:MSFT",
new TradingView.widget(
{
"width": 980,
"height": 610,
"symbol": "NASDAQ:AAPL",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "Light",
"theme": "light",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_ab4e5"
});
"container_id": "tradingview_e7aa0"
}
);
</script>
</div>
<!-- TradingView Widget END -->
```

View File

@ -140,12 +140,11 @@ export default class ScriptEditorWebPart extends BaseClientSideWebPart<IScriptEd
// main section of function
const scripts = [];
const children_nodes = element.childNodes;
const children_nodes = element.getElementsByTagName("script");
for (let i = 0; children_nodes[i]; i++) {
const child: any = children_nodes[i];
if (this.nodeName(child, "script") &&
(!child.type || child.type.toLowerCase() === "text/javascript")) {
if (!child.type || child.type.toLowerCase() === "text/javascript") {
scripts.push(child);
}
}

View File

@ -29,26 +29,28 @@ As an example add the following scripts to the web part in order to show stock t
```html
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_ab4e5"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-MSFT/" rel="noopener" target="_blank"><span class="blue-text">MSFT chart</span></a> by TradingView</div>
</div>
<div id="tradingview_e7aa0"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-AAPL/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
"width": 400,
"height": 200,
"symbol": "NASDAQ:MSFT",
new TradingView.widget(
{
"width": 980,
"height": 610,
"symbol": "NASDAQ:AAPL",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "Light",
"theme": "light",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_ab4e5"
});
"container_id": "tradingview_e7aa0"
}
);
</script>
</div>
<!-- TradingView Widget END -->
```