|
1 | | -function callback(response) { |
2 | | - const div = document.createElement('div'); |
3 | | - div.innerHTML = response.html; |
4 | | - document.body.appendChild(div); |
5 | | - const container = div.querySelector('.rst-versions'); |
6 | | - div.querySelector('.rst-current-version').addEventListener('click', function() { |
7 | | - const classes = container.className.split(' '); |
8 | | - const index = classes.indexOf('shift-up'); |
9 | | - if (index === -1) { |
10 | | - classes.push('shift-up'); |
11 | | - } else { |
12 | | - classes.splice(index, 1); |
13 | | - } |
14 | | - container.className = classes.join(' '); |
15 | | - }); |
16 | | -} |
| 1 | +(function() { |
| 2 | + const callbackName = 'callback_' + new Date().getTime(); |
| 3 | + window[callbackName] = function (response) { |
| 4 | + const div = document.createElement('div'); |
| 5 | + div.innerHTML = response.html; |
| 6 | + document.body.appendChild(div); |
| 7 | + const container = div.querySelector('.rst-versions'); |
| 8 | + div.querySelector('.rst-current-version').addEventListener('click', function() { |
| 9 | + const classes = container.className.split(' '); |
| 10 | + const index = classes.indexOf('shift-up'); |
| 11 | + if (index === -1) { |
| 12 | + classes.push('shift-up'); |
| 13 | + } else { |
| 14 | + classes.splice(index, 1); |
| 15 | + } |
| 16 | + container.className = classes.join(' '); |
| 17 | + }); |
| 18 | + } |
| 19 | + |
| 20 | + var script = document.createElement('script'); |
| 21 | + script.src = 'https://argocd-notifications.readthedocs.io/_/api/v2/footer_html/?'+ |
| 22 | + 'callback=' + callbackName + '&project=argocd-notifications&page=&theme=mkdocs&format=jsonp&docroot=docs&source_suffix=.md&version=' + (window['READTHEDOCS_DATA'] || { version: 'latest' }).version; |
| 23 | + |
| 24 | + document.getElementsByTagName('head')[0].appendChild(script); |
| 25 | +})(); |
17 | 26 |
|
18 | | -var script = document.createElement('script'); |
19 | | -script.src = 'https://argocd-notifications.readthedocs.io/_/api/v2/footer_html/?'+ |
20 | | - 'callback=callback&project=argocd-notifications&page=&theme=mkdocs&format=jsonp&docroot=docs&source_suffix=.md&version=' + (window['READTHEDOCS_DATA'] || { version: 'latest' }).version; |
21 | | - |
22 | | -document.getElementsByTagName('head')[0].appendChild(script); |
|
0 commit comments