Skip to content

Commit

Permalink
fix for issue with checkZFT static method
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Nov 22, 2024
1 parent af5d453 commit 4618f52
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dist/ARToolkitNFT.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ARToolkitNFT_simd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ARToolkitNFT_td.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/js/threading_files/ARToolkitNFT_td.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/ARToolkitNFT_simd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export class ARToolkitNFT implements IARToolkitNFT {
const filename4 = prefix + ".zft";

let type = Utils.checkZFT(element + ".zft");
console.log(type);
if (type) {
pending -= 2;
this.ajax(
Expand Down
24 changes: 9 additions & 15 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,17 @@ export default class Utils {
return out;
}

static checkZFT(url: string): any {
let isZFT: boolean = null;
static checkZFT(url: string): boolean {
const request = new XMLHttpRequest();
request.open("GET", url, false); // `false` makes the request synchronous
request.send(null);

try {
const response: any = axios.get(url);

return () => {
if (response.status == 200) {
isZFT = true;
} else {
isZFT = false;
}
return isZFT;
};
} catch (error) {
throw new Error("Error in Utils.checkZFT: ", error);
if (request.status === 200) {
return true;
} else if (request.status === 404) {
return false;
}
return false;
}
/**
* Stores data in the Emscripten filesystem.
Expand Down
2 changes: 1 addition & 1 deletion types/src/Utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export default class Utils {
static fetchRemoteDataCallback(url: string, callback: any): Promise<any>;
static string2Uint8Data(string: string): Uint8Array;
static Uint8ArrayToStr(array: any): string;
static checkZFT(url: string): any;
static checkZFT(url: string): boolean;
static _storeDataFile(data: Uint8Array, target: string, instance: any): void;
}

0 comments on commit 4618f52

Please sign in to comment.