Created
December 8, 2017 18:44
-
-
Save wlib/b03f8acf5f90bd240f6d21adf04c08e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getWidgetURL(options) { | |
const url = new URL("https://s.tradingview.com/widgetembed/"); | |
const defaultOptions = { | |
symbol: "BTCUSD", | |
interval: 60, | |
hidesidetoolbar: 0, | |
symboledit: 1, | |
saveimage: 1, | |
toolbarbg: "f1f3f6", | |
theme: "Light", | |
style: 1, | |
timezone: "America/New_York", | |
locale: "en" | |
}; | |
const finalOptions = Object.assign({}, defaultOptions, options); | |
for (let key in finalOptions) { | |
url.searchParams.set(key, finalOptions[key]); | |
} | |
return url.href; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment