Skip to content

Commit

Permalink
Fix browser incompatiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
Kragrathea committed Sep 25, 2019
1 parent b35570b commit 699b0fa
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions octoprint_prettygcode/static/js/prettygcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ $(function () {

}
self.fromHistoryData = function(data) {
if(!viewInitialized)
return;

updateJob(data.job);
};

Expand Down Expand Up @@ -183,6 +186,11 @@ $(function () {
var printHeadSim=new PrintHeadSimulator();
var curPrinterState=null;
self.fromCurrentData= function (data) {

//Dont do anything if view not initalized
if(!viewInitialized)
return;

//update current loaded model.
updateJob(data.job);
if(curPrinterState && curPrinterState.text!=data.state.text)
Expand All @@ -195,7 +203,6 @@ $(function () {
}
}
curPrinterState=data.state;
//todo. Dont do anything if view not initalized

//parse logs position data for simulator
if(data.logs.length){
Expand All @@ -210,10 +217,10 @@ $(function () {
//Strip out the extra stuff in the terminal line.
//match second space to * character. I hate regexp.
if(terminalGcodeProxy){
var reg=/(?<=\s\S*\s).[^*]*/g
var matches=e.match(reg);
if(matches && matches.length>0)
terminalGcodeProxy.parse(matches[0]+'\n');
// var reg=/(?<=\s\S*\s).[^*]*/g
// var matches=e.match(reg);
// if(matches && matches.length>0)
// terminalGcodeProxy.parse(matches[0]+'\n');
}
}
})
Expand Down Expand Up @@ -624,10 +631,11 @@ $(function () {
fetch(myRequest)
.then(function (response) {
var contentLength = response.headers.get('Content-Length');
if (!response.body || (!TextDecoder)) {
if (!response.body || !window['TextDecoder']) {
response.text().then(function (text) {
parserObject.parse(text);
});;
parserObject.finishLoading();
});
} else {
var myReader = response.body.getReader();
var decoder = new TextDecoder();
Expand Down

0 comments on commit 699b0fa

Please sign in to comment.