Commit 8a8c7150 authored by Mathias Goebel's avatar Mathias Goebel 🎠

Merge branch 'bugfix/async' into 'develop'

Bugfix/async

See merge request !12
parents 37685ea0 890046dc
Pipeline #115427 passed with stage
in 2 minutes and 2 seconds
......@@ -46,26 +46,20 @@ export default {
},
getManifest(url) {
fetch(url)
.then((response) => {
response.json()
.then((data) => {
this.collection.push(data);
this.sequences.push(data.sequence);
data.sequence.forEach(seq => this.itemurls.push(seq.id));
this.itemurl = this.$route.query.emo_itemurl || data.sequence[0].id;
.then(response => response.json())
.then((data) => {
this.collection.push(data);
this.sequences.push(data.sequence);
data.sequence.forEach(seq => this.itemurls.push(seq.id));
this.itemurl = this.$route.query.emo_itemurl || data.sequence[0].id;
this.$router.push({ query: { emo_itemurl: this.itemurl } });
});
this.$router.push({ query: { emo_itemurl: this.itemurl } });
});
},
getCollection() {
fetch(this.config.entrypoint)
.then((response) => {
response.json()
.then((data) => {
data.sequence.forEach(seq => this.getManifest(seq.id));
});
});
.then(response => response.json())
.then(data => data.sequence.forEach(seq => this.getManifest(seq.id)));
},
},
created() {
......
......@@ -21,13 +21,11 @@ export default {
getSupport(supportobj) {
if (supportobj.type === 'css') {
fetch(supportobj.url)
.then((response) => {
response.text()
.then((data) => {
const styleelement = document.createElement('style');
styleelement.innerText = data.replace(/^|}|,/gm, (x => x.concat('#', this.nodeid, ' ')));
document.head.appendChild(styleelement);
});
.then(response => response.text())
.then((data) => {
const styleelement = document.createElement('style');
styleelement.innerText = data.replace(/^|}|,/gm, (x => x.concat('#', this.nodeid, ' ')));
document.head.appendChild(styleelement);
});
}
},
......@@ -37,12 +35,11 @@ export default {
this.collection.forEach((manifest) => {
if (manifest.support) {
manifest.support.map(this.getSupport);
fetch(this.contenturl)
.then((response) => {
response.text()
.then((data) => {
this.content = data;
});
.then(response => response.text())
.then((data) => {
this.content = data;
});
}
});
......
......@@ -35,14 +35,12 @@ export default {
},
mounted() {
fetch(this.itemurl)
.then((response) => {
response.json()
.then((data) => {
this.item = data;
if (data.image) {
this.imageurl = data.image.id;
}
});
.then(response => response.json())
.then((data) => {
this.item = data;
if (data.image) {
this.imageurl = data.image.id;
}
});
},
};
......
......@@ -45,7 +45,6 @@ export default {
return {
page: 0,
chapter: 0,
chaptercount: 0,
};
},
methods: {
......@@ -54,6 +53,9 @@ export default {
},
},
computed: {
chaptercount() {
return this.sequences.length;
},
getPagesPerChapter() {
const pagesperchapter = [];
......@@ -88,7 +90,6 @@ export default {
},
},
mounted() {
this.chaptercount = Object.keys(this.sequences).length;
this.page = this.updatePage;
this.$root.$on('update-page', (currentpage) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment