|
43 | 43 | {{ super() }} |
44 | 44 |
|
45 | 45 | {%- if not embedded %} |
46 | | -<metaname="readthedocs-addons-api-version"content="1"> |
47 | | -<scripttype="text/javascript"> |
48 | | -functiononSwitch(event){ |
49 | | -constoption=event.target.selectedIndex; |
50 | | -constitem=event.target.options[option]; |
51 | | -window.location.href=item.dataset.url; |
52 | | -} |
53 | | - |
54 | | -document.addEventListener("readthedocs-addons-data-ready",function(event){ |
55 | | -constconfig=event.detail.data() |
56 | | - |
57 | | -// Add some mocked hardcoded versions pointing to the official |
58 | | -// documentation while migrating to Read the Docs. |
59 | | -// These are only for testing purposes. |
60 | | -// TODO: remove them when managing all the versions on Read the Docs, |
61 | | -// since all the "active, built and not hidden" versions will be shown automatically. |
62 | | -letversions=config.versions.active.concat([ |
63 | | -{ |
64 | | -slug:"dev (3.14)", |
65 | | -urls:{ |
66 | | -documentation:"https://docs.python.org/3.14/", |
67 | | -} |
68 | | -}, |
69 | | -{ |
70 | | -slug:"pre (3.13)", |
71 | | -urls:{ |
72 | | -documentation:"https://docs.python.org/3.13/", |
73 | | -} |
74 | | -}, |
75 | | -{ |
76 | | -slug:"3.12", |
77 | | -urls:{ |
78 | | -documentation:"https://docs.python.org/3.12/", |
79 | | -} |
80 | | -}, |
81 | | -{ |
82 | | -slug:"3.11", |
83 | | -urls:{ |
84 | | -documentation:"https://docs.python.org/3.11/", |
85 | | -} |
86 | | -}, |
87 | | -]); |
88 | | - |
89 | | -constversionSelect=` |
90 | | - <select id="version_select"> |
91 | | -${versions.map( |
92 | | -(version)=>` |
93 | | - <option |
94 | | - value="${version.slug}" |
95 | | -${config.versions.current.slug===version.slug ?'selected="selected"' :''} |
96 | | - data-url="${version.urls.documentation}"> |
97 | | -${version.slug} |
98 | | - </option>` |
99 | | -).join("\n")} |
100 | | - </select> |
101 | | - `; |
102 | | - |
103 | | -// Prepend the current language to the options on the selector |
104 | | -letlanguages=config.projects.translations.concat(config.projects.current); |
105 | | -languages=languages.sort((a,b)=>a.language.name.localeCompare(b.language.name)); |
106 | | - |
107 | | -constlanguageSelect=` |
108 | | - <select id="language_select"> |
109 | | -${languages.map( |
110 | | -(translation)=>` |
111 | | - <option |
112 | | - value="${translation.slug}" |
113 | | -${config.projects.current.slug===translation.slug ?'selected="selected"' :''} |
114 | | - data-url="${translation.urls.documentation}"> |
115 | | -${translation.language.name} |
116 | | - </option>` |
117 | | -).join("\n")} |
118 | | - </select> |
119 | | - `; |
120 | | - |
121 | | -// Query all the placeholders because there are different ones for Desktop/Mobile |
122 | | -constversionPlaceholders=document.querySelectorAll(".version_switcher_placeholder"); |
123 | | -for(placeholderofversionPlaceholders){ |
124 | | -placeholder.innerHTML=versionSelect; |
125 | | -letselectElement=placeholder.querySelector("select"); |
126 | | -selectElement.addEventListener("change",onSwitch); |
127 | | -} |
128 | | - |
129 | | -constlanguagePlaceholders=document.querySelectorAll(".language_switcher_placeholder"); |
130 | | -for(placeholderoflanguagePlaceholders){ |
131 | | -placeholder.innerHTML=languageSelect; |
132 | | -letselectElement=placeholder.querySelector("select"); |
133 | | -selectElement.addEventListener("change",onSwitch); |
134 | | -} |
135 | | -}); |
136 | | -</script> |
| 46 | +<scripttype="text/javascript"src="{{ pathto('_static/rtd_switcher.js', 1) }}"></script> |
| 47 | +<metaname="readthedocs-addons-api-version"content="1"> |
137 | 48 | {%- endif %} |
138 | 49 | {% endblock %} |