Skip to content

Commit 97a9f44

Browse files
SidebarFileManager: further improve url file loading
1 parent 733805f commit 97a9f44

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/SideBarFileManager.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,24 @@ export default {
7474
this.state.logType = 'tlog'
7575
} else {
7676
url = file
77+
// Set the file name for display purposes
78+
const urlParts = url.split('/')
79+
this.state.file = urlParts[urlParts.length - 1]
7780
}
7881
const oReq = new XMLHttpRequest()
7982
console.log(`loading file from ${url}`)
83+
84+
// Set the log type based on file extension
8085
this.state.logType = url.indexOf('.tlog') > 0 ? 'tlog' : 'bin'
86+
if (url.indexOf('.txt') > 0) {
87+
this.state.logType = 'dji'
88+
}
89+
8190
oReq.open('GET', url, true)
8291
oReq.responseType = 'arraybuffer'
8392
84-
oReq.onload = function (oEvent) {
93+
// Use arrow function to preserve 'this' context
94+
oReq.onload = (oEvent) => {
8595
const arrayBuffer = oReq.response
8696
8797
this.transferMessage = 'Download Done'
@@ -252,7 +262,7 @@ export default {
252262
}
253263
const url = document.location.search.split('?file=')[1]
254264
if (url) {
255-
this.onLoadSample(url)
265+
this.onLoadSample(decodeURIComponent(url))
256266
}
257267
},
258268
components: {

0 commit comments

Comments
 (0)