Skip to content

Commit

Permalink
CockpitPanel: update XML handling
Browse files Browse the repository at this point in the history
Latest MSFS uses sConfigFile as an XML string instead of a file as
before. Add a new getXML method to the WebSim class and use it to
load the cockpit XML panel data when sConfigFile is updated.

Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
  • Loading branch information
tavip committed May 1, 2021
1 parent 600e513 commit fd2e909
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/html_ui/WebSim/CockpitPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WebSimCockpitPanelData {
}

setConfigFile(filename) {
this.sConfigFile = filename;
this.sConfigFile = WebSim.getXML("VFS/" + filename);
}

addInstrument(url, name, x, y, z, w) {
Expand Down
12 changes: 12 additions & 0 deletions src/html_ui/WebSim/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ class WebSim {
xhr.send();
});
}
static getXML(xmlPath) {
let xhr = new XMLHttpRequest();

xhr.open("GET", xmlPath, false);
xhr.send();
if (xhr.status === 200) {
return xhr.responseText;
} else {
return "";
}
}

}

0 comments on commit fd2e909

Please sign in to comment.