Skip to content

Commit e105f80

Browse files
authored
Merge pull request #16 from gym22/main
2 parents d05f821 + 29ba955 commit e105f80

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

scripts/script.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,12 @@ function exportToYaml() {
384384
});
385385

386386
// get highest y value
387-
var mostTopRoom = jsonStorage.rooms.reduce(function(prev, curr) {
388-
return prev.zone.y <= curr.zone.y ? prev : curr;
387+
var mostBottomRoom = jsonStorage.rooms.reduce(function(prev, curr) {
388+
return (prev.zone.y + prev.zone.height) >= (curr.zone.y + curr.zone.height) ? prev : curr;
389389
});
390390

391391
// create an offseter
392-
firstCoordinateOffsetY = mostTopRoom.zone.y;
392+
firstCoordinateOffsetY = mostBottomRoom.zone.y + mostBottomRoom.zone.height;
393393
firstCoordinateOffsetX = mostLeftRoom.zone.x;
394394

395395
var data = {
@@ -430,7 +430,7 @@ function exportToYaml() {
430430

431431
exportedValue = objToYaml(data);
432432
var modal = document.querySelector(".yaml-export");
433-
modal.querySelector(".text").innerHTML = exportedValue.replaceAll("\n", "<br />").replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
433+
modal.querySelector(".text").innerHTML = exportedValue.replaceAll("\n", "<br />").replaceAll("\t", "&nbsp;&nbsp;");
434434
modal.classList.add("visible");
435435
console.log(exportedValue);
436436
}
@@ -453,19 +453,19 @@ function closeModal(id) {
453453
}
454454

455455
function copyYaml() {
456-
navigator.clipboard.writeText(exportedValue);
456+
navigator.clipboard.writeText(exportedValue.replaceAll("\t", " "));
457457
}
458458

459459
function objToYaml(obj) {
460460
var string = "rooms: \n"
461461
obj.roomplans.forEach(obj => {
462462
string += "\t- name: " + obj.name + "\n";
463463
string += "\t\tpoints:" + "\n";
464-
string += "\t\t\t - [ " + (Math.round(obj.x1)/100) + ", " + (Math.round(obj.y1)/100) +"]\n";
465-
string += "\t\t\t - [ " + (Math.round(obj.x2)/100) + ", " + (Math.round(obj.y1)/100) +"]\n";
466-
string += "\t\t\t - [ " + (Math.round(obj.x2)/100) + ", " + (Math.round(obj.y2)/100) +"]\n";
467-
string += "\t\t\t - [ " + (Math.round(obj.x1)/100) + ", " + (Math.round(obj.y2)/100) +"]\n";
468-
string += "\t\t\t - [ " + (Math.round(obj.x1)/100) + ", " + (Math.round(obj.y1)/100) +"]\n";
464+
string += "\t\t\t- [ " + (Math.round(obj.x1)/100) + ", " + (Math.round(obj.y1)/100) +"]\n";
465+
string += "\t\t\t- [ " + (Math.round(obj.x2)/100) + ", " + (Math.round(obj.y1)/100) +"]\n";
466+
string += "\t\t\t- [ " + (Math.round(obj.x2)/100) + ", " + (Math.round(obj.y2)/100) +"]\n";
467+
string += "\t\t\t- [ " + (Math.round(obj.x1)/100) + ", " + (Math.round(obj.y2)/100) +"]\n";
468+
string += "\t\t\t- [ " + (Math.round(obj.x1)/100) + ", " + (Math.round(obj.y1)/100) +"]\n";
469469
});
470470

471471
string += "nodes: \n";
@@ -474,8 +474,8 @@ function objToYaml(obj) {
474474
var x = currentUnit == "m" ? Math.abs(probe.x - firstCoordinateOffsetX) : Math.abs(probe.x - firstCoordinateOffsetX)/3.2808;
475475
var y = currentUnit == "m" ? Math.abs(probe.y - firstCoordinateOffsetY) : Math.abs(probe.y - firstCoordinateOffsetY)/3.2808;
476476
string += "\t- name: " + probe.name +"\n";
477-
string += "\tpoint: [" + (Math.round(x)/100) + "," + (Math.round(y) / 100) + ", 0]\n";
478-
string += "\tfloors: [\"first\"]\n";
477+
string += "\t\tpoint: [" + (Math.round(x)/100) + "," + (Math.round(y) / 100) + ", 0]\n";
478+
string += "\t\tfloors: [\"first\"]\n";
479479
});
480480
});
481481
return string;

0 commit comments

Comments
 (0)