|
@@ -8,6 +8,7 @@
|
|
|
* Treat actions associated to iGeomJS menu (File | Edit)
|
|
|
*
|
|
|
* ./app/core/application/header-menu.js
|
|
|
+ * @version 2025/03/25: Fixed reading any GEO file (treat tag "messages" in "src/index.html")
|
|
|
* @version 2023/07/14: Fixed reading GEO file with midpoint
|
|
|
*/
|
|
|
|
|
@@ -78,32 +79,40 @@ class HeaderMenu {
|
|
|
console.log("header-menu.js!onload(): starts"); //D
|
|
|
var obj_file_parser = "-1", content_map = "-1", orchestrator = "-1";
|
|
|
try {
|
|
|
- auxEr += " 1, ";
|
|
|
+ auxEr += " [1] ";
|
|
|
if (obj_file_reader) {
|
|
|
str_file_content = obj_file_reader.result; // get
|
|
|
- auxEr += "2, "; console.log("* #str_file_content=" + (str_file_content?str_file_content.length:0) + ", str_file_content = " + str_file_content);
|
|
|
+ auxEr += "[2] "; console.log("* #str_file_content=" + (str_file_content?str_file_content.length:0) + ", str_file_content = " + str_file_content);
|
|
|
}
|
|
|
|
|
|
+ // src/index.html: must have tag <li><span class="level-1" id="messages">iGeom version</span></li>
|
|
|
var element = document.getElementById("messages"); // overwrite the message "File does not exist or it is empty""
|
|
|
- element.innerHTML = "Construct inside area *"; // same text in "index.html"
|
|
|
+ auxEr += "[2.1] ";
|
|
|
+ if (element != undefined) { // security (case id="messages" was removed from "src/index.html"
|
|
|
+ console.log("header-menu.js!onFileChanged(): [2.2] element=" + element);
|
|
|
+ element.innerHTML = "Construct inside area *"; // same text in "index.html"
|
|
|
+ auxEr += "[2.2] ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ console.log("header-menu.js!onFileChanged(): [2.2] Error: src/index.html missing id=messages!");
|
|
|
|
|
|
obj_file_parser = new FileParser(str_file_content); // app/core/parser/file-parser.js: export class FileParser: only set "this.content = str_file_content"
|
|
|
- auxEr += "3, ";
|
|
|
+ auxEr += "[3] ";
|
|
|
|
|
|
content_map = obj_file_parser.parse(vec_obj_dynamic_obj); // now parse each line producing a JS Map (additionally produce array "vec_obj_dynamic_obj")
|
|
|
- auxEr += "4, ";
|
|
|
+ auxEr += "[4] ";
|
|
|
|
|
|
var aux = ""; // try { aux = JSON.stringify(Object.keys(content_map)) + " "; } catch (error) { aux = "error " + error + " "; }
|
|
|
- auxEr += "5, "; // content_map = [id,1=type,0] [id,2=type,0] [id,3=type,13] [id,4=type,0] [id,5=type,13] [undefined=undefined]
|
|
|
+ auxEr += "[5] "; // content_map = [id,1=type,0] [id,2=type,0] [id,3=type,13] [id,4=type,0] [id,5=type,13] [undefined=undefined]
|
|
|
console.log("* #content_map=" + (content_map?content_map.length:0) + "=" + content_map.size + ", content_map = " + HeaderMenu.printMap_hm(content_map)); //D JSON.stringify(content_map) + "\n" + aux);
|
|
|
orchestrator = new ParserOrchestrator(content_map); // app/core/parser/parser-orchestrator.js
|
|
|
- auxEr += "6, "; console.log("* #orchestrator=" + (orchestrator?orchestrator.length:0) + ", orchestrator = " + orchestrator);
|
|
|
- auxEr += "7, ";
|
|
|
+ auxEr += "[6] "; console.log("* #orchestrator=" + (orchestrator?orchestrator.length:0) + ", orchestrator = " + orchestrator);
|
|
|
+ auxEr += "[7] ";
|
|
|
orchestrator.orchestrate(vec_obj_dynamic_obj); // Array() with {id, obj}
|
|
|
}
|
|
|
catch (error) {
|
|
|
- console.log("header-menu.js!onFileChanged()!obj_file_reader.onload: error " + error + // "\n * str_file_content = " + str_file_content + "\n * obj_file_parser = " + JSON.stringify(obj_file_parser) + "\n * content_map = " + JSON.stringify(content_map));
|
|
|
- auxEr);
|
|
|
+ console.log("header-menu.js!onFileChanged()!obj_file_reader.onload: error " + error + auxEr);
|
|
|
+ // "\n * str_file_content = " + str_file_content + "\n * obj_file_parser = " + JSON.stringify(obj_file_parser) + "\n * content_map = " + JSON.stringify(content_map));
|
|
|
}
|
|
|
HeaderMenu.printObj_hm(vec_obj_dynamic_obj); //D only DEBUG!
|
|
|
console.log("header-menu.js!onload(): final"); //D
|