|
5 | 5 | <meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"> |
6 | 6 | <title>LaunchDarkly tutorial</title> |
7 | 7 | <script src="https://unpkg.com/launchdarkly-js-client-sdk@3"></script> |
| 8 | + <link rel="stylesheet" href="./index.css"> |
8 | 9 | </head> |
9 | 10 | <body> |
10 | 11 | <script> |
|
14 | 15 | const clientSideID = ''; |
15 | 16 |
|
16 | 17 | // Set flagKey to the feature flag key you want to evaluate |
17 | | - const flagKey = 'my-boolean-flag'; |
| 18 | + const flagKey = 'sample-feature'; |
18 | 19 |
|
19 | | - // Set up the context properties. This context should appear on your |
| 20 | + // Set up the evaluation context. This context should appear on your |
20 | 21 | // LaunchDarkly contexts dashboard soon after you run the demo. |
21 | 22 | const context = { |
22 | 23 | kind: 'user', |
|
37 | 38 |
|
38 | 39 | function render() { |
39 | 40 | const flagValue = ldclient.variation(flagKey, false); |
40 | | - const label = 'Feature flag ' + flagKey + ' is ' + flagValue + ' for this context. '; |
| 41 | + const label = `The ${flagKey} feature flag evalutes to ${flagValue}.`; |
| 42 | + document.body.style.background = flagValue ? '#00844B' : '#373841'; |
41 | 43 | div.replaceChild(document.createTextNode(label), div.firstChild); |
42 | 44 | } |
43 | 45 |
|
44 | 46 | ldclient.on('initialized', () => { |
45 | | - div.appendChild(document.createTextNode('SDK successfully initialized!'), div.firstChild); |
| 47 | + div.replaceChild(document.createTextNode('SDK successfully initialized!'), div.firstChild); |
46 | 48 | }); |
47 | 49 | ldclient.on('failed', () => { |
48 | | - div.appendChild(document.createTextNode('SDK failed to initialize'), div.firstChild); |
| 50 | + div.replaceChild(document.createTextNode('SDK failed to initialize'), div.firstChild); |
49 | 51 | }); |
50 | 52 | ldclient.on('ready', render); |
51 | 53 | ldclient.on('change', render); |
|
0 commit comments