You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB
JavaScript

3 years ago
class Controller {
constructor(model, view) {
this.model = model;
this.view = view;
3 years ago
this.init();
}
init() {
// Get video code
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
this.videoToLoad = urlParams.get("v");
this.loadVideo(this.videoToLoad);
this.loadXml(this.videoToLoad);
this.view.drawCommentsText(this.model.comments);
this.view.videoPlayer.getVideoDuration().then(function(v) {
this.view.drawCommentsToVideo(this.model.comments, v);
}.bind(this))
}
loadVideo(v) {
let video = document.getElementById("video");
video.children[0].src = "./videos/" + v + ".webm";
video.load();
}
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];
this.model.parseXML(TheDocument);
3 years ago
}
}