|
28 | 28 | </ul>
|
29 | 29 | </div>
|
30 | 30 |
|
31 |
| - <Content :pageKey="activeClientComponent" id="client_content" class="example-content-well"/> |
| 31 | + <div id="client_content" class="example-content-well"> |
| 32 | + <div v-if="clientContentLoading">Loading... </div> |
| 33 | + <div v-else v-html="clientContent"></div> |
| 34 | + </div> |
32 | 35 |
|
33 | 36 | <h2 id="server_setup">Server Setup</h2>
|
34 | 37 |
|
|
54 | 57 | </ul>
|
55 | 58 | </div>
|
56 | 59 |
|
57 |
| - <div id="server_content" class="example-content-well"></div> |
| 60 | + <div id="server_content" class="example-content-well"> |
| 61 | + <div v-if="serverContentLoading">Loading... </div> |
| 62 | + <div v-else v-html="serverContent"></div> |
| 63 | + </div> |
58 | 64 | </div>
|
59 | 65 |
|
60 | 66 | <div class="TableOfContents TableOfContentsPreload">
|
|
64 | 70 | </div>
|
65 | 71 | <!-- END Page Content -->
|
66 | 72 | </section>
|
| 73 | + <iframe style="display:none;" id="clientContentIframe" :src="clientContentUrl"></iframe> |
| 74 | + <iframe style="display:none;" id="serverContentIframe" :src="serverContentUrl"></iframe> |
67 | 75 | <Footer/>
|
68 | 76 | </div>
|
69 | 77 | </template>
|
|
80 | 88 | activeClient: null,
|
81 | 89 | activeServer: null,
|
82 | 90 | activeFramework: null,
|
83 |
| - activeTab: null |
| 91 | + activeTab: null, |
| 92 | + clientContentUrl: null, |
| 93 | + serverContentUrl: null, |
| 94 | + clientContentLoading: true, |
| 95 | + serverContentLoading: true, |
| 96 | + clientContent: "", |
| 97 | + serverContent: "" |
84 | 98 | }
|
85 | 99 | },
|
86 | 100 | created: function () {
|
|
109 | 123 | })
|
110 | 124 | this.activeFramework = defaultServerFramework.name
|
111 | 125 | }
|
| 126 | +
|
112 | 127 | },
|
113 | 128 | computed: {
|
114 | 129 | activeServerFrameworks: function () {
|
|
128 | 143 | },
|
129 | 144 | watch: {
|
130 | 145 | activeClient: function () {
|
131 |
| - this.loadContent() |
| 146 | + this.loadClientContent() |
132 | 147 | window.location.hash = '/'+this.activeClient+'/'+this.activeServer+'/'+this.activeFramework
|
133 | 148 | },
|
134 | 149 | activeServer: function () {
|
|
165 | 180 |
|
166 | 181 | this.activeFramework = frameworkToSet
|
167 | 182 |
|
168 |
| - this.loadContent() |
| 183 | + this.loadServerContent() |
169 | 184 | window.location.hash = '/'+this.activeClient+'/'+this.activeServer+'/'+this.activeFramework
|
170 | 185 | },
|
171 | 186 | activeFramework: function () {
|
172 |
| - this.loadContent() |
| 187 | + this.loadServerContent() |
173 | 188 | window.location.hash = '/'+this.activeClient+'/'+this.activeServer+'/'+this.activeFramework
|
174 | 189 | }
|
175 | 190 | },
|
|
190 | 205 | window.scrollTo(0, document.querySelectorAll(element)[0].offsetTop - 150)
|
191 | 206 | },
|
192 | 207 |
|
193 |
| - loadContent: function () { |
| 208 | + loadClientContent: function () { |
| 209 | + this.clientContentLoading = true |
| 210 | +
|
| 211 | + this.clientContentUrl = '/quickstart-fragments/' + this.activeClient + '/default-example/' |
| 212 | +
|
| 213 | +
|
| 214 | + document.getElementById('clientContentIframe').onload = () => { |
| 215 | + this.clientContentLoading = false |
| 216 | + this.clientContent = document.getElementById('clientContentIframe').contentDocument.querySelector('.PageContent-main').innerHTML |
| 217 | + } |
| 218 | + }, |
| 219 | +
|
| 220 | + loadServerContent: function () { |
| 221 | + this.serverContentLoading = true |
194 | 222 | let client = this.$themeConfig.quickstarts.clients.filter((client) => {
|
195 | 223 | return client.name === this.activeClient
|
196 | 224 | })[0];
|
197 |
| - let clientContentUrl = '/quickstart-fragments/' + this.activeClient + '/default-example/' |
198 |
| - let serverContentUrl = '/quickstart-fragments/' + this.activeServer + '/' + this.activeFramework + '-' + client.serverExampleType |
199 | 225 |
|
200 |
| - fetch(clientContentUrl) |
201 |
| - .then( response => { |
202 |
| - if( response.ok ) { |
203 |
| - return response.text(); |
204 |
| - } |
205 |
| - // Here's where you can handle error status codes |
206 |
| - }) |
207 |
| - .then( text => { |
208 |
| - const element = document.createElement('div') |
209 |
| - element.innerHTML = text |
210 |
| - console.log(element.getElementById('app')) |
211 |
| - }) |
212 |
| - .catch( err => { |
213 |
| - // Here's where you handle network errors |
214 |
| - }); |
| 226 | + this.serverContentUrl = '/quickstart-fragments/' + this.activeServer + '/' + this.activeFramework + '-' + client.serverExampleType + '/' |
| 227 | +
|
| 228 | + document.getElementById('serverContentIframe').onload = () => { |
| 229 | + this.serverContentLoading = false |
| 230 | + this.serverContent = document.getElementById('serverContentIframe').contentDocument.querySelector('.PageContent-main').innerHTML |
| 231 | + } |
215 | 232 | }
|
216 | 233 | }
|
217 | 234 | }
|
|
0 commit comments