@@ -384,12 +384,12 @@ function exportToYaml() {
384
384
} ) ;
385
385
386
386
// 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 ;
389
389
} ) ;
390
390
391
391
// create an offseter
392
- firstCoordinateOffsetY = mostTopRoom . zone . y ;
392
+ firstCoordinateOffsetY = mostBottomRoom . zone . y + mostBottomRoom . zone . height ;
393
393
firstCoordinateOffsetX = mostLeftRoom . zone . x ;
394
394
395
395
var data = {
@@ -430,7 +430,7 @@ function exportToYaml() {
430
430
431
431
exportedValue = objToYaml ( data ) ;
432
432
var modal = document . querySelector ( ".yaml-export" ) ;
433
- modal . querySelector ( ".text" ) . innerHTML = exportedValue . replaceAll ( "\n" , "<br />" ) . replaceAll ( "\t" , " " ) ;
433
+ modal . querySelector ( ".text" ) . innerHTML = exportedValue . replaceAll ( "\n" , "<br />" ) . replaceAll ( "\t" , " " ) ;
434
434
modal . classList . add ( "visible" ) ;
435
435
console . log ( exportedValue ) ;
436
436
}
@@ -453,19 +453,19 @@ function closeModal(id) {
453
453
}
454
454
455
455
function copyYaml ( ) {
456
- navigator . clipboard . writeText ( exportedValue ) ;
456
+ navigator . clipboard . writeText ( exportedValue . replaceAll ( "\t" , " " ) ) ;
457
457
}
458
458
459
459
function objToYaml ( obj ) {
460
460
var string = "rooms: \n"
461
461
obj . roomplans . forEach ( obj => {
462
462
string += "\t- name: " + obj . name + "\n" ;
463
463
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" ;
469
469
} ) ;
470
470
471
471
string += "nodes: \n" ;
@@ -474,8 +474,8 @@ function objToYaml(obj) {
474
474
var x = currentUnit == "m" ? Math . abs ( probe . x - firstCoordinateOffsetX ) : Math . abs ( probe . x - firstCoordinateOffsetX ) / 3.2808 ;
475
475
var y = currentUnit == "m" ? Math . abs ( probe . y - firstCoordinateOffsetY ) : Math . abs ( probe . y - firstCoordinateOffsetY ) / 3.2808 ;
476
476
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" ;
479
479
} ) ;
480
480
} ) ;
481
481
return string ;
0 commit comments