class Controller { constructor(model, view) { this.model = model; this.view = view; 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); } }