|
|
|
class Model {
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
parseXML(xml) {
|
|
|
|
let parser = new DOMParser();
|
|
|
|
let xmlDoc = parser.parseFromString(xml, "text/xml");
|
|
|
|
|
|
|
|
this.comments = [];
|
|
|
|
this.popups = [];
|
|
|
|
|
|
|
|
let comment = xmlDoc.getElementsByTagName("comment");
|
|
|
|
for (let i = 0; i < comment.length; i++) {
|
|
|
|
let start = comment[i].getElementsByTagName("start")[0].innerHTML;
|
|
|
|
let end = comment[i].getElementsByTagName("end")[0].innerHTML;
|
|
|
|
let title = comment[i].getElementsByTagName("title")[0].innerHTML;
|
|
|
|
let text = comment[i].getElementsByTagName("text");
|
|
|
|
|
|
|
|
this.comments.push(new Comment(start, end, title, text));
|
|
|
|
}
|
|
|
|
let popup = xmlDoc.getElementsByTagName("popup");
|
|
|
|
for (let i = 0; i < popup.length; i++) {
|
|
|
|
let start = popup[i].getElementsByTagName("start")[0].innerHTML;
|
|
|
|
let end = popup[i].getElementsByTagName("end")[0].innerHTML;
|
|
|
|
let text = popup[i].getElementsByTagName("text")[0].innerHTML;
|
|
|
|
|
|
|
|
this.popups.push(new Popup(start, end, text));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getVideoFileName(xml) {
|
|
|
|
let parser = new DOMParser();
|
|
|
|
let xmlDoc = parser.parseFromString(xml, "text/xml");
|
|
|
|
let videoTag = xmlDoc.firstChild.getAttribute("src");
|
|
|
|
|
|
|
|
return videoTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
getCommentsObjects() {}
|
|
|
|
|
|
|
|
async loadXml(v) {
|
|
|
|
var Connect = new XMLHttpRequest();
|
|
|
|
// Define which file to open and
|
|
|
|
// send the request.
|
|
|
|
Connect.open("GET", "./videos/" + v + ".xml", false);
|
|
|
|
Connect.setRequestHeader("Content-Type", "text/xml");
|
|
|
|
Connect.send(null);
|
|
|
|
// Place the response in an XML document.
|
|
|
|
var TheDocument = Connect.responseText;
|
|
|
|
// Place the root node in an element.
|
|
|
|
// var Customers = TheDocument.childNodes[0];
|
|
|
|
|
|
|
|
return TheDocument;
|
|
|
|
}
|
|
|
|
}
|