Skip to content

Commit 0bba246

Browse files
committed
Fix an error
1 parent 6dbc9f5 commit 0bba246

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

dwg_json_viewer.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h1>Dwg/dxf Database JSON Viewer</h1>
7272
(function() {
7373
// Check if running locally (localhost, 127.0.0.1, or file:// protocol)
7474
const wl = window.location;
75-
const isDevEnv = false;
75+
const isDevEnv = wl.hostname === "localhost" || wl.hostname === "127.0.0.1";
7676

7777
// Load jsoneditor based on environment
7878
const jsoneditorJsPath = isDevEnv
@@ -171,24 +171,23 @@ <h1>Dwg/dxf Database JSON Viewer</h1>
171171
fileName1Element.textContent = file.name
172172

173173
const reader = new FileReader();
174-
reader.onload = function(e) {
174+
reader.onload = async function(e) {
175175
const fileContent = e.target.result;
176176
let version;
177177
let codepage;
178178
let stats = { unknownEntityCount: "" };
179179
const parser = new DxfParser();
180180
{
181-
const result = parser.libredwgConvertEx(fileContent);
181+
const result = await parser.libredwgConvertExAsync(fileContent);
182182
jsonEditor1.set(result.database);
183183
version = result.version;
184184
codepage = result.codepage;
185185
stats = result.stats;
186186
}
187187

188188
{
189-
// force to parse with libredwg-web parser
190-
// This will trigger libredwg-web to call libredwg.convertEx() again.
191-
const result = parser.parseDwg(fileContent);
189+
// Full x-viewer IDxf conversion (loads libredwg on demand via parseAsync)
190+
const result = await parser.parseAsync(fileContent);
192191
jsonEditor2.set({
193192
tables: result.tables,
194193
objects: result.objects,

0 commit comments

Comments
 (0)