@denevads/dnv-smo 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/smo.d.ts CHANGED
@@ -41,7 +41,7 @@ declare class SmoEvents {
41
41
  getRecursosRelleno: Subject<GetRecursosRelleno>;
42
42
  getVariableStorage: Subject<variable>;
43
43
  checkHealth: Subject<string>;
44
- checkHealthPrinter: Subject<String>;
44
+ checkHealthPrinter: Subject<string>;
45
45
  constructor(smo: SMO);
46
46
  }
47
47
  declare class smoCallBacks {
@@ -96,6 +96,7 @@ declare class Utils {
96
96
  constructor(_smo: SMO, _smoCallBacks: smoCallBacks);
97
97
  xmlToJSON(xml: string): string;
98
98
  jsonToStr(js_obj: any): string;
99
+ sendToParent(obj: any, dest: string): void;
99
100
  setJsonObj(xml: any): any;
100
101
  dataToJSON(data: setDatasource): any;
101
102
  }
package/dist/smo.js CHANGED
@@ -35,40 +35,6 @@ var SMO = /** @class */ (function () {
35
35
  _this.events.checkHealthPrinter.next(objData);
36
36
  break;
37
37
  }
38
- // @ts-ignore
39
- window.parent.postMessage = function (target, objData, idSmo) {
40
- switch (target.target) {
41
- case "Dnv.smoCallbacks.onSmoLoad":
42
- // @ts-ignore
43
- window.objJS.onSmoLoad();
44
- break;
45
- case "Dnv.smoCallbacks.printTextLine":
46
- // @ts-ignore
47
- window.objJS.printTextLine(objData.txt);
48
- break;
49
- case "Dnv.smoCallbacks.printBarcode":
50
- // @ts-ignore
51
- window.objJS.printBarcode(objData.code, objData.width, objData.height);
52
- break;
53
- case "Dnv.smoCallbacks.cutPaper":
54
- // @ts-ignore
55
- window.objJS.cutPaper(objData.percent);
56
- break;
57
- case "Dnv.smoCallbacks.printImage":
58
- // @ts-ignore
59
- window.objJS.printImage(idSmo, objData.image);
60
- break;
61
- case "Dnv.smoCallbacks.checkHealthPrinter":
62
- console.log('llamo a checkhealthprinter');
63
- // @ts-ignore
64
- window.objJS.checkHealthPrinter(idSmo);
65
- break;
66
- case "Dnv.smoCallbacks.checkHealth":
67
- // @ts-ignore
68
- window.objJS.checkHealth();
69
- break;
70
- }
71
- };
72
38
  };
73
39
  window.external = {
74
40
  // @ts-ignore
@@ -296,14 +262,14 @@ var smoCallBacks = /** @class */ (function () {
296
262
  this.smo = _smo;
297
263
  }
298
264
  smoCallBacks.prototype.onSmoLoad = function () {
299
- window.parent.postMessage({
265
+ this.smo.utils.sendToParent({
300
266
  target: "Dnv.smoCallbacks.onSmoLoad",
301
267
  objData: undefined,
302
268
  idSmo: this.smo.id
303
269
  }, "*");
304
270
  };
305
271
  smoCallBacks.prototype.onSmoReady = function () {
306
- window.parent.postMessage({
272
+ this.smo.utils.sendToParent({
307
273
  target: "Dnv.smoCallbacks.onSmoReady",
308
274
  objData: undefined,
309
275
  idSmo: this.smo.id
@@ -327,7 +293,7 @@ var smoCallBacks = /** @class */ (function () {
327
293
  console.error(msn);
328
294
  }
329
295
  if (window.parent != window) {
330
- window.parent.postMessage({
296
+ this.smo.utils.sendToParent({
331
297
  target: "Dnv.smoCallbacks.smoLog",
332
298
  objData: {
333
299
  level: level,
@@ -338,7 +304,7 @@ var smoCallBacks = /** @class */ (function () {
338
304
  }
339
305
  };
340
306
  smoCallBacks.prototype.smoAlarma = function (msn, level) {
341
- window.parent.postMessage({
307
+ this.smo.utils.sendToParent({
342
308
  target: "Dnv.smoCallbacks.smoAlarma",
343
309
  objData: {
344
310
  level: level,
@@ -348,7 +314,7 @@ var smoCallBacks = /** @class */ (function () {
348
314
  }, "*");
349
315
  };
350
316
  smoCallBacks.prototype.smoLogStash = function (msn) {
351
- window.parent.postMessage({
317
+ this.smo.utils.sendToParent({
352
318
  target: "Dnv.smoCallbacks.smoLogStash",
353
319
  objData: {
354
320
  txt: msn
@@ -357,7 +323,7 @@ var smoCallBacks = /** @class */ (function () {
357
323
  }, "*");
358
324
  };
359
325
  smoCallBacks.prototype.smoLogNowShowing = function (msn) {
360
- window.parent.postMessage({
326
+ this.smo.utils.sendToParent({
361
327
  target: "Dnv.smoCallbacks.smoNowShowing",
362
328
  objData: msn,
363
329
  idSmo: this.smo.id
@@ -365,7 +331,7 @@ var smoCallBacks = /** @class */ (function () {
365
331
  };
366
332
  smoCallBacks.prototype.reiniciarDispositivo = function (msn) {
367
333
  //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
368
- window.parent.postMessage({
334
+ this.smo.utils.sendToParent({
369
335
  target: "Dnv.smoCallbacks.reiniciarDispositivo",
370
336
  objData: {
371
337
  txt: msn // Razón del reinicio
@@ -375,7 +341,7 @@ var smoCallBacks = /** @class */ (function () {
375
341
  };
376
342
  smoCallBacks.prototype.urlNext = function () {
377
343
  //Permite avanzar plantilla. Solo si Reloj Maestro activado.
378
- window.parent.postMessage({
344
+ this.smo.utils.sendToParent({
379
345
  target: "Dnv.smoCallbacks.urlNext",
380
346
  objData: undefined,
381
347
  idSmo: this.smo.id
@@ -383,7 +349,7 @@ var smoCallBacks = /** @class */ (function () {
383
349
  };
384
350
  smoCallBacks.prototype.exitInteractivity = function () {
385
351
  //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
386
- window.parent.postMessage({
352
+ this.smo.utils.sendToParent({
387
353
  target: "Dnv.smoCallbacks.exitInteractivity",
388
354
  objData: undefined,
389
355
  idSmo: this.smo.id
@@ -399,7 +365,7 @@ var smoCallBacks = /** @class */ (function () {
399
365
  /* NOT IMPLEMENTED */
400
366
  };
401
367
  smoCallBacks.prototype.setVariable = function (variable, valor) {
402
- window.parent.postMessage({
368
+ this.smo.utils.sendToParent({
403
369
  target: "Dnv.smoCallbacks.setVariable",
404
370
  objData: {
405
371
  variable: variable,
@@ -409,7 +375,7 @@ var smoCallBacks = /** @class */ (function () {
409
375
  }, "*");
410
376
  };
411
377
  smoCallBacks.prototype.getVariable = function (variable) {
412
- window.parent.postMessage({
378
+ this.smo.utils.sendToParent({
413
379
  target: "Dnv.smoCallbacks.getVariable",
414
380
  objData: {
415
381
  variable: variable
@@ -419,14 +385,14 @@ var smoCallBacks = /** @class */ (function () {
419
385
  /* MIRAR SMO.getVariable */
420
386
  };
421
387
  smoCallBacks.prototype.getFile = function (file) {
422
- parent.postMessage({
388
+ this.smo.utils.sendToParent({
423
389
  target: "Dnv.smoCallbacks.getFile",
424
390
  objData: file,
425
391
  idSmo: this.smo.id
426
392
  }, "*");
427
393
  };
428
394
  smoCallBacks.prototype.setLocalData = function (variable, valor) {
429
- parent.postMessage({
395
+ this.smo.utils.sendToParent({
430
396
  target: "Dnv.smoCallbacks.setLocalData",
431
397
  objData: {
432
398
  nameData: variable,
@@ -436,7 +402,7 @@ var smoCallBacks = /** @class */ (function () {
436
402
  }, "*");
437
403
  };
438
404
  smoCallBacks.prototype.getLocalData = function (variable) {
439
- parent.postMessage({
405
+ this.smo.utils.sendToParent({
440
406
  target: "Dnv.smoCallbacks.getLocalData",
441
407
  objData: variable,
442
408
  idSmo: this.smo.id
@@ -444,7 +410,7 @@ var smoCallBacks = /** @class */ (function () {
444
410
  /* MIRAR SMO.setDatasource */
445
411
  };
446
412
  smoCallBacks.prototype.getCurrentStream = function () {
447
- parent.postMessage({
413
+ this.smo.utils.sendToParent({
448
414
  target: "Dnv.smoCallbacks.getCurrentStream",
449
415
  objData: undefined,
450
416
  idSmo: this.smo.id
@@ -452,21 +418,21 @@ var smoCallBacks = /** @class */ (function () {
452
418
  /* MIRAR SMO.setCurrentStream' */
453
419
  };
454
420
  smoCallBacks.prototype.finAviso = function (id) {
455
- parent.postMessage({
421
+ this.smo.utils.sendToParent({
456
422
  target: "Dnv.smoCallbacks.finAviso",
457
423
  objData: id,
458
424
  idSmo: this.smo.id
459
425
  }, "*");
460
426
  };
461
427
  smoCallBacks.prototype.refreshDatasource = function (codigo) {
462
- parent.postMessage({
428
+ this.smo.utils.sendToParent({
463
429
  target: "Dnv.smoCallbacks.refreshDatasource",
464
430
  objData: codigo,
465
431
  idSmo: this.smo.id
466
432
  }, "*");
467
433
  };
468
434
  smoCallBacks.prototype.getLocation = function () {
469
- parent.postMessage({
435
+ this.smo.utils.sendToParent({
470
436
  target: "Dnv.smoCallbacks.getLocation",
471
437
  objData: undefined,
472
438
  idSmo: this.smo.id
@@ -474,7 +440,7 @@ var smoCallBacks = /** @class */ (function () {
474
440
  /* MIRAR SMO.infoCurrentLocation */
475
441
  };
476
442
  smoCallBacks.prototype.getSalidaData = function (data) {
477
- parent.postMessage({
443
+ this.smo.utils.sendToParent({
478
444
  target: "Dnv.smoCallbacks.getSalidaData",
479
445
  objData: data,
480
446
  idSmo: this.smo.id
@@ -486,7 +452,7 @@ var smoCallBacks = /** @class */ (function () {
486
452
  funcion: "", // Nombre de la función que se debe ejecutar
487
453
  params: "" // Parámetros que debemos enviarle a la funcion. sin separadores ni nada, un string y se usa como tal. Solo esta implementada en un caso y se usa como tal sin parsear ni nada
488
454
  } */
489
- parent.postMessage({
455
+ this.smo.utils.sendToParent({
490
456
  target: "Dnv.smoCallbacks.ejecutaFuncion",
491
457
  objData: data,
492
458
  idSmo: this.smo.id
@@ -495,7 +461,7 @@ var smoCallBacks = /** @class */ (function () {
495
461
  smoCallBacks.prototype.addObserver = function (data) {
496
462
  /*data ="fruta"
497
463
  */
498
- parent.postMessage({
464
+ this.smo.utils.sendToParent({
499
465
  target: "Dnv.smoCallbacks.addObserver",
500
466
  objData: data,
501
467
  idSmo: this.smo.id
@@ -506,31 +472,31 @@ var smoCallBacks = /** @class */ (function () {
506
472
  destino: "fruta",
507
473
  value: "{'fruta':'manzana', 'color':'roja'}"
508
474
  } */
509
- parent.postMessage({
475
+ this.smo.utils.sendToParent({
510
476
  target: "Dnv.smoCallbacks.notify",
511
477
  objData: data,
512
478
  idSmo: this.smo.id
513
479
  }, "*");
514
480
  };
515
481
  smoCallBacks.prototype.playOnceChannelByTrigger = function (trigger) {
516
- parent.postMessage({
482
+ this.smo.utils.sendToParent({
517
483
  target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
518
484
  objData: { triggerCanal: trigger },
519
485
  idSmo: this.smo.id
520
486
  }, "*");
521
487
  };
522
488
  smoCallBacks.prototype.stopPlayOnceChannelByTrigger = function () {
523
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
489
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
524
490
  };
525
491
  smoCallBacks.prototype.playOnceChannel = function (codigoCanal) {
526
- parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
492
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
527
493
  };
528
494
  smoCallBacks.prototype.stopPlayChannel = function () {
529
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
495
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
530
496
  };
531
497
  smoCallBacks.prototype.editWrapperStyle = function (obj) {
532
498
  /*{"posX": "0px","posY": "0px","alto": "0px","ancho": "0px","overflow": "hidden","scale": 0.1,"zindex": 0.1,"opacidad": 0.1,"isMaestro": true,duracionTransition: "1s", transitionTiming: "lineal", css: string} */
533
- parent.postMessage({
499
+ this.smo.utils.sendToParent({
534
500
  target: "Dnv.smoCallbacks.editWrapperStyle",
535
501
  objData: obj,
536
502
  idSmo: this.smo.id
@@ -538,7 +504,7 @@ var smoCallBacks = /** @class */ (function () {
538
504
  };
539
505
  smoCallBacks.prototype.getRecursosByCodigo = function (codigos) {
540
506
  /** ["123456","654321"] */
541
- parent.postMessage({
507
+ this.smo.utils.sendToParent({
542
508
  target: "Dnv.smoCallbacks.getRecursosByCodigo",
543
509
  objData: {
544
510
  recursos: codigos
@@ -547,25 +513,25 @@ var smoCallBacks = /** @class */ (function () {
547
513
  }, "*");
548
514
  };
549
515
  smoCallBacks.prototype.getRecursos = function () {
550
- parent.postMessage({
516
+ this.smo.utils.sendToParent({
551
517
  target: "Dnv.smoCallbacks.getRecursos",
552
518
  idSmo: this.smo.id
553
519
  }, "*");
554
520
  };
555
521
  smoCallBacks.prototype.getRecursosDefault = function () {
556
- parent.postMessage({
522
+ this.smo.utils.sendToParent({
557
523
  target: "Dnv.smoCallbacks.getRecursosDefault",
558
524
  idSmo: this.smo.id
559
525
  }, "*");
560
526
  };
561
527
  smoCallBacks.prototype.getRecursosRelleno = function () {
562
- parent.postMessage({
528
+ this.smo.utils.sendToParent({
563
529
  target: "Dnv.smoCallbacks.getRecursosRelleno",
564
530
  idSmo: this.smo.id
565
531
  }, "*");
566
532
  };
567
533
  smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
568
- window.parent.postMessage({
534
+ this.smo.utils.sendToParent({
569
535
  target: "Dnv.smoCallbacks.setVariableStorage",
570
536
  objData: {
571
537
  variable: variable,
@@ -575,7 +541,7 @@ var smoCallBacks = /** @class */ (function () {
575
541
  }, "*");
576
542
  };
577
543
  smoCallBacks.prototype.getVariableStorage = function (variable) {
578
- window.parent.postMessage({
544
+ this.smo.utils.sendToParent({
579
545
  target: "Dnv.smoCallbacks.getVariableStorage",
580
546
  objData: {
581
547
  variable: variable
@@ -585,7 +551,7 @@ var smoCallBacks = /** @class */ (function () {
585
551
  /* MIRAR SMO.getVariable */
586
552
  };
587
553
  smoCallBacks.prototype.printTextLine = function (txt) {
588
- window.parent.postMessage({
554
+ this.smo.utils.sendToParent({
589
555
  target: "Dnv.smoCallbacks.printTextLine",
590
556
  objData: {
591
557
  txt: txt
@@ -594,7 +560,7 @@ var smoCallBacks = /** @class */ (function () {
594
560
  }, "*");
595
561
  };
596
562
  smoCallBacks.prototype.printBarcode = function (code, width, height) {
597
- window.parent.postMessage({
563
+ this.smo.utils.sendToParent({
598
564
  target: "Dnv.smoCallbacks.printBarcode",
599
565
  objData: {
600
566
  code: code,
@@ -605,7 +571,7 @@ var smoCallBacks = /** @class */ (function () {
605
571
  }, "*");
606
572
  };
607
573
  smoCallBacks.prototype.cutPaper = function (percent) {
608
- window.parent.postMessage({
574
+ this.smo.utils.sendToParent({
609
575
  target: "Dnv.smoCallbacks.cutPaper",
610
576
  objData: {
611
577
  percent: percent
@@ -614,19 +580,19 @@ var smoCallBacks = /** @class */ (function () {
614
580
  }, "*");
615
581
  };
616
582
  smoCallBacks.prototype.checkHealth = function () {
617
- window.parent.postMessage({
583
+ this.smo.utils.sendToParent({
618
584
  target: "Dnv.smoCallbacks.checkHealth",
619
585
  idSmo: this.smo.id
620
586
  }, "*");
621
587
  };
622
588
  smoCallBacks.prototype.checkHealthPrinter = function () {
623
- window.parent.postMessage({
589
+ this.smo.utils.sendToParent({
624
590
  target: "Dnv.smoCallbacks.checkHealthPrinter",
625
591
  idSmo: this.smo.id
626
592
  }, "*");
627
593
  };
628
594
  smoCallBacks.prototype.printImage = function (image) {
629
- window.parent.postMessage({
595
+ this.smo.utils.sendToParent({
630
596
  target: "Dnv.smoCallbacks.printImage",
631
597
  objData: {
632
598
  image: image
@@ -656,6 +622,87 @@ var Utils = /** @class */ (function () {
656
622
  var rejsn = JSON.stringify(js_obj, undefined, 2).replace(/(\\t|\\r|\\n)/g, '').replace(/"",[\n\t\r\s]+""[,]*/g, '').replace(/(\n[\t\s\r]*\n)/g, '').replace(/[\s\t]{2,}""[,]{0,1}/g, '').replace(/"[\s\t]{1,}"[,]{0,1}/g, '').replace(/\[[\t\s]*\]/g, '""');
657
623
  return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
658
624
  };
625
+ Utils.prototype.sendToParent = function (obj, dest) {
626
+ console.log('sendToParent->', obj);
627
+ //@ts-ignore
628
+ if (window.objJS) {
629
+ switch (obj.target) {
630
+ case "Dnv.smoCallbacks.onSmoLoad":
631
+ // @ts-ignore
632
+ window.objJS.onSmoLoad();
633
+ break;
634
+ case "Dnv.smoCallbacks.printTextLine":
635
+ // @ts-ignore
636
+ window.objJS.printTextLine(objData.txt);
637
+ break;
638
+ case "Dnv.smoCallbacks.printBarcode":
639
+ // @ts-ignore
640
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
641
+ break;
642
+ case "Dnv.smoCallbacks.cutPaper":
643
+ // @ts-ignore
644
+ window.objJS.cutPaper(objData.percent);
645
+ break;
646
+ case "Dnv.smoCallbacks.printImage":
647
+ // @ts-ignore
648
+ window.objJS.printImage(obj.idSmo, objData.image);
649
+ break;
650
+ case "Dnv.smoCallbacks.checkHealthPrinter":
651
+ console.log('llamo a checkhealthprinter');
652
+ // @ts-ignore
653
+ window.objJS.checkHealthPrinter(obj.idSmo);
654
+ break;
655
+ case "Dnv.smoCallbacks.checkHealth":
656
+ // @ts-ignore
657
+ window.objJS.checkHealth();
658
+ break;
659
+ case "Dnv.smoCallbacks.getFile":
660
+ // @ts-ignore
661
+ window.objJS.getFile(dest, obj.objData);
662
+ break;
663
+ }
664
+ return;
665
+ }
666
+ /* // @ts-ignore
667
+ window.parent.postMessage = (target,objData,idSmo)=> {
668
+ switch (target.target) {
669
+ case "Dnv.smoCallbacks.onSmoLoad":
670
+ // @ts-ignore
671
+ window.objJS.onSmoLoad();
672
+ break;
673
+
674
+ case "Dnv.smoCallbacks.printTextLine":
675
+ // @ts-ignore
676
+ window.objJS.printTextLine(objData.txt);
677
+ break;
678
+ case "Dnv.smoCallbacks.printBarcode":
679
+ // @ts-ignore
680
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
681
+ break;
682
+ case "Dnv.smoCallbacks.cutPaper":
683
+ // @ts-ignore
684
+ window.objJS.cutPaper(objData.percent);
685
+ break;
686
+ case "Dnv.smoCallbacks.printImage":
687
+ // @ts-ignore
688
+ window.objJS.printImage(idSmo, objData.image);
689
+ break;
690
+ case "Dnv.smoCallbacks.checkHealthPrinter":
691
+ console.log('llamo a checkhealthprinter');
692
+ // @ts-ignore
693
+
694
+ window.objJS.checkHealthPrinter(idSmo);
695
+ break;
696
+ case "Dnv.smoCallbacks.checkHealth":
697
+ // @ts-ignore
698
+ window.objJS.checkHealth();
699
+ break;
700
+
701
+
702
+ }
703
+ }*/
704
+ window.parent.postMessage(obj, dest);
705
+ };
659
706
  Utils.prototype.setJsonObj = function (xml) {
660
707
  var js_obj = {};
661
708
  if (xml.nodeType == 1) { // Element
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/smo.ts CHANGED
@@ -58,44 +58,7 @@ export class SMO {
58
58
  this.events.checkHealthPrinter.next(objData);
59
59
  break;
60
60
  }
61
- // @ts-ignore
62
- window.parent.postMessage = (target,objData,idSmo)=> {
63
- switch (target.target) {
64
- case "Dnv.smoCallbacks.onSmoLoad":
65
- // @ts-ignore
66
- window.objJS.onSmoLoad();
67
- break;
68
61
 
69
- case "Dnv.smoCallbacks.printTextLine":
70
- // @ts-ignore
71
- window.objJS.printTextLine(objData.txt);
72
- break;
73
- case "Dnv.smoCallbacks.printBarcode":
74
- // @ts-ignore
75
- window.objJS.printBarcode(objData.code, objData.width, objData.height);
76
- break;
77
- case "Dnv.smoCallbacks.cutPaper":
78
- // @ts-ignore
79
- window.objJS.cutPaper(objData.percent);
80
- break;
81
- case "Dnv.smoCallbacks.printImage":
82
- // @ts-ignore
83
- window.objJS.printImage(idSmo, objData.image);
84
- break;
85
- case "Dnv.smoCallbacks.checkHealthPrinter":
86
- console.log('llamo a checkhealthprinter');
87
- // @ts-ignore
88
-
89
- window.objJS.checkHealthPrinter(idSmo);
90
- break;
91
- case "Dnv.smoCallbacks.checkHealth":
92
- // @ts-ignore
93
- window.objJS.checkHealth();
94
- break;
95
-
96
-
97
- }
98
- }
99
62
 
100
63
  }
101
64
 
@@ -315,7 +278,7 @@ class SmoEvents{
315
278
  public getRecursosRelleno: Subject<GetRecursosRelleno> = new Subject<GetRecursosRelleno>();
316
279
  public getVariableStorage: Subject<variable> = new Subject<variable>();
317
280
  public checkHealth: Subject<string> = new Subject<string>();
318
- public checkHealthPrinter: Subject<String> = new Subject<String>();
281
+ public checkHealthPrinter: Subject<string> = new Subject<string>();
319
282
  constructor(smo:SMO){}
320
283
  }
321
284
  class smoCallBacks{
@@ -324,14 +287,14 @@ class smoCallBacks{
324
287
  this.smo =_smo;
325
288
  }
326
289
  public onSmoLoad():void {
327
- window.parent.postMessage({
290
+ this.smo.utils.sendToParent({
328
291
  target: "Dnv.smoCallbacks.onSmoLoad",
329
292
  objData: undefined,
330
293
  idSmo: this.smo.id
331
294
  }, "*");
332
295
  }
333
296
  public onSmoReady():void {
334
- window.parent.postMessage({
297
+ this.smo.utils.sendToParent({
335
298
  target: "Dnv.smoCallbacks.onSmoReady",
336
299
  objData: undefined,
337
300
  idSmo: this.smo.id
@@ -355,7 +318,7 @@ class smoCallBacks{
355
318
  console.error(msn);
356
319
  }
357
320
  if (window.parent != window) {
358
- window.parent.postMessage({
321
+ this.smo.utils.sendToParent({
359
322
  target: "Dnv.smoCallbacks.smoLog",
360
323
  objData: {
361
324
  level: level,
@@ -367,7 +330,7 @@ class smoCallBacks{
367
330
 
368
331
  }
369
332
  public smoAlarma(msn:string, level:AlarmaLevel):void {
370
- window.parent.postMessage({
333
+ this.smo.utils.sendToParent({
371
334
  target: "Dnv.smoCallbacks.smoAlarma",
372
335
  objData: {
373
336
  level: level,
@@ -377,7 +340,7 @@ class smoCallBacks{
377
340
  }, "*");
378
341
  }
379
342
  public smoLogStash(msn:string):void {
380
- window.parent.postMessage({
343
+ this.smo.utils.sendToParent({
381
344
  target: "Dnv.smoCallbacks.smoLogStash",
382
345
  objData: {
383
346
  txt: msn
@@ -386,7 +349,7 @@ class smoCallBacks{
386
349
  }, "*");
387
350
  }
388
351
  public smoLogNowShowing(msn:any):void {
389
- window.parent.postMessage({
352
+ this.smo.utils.sendToParent({
390
353
  target: "Dnv.smoCallbacks.smoNowShowing",
391
354
  objData: msn,
392
355
  idSmo: this.smo.id
@@ -394,7 +357,7 @@ class smoCallBacks{
394
357
  }
395
358
  public reiniciarDispositivo(msn:string):void {
396
359
  //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
397
- window.parent.postMessage({
360
+ this.smo.utils.sendToParent({
398
361
  target: "Dnv.smoCallbacks.reiniciarDispositivo",
399
362
  objData: {
400
363
  txt: msn // Razón del reinicio
@@ -404,7 +367,7 @@ class smoCallBacks{
404
367
  }
405
368
  urlNext():void {
406
369
  //Permite avanzar plantilla. Solo si Reloj Maestro activado.
407
- window.parent.postMessage({
370
+ this.smo.utils.sendToParent({
408
371
  target: "Dnv.smoCallbacks.urlNext",
409
372
  objData: undefined,
410
373
  idSmo: this.smo.id
@@ -412,7 +375,7 @@ class smoCallBacks{
412
375
  }
413
376
  exitInteractivity():void {
414
377
  //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
415
- window.parent.postMessage({
378
+ this.smo.utils.sendToParent({
416
379
  target: "Dnv.smoCallbacks.exitInteractivity",
417
380
  objData: undefined,
418
381
  idSmo: this.smo.id
@@ -428,7 +391,7 @@ class smoCallBacks{
428
391
  /* NOT IMPLEMENTED */
429
392
  }
430
393
  setVariable(variable:string, valor:string) {
431
- window.parent.postMessage({
394
+ this.smo.utils.sendToParent({
432
395
  target: "Dnv.smoCallbacks.setVariable",
433
396
  objData: {
434
397
  variable: variable,
@@ -438,7 +401,7 @@ class smoCallBacks{
438
401
  }, "*");
439
402
  }
440
403
  getVariable(variable:string):void {
441
- window.parent.postMessage({
404
+ this.smo.utils.sendToParent({
442
405
  target: "Dnv.smoCallbacks.getVariable",
443
406
  objData: {
444
407
  variable: variable
@@ -447,15 +410,16 @@ class smoCallBacks{
447
410
  }, "*");
448
411
  /* MIRAR SMO.getVariable */
449
412
  }
413
+
450
414
  getFile(file:string):void {
451
- parent.postMessage({
415
+ this.smo.utils.sendToParent({
452
416
  target: "Dnv.smoCallbacks.getFile",
453
417
  objData: file,
454
418
  idSmo: this.smo.id
455
419
  }, "*");
456
420
  }
457
421
  setLocalData(variable:string, valor:string):void {
458
- parent.postMessage({
422
+ this.smo.utils.sendToParent({
459
423
  target: "Dnv.smoCallbacks.setLocalData",
460
424
  objData: {
461
425
  nameData: variable,
@@ -465,7 +429,7 @@ class smoCallBacks{
465
429
  }, "*");
466
430
  }
467
431
  getLocalData(variable:string):void {
468
- parent.postMessage({
432
+ this.smo.utils.sendToParent({
469
433
  target: "Dnv.smoCallbacks.getLocalData",
470
434
  objData: variable, // nameData
471
435
  idSmo: this.smo.id
@@ -473,8 +437,7 @@ class smoCallBacks{
473
437
  /* MIRAR SMO.setDatasource */
474
438
  }
475
439
  getCurrentStream():void {
476
-
477
- parent.postMessage({
440
+ this.smo.utils.sendToParent({
478
441
  target: "Dnv.smoCallbacks.getCurrentStream",
479
442
  objData: undefined,
480
443
  idSmo: this.smo.id
@@ -482,21 +445,21 @@ class smoCallBacks{
482
445
  /* MIRAR SMO.setCurrentStream' */
483
446
  }
484
447
  finAviso(id:string):void {
485
- parent.postMessage({
448
+ this.smo.utils.sendToParent({
486
449
  target: "Dnv.smoCallbacks.finAviso",
487
450
  objData: id, // id del aviso
488
451
  idSmo: this.smo.id
489
452
  }, "*");
490
453
  }
491
454
  refreshDatasource(codigo:string):void {
492
- parent.postMessage({
455
+ this.smo.utils.sendToParent({
493
456
  target: "Dnv.smoCallbacks.refreshDatasource",
494
457
  objData: codigo, // Codigo del datasource
495
458
  idSmo: this.smo.id
496
459
  }, "*");
497
460
  }
498
461
  getLocation():void {
499
- parent.postMessage({
462
+ this.smo.utils.sendToParent({
500
463
  target: "Dnv.smoCallbacks.getLocation",
501
464
  objData: undefined,
502
465
  idSmo: this.smo.id
@@ -504,7 +467,7 @@ class smoCallBacks{
504
467
  /* MIRAR SMO.infoCurrentLocation */
505
468
  }
506
469
  getSalidaData(data:string):void {
507
- parent.postMessage({
470
+ this.smo.utils.sendToParent({
508
471
  target: "Dnv.smoCallbacks.getSalidaData",
509
472
  objData: data, // Nombre del "data" que solicita. El player recibe ese string y hace un select case del mismo para devolver un json con datos al smo\html5 que le ha invocado.
510
473
  idSmo: this.smo.id
@@ -516,7 +479,7 @@ class smoCallBacks{
516
479
  funcion: "", // Nombre de la función que se debe ejecutar
517
480
  params: "" // Parámetros que debemos enviarle a la funcion. sin separadores ni nada, un string y se usa como tal. Solo esta implementada en un caso y se usa como tal sin parsear ni nada
518
481
  } */
519
- parent.postMessage({
482
+ this.smo.utils.sendToParent({
520
483
  target: "Dnv.smoCallbacks.ejecutaFuncion",
521
484
  objData: data,
522
485
  idSmo: this.smo.id
@@ -525,7 +488,7 @@ class smoCallBacks{
525
488
  addObserver(data:string):void {
526
489
  /*data ="fruta"
527
490
  */
528
- parent.postMessage({
491
+ this.smo.utils.sendToParent({
529
492
  target: "Dnv.smoCallbacks.addObserver",
530
493
  objData: data,
531
494
  idSmo: this.smo.id
@@ -536,7 +499,7 @@ class smoCallBacks{
536
499
  destino: "fruta",
537
500
  value: "{'fruta':'manzana', 'color':'roja'}"
538
501
  } */
539
- parent.postMessage({
502
+ this.smo.utils.sendToParent({
540
503
  target: "Dnv.smoCallbacks.notify",
541
504
  objData: data,
542
505
  idSmo: this.smo.id
@@ -544,24 +507,24 @@ class smoCallBacks{
544
507
  }, "*");
545
508
  }
546
509
  playOnceChannelByTrigger(trigger:string):void {
547
- parent.postMessage({
510
+ this.smo.utils.sendToParent({
548
511
  target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
549
512
  objData: { triggerCanal: trigger },
550
513
  idSmo: this.smo.id
551
514
  }, "*");
552
515
  }
553
516
  stopPlayOnceChannelByTrigger():void {
554
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
517
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
555
518
  }
556
519
  playOnceChannel(codigoCanal:string):void {
557
- parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
520
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
558
521
  }
559
522
  stopPlayChannel():void {
560
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
523
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
561
524
  }
562
525
  editWrapperStyle(obj: any):void{
563
526
  /*{"posX": "0px","posY": "0px","alto": "0px","ancho": "0px","overflow": "hidden","scale": 0.1,"zindex": 0.1,"opacidad": 0.1,"isMaestro": true,duracionTransition: "1s", transitionTiming: "lineal", css: string} */
564
- parent.postMessage({
527
+ this.smo.utils.sendToParent({
565
528
  target: "Dnv.smoCallbacks.editWrapperStyle",
566
529
  objData: obj,
567
530
  idSmo: this.smo.id
@@ -569,7 +532,7 @@ class smoCallBacks{
569
532
  }
570
533
  getRecursosByCodigo(codigos: any):void{
571
534
  /** ["123456","654321"] */
572
- parent.postMessage({
535
+ this.smo.utils.sendToParent({
573
536
  target: "Dnv.smoCallbacks.getRecursosByCodigo",
574
537
  objData: {
575
538
  recursos : codigos
@@ -578,25 +541,25 @@ class smoCallBacks{
578
541
  }, "*");
579
542
  }
580
543
  getRecursos():void{
581
- parent.postMessage({
544
+ this.smo.utils.sendToParent({
582
545
  target: "Dnv.smoCallbacks.getRecursos",
583
546
  idSmo: this.smo.id
584
547
  }, "*");
585
548
  }
586
549
  getRecursosDefault():void{
587
- parent.postMessage({
550
+ this.smo.utils.sendToParent({
588
551
  target: "Dnv.smoCallbacks.getRecursosDefault",
589
552
  idSmo: this.smo.id
590
553
  }, "*");
591
554
  }
592
555
  getRecursosRelleno():void{
593
- parent.postMessage({
556
+ this.smo.utils.sendToParent({
594
557
  target: "Dnv.smoCallbacks.getRecursosRelleno",
595
558
  idSmo: this.smo.id
596
559
  }, "*");
597
560
  }
598
561
  setVariableStorage(variable:string, valor:string) {
599
- window.parent.postMessage({
562
+ this.smo.utils.sendToParent({
600
563
  target: "Dnv.smoCallbacks.setVariableStorage",
601
564
  objData: {
602
565
  variable: variable,
@@ -606,7 +569,7 @@ class smoCallBacks{
606
569
  }, "*");
607
570
  }
608
571
  getVariableStorage(variable:string):void {
609
- window.parent.postMessage({
572
+ this.smo.utils.sendToParent({
610
573
  target: "Dnv.smoCallbacks.getVariableStorage",
611
574
  objData: {
612
575
  variable: variable
@@ -616,7 +579,7 @@ class smoCallBacks{
616
579
  /* MIRAR SMO.getVariable */
617
580
  }
618
581
  printTextLine(txt:string):void{
619
- window.parent.postMessage({
582
+ this.smo.utils.sendToParent({
620
583
  target: "Dnv.smoCallbacks.printTextLine",
621
584
  objData: {
622
585
  txt: txt
@@ -625,7 +588,7 @@ class smoCallBacks{
625
588
  }, "*");
626
589
  }
627
590
  printBarcode(code:string, width:number, height:number):void{
628
- window.parent.postMessage({
591
+ this.smo.utils.sendToParent({
629
592
  target: "Dnv.smoCallbacks.printBarcode",
630
593
  objData: {
631
594
  code: code,
@@ -636,7 +599,7 @@ class smoCallBacks{
636
599
  }, "*");
637
600
  }
638
601
  cutPaper(percent:number):void{
639
- window.parent.postMessage({
602
+ this.smo.utils.sendToParent({
640
603
  target: "Dnv.smoCallbacks.cutPaper",
641
604
  objData: {
642
605
  percent: percent
@@ -645,19 +608,19 @@ class smoCallBacks{
645
608
  }, "*");
646
609
  }
647
610
  checkHealth(){
648
- window.parent.postMessage({
649
- target: "Dnv.smoCallbacks.checkHealth",
650
- idSmo: this.smo.id
651
- }, "*");
611
+ this.smo.utils.sendToParent({
612
+ target: "Dnv.smoCallbacks.checkHealth",
613
+ idSmo: this.smo.id
614
+ }, "*");
652
615
  }
653
616
  checkHealthPrinter(){
654
- window.parent.postMessage({
617
+ this.smo.utils.sendToParent({
655
618
  target: "Dnv.smoCallbacks.checkHealthPrinter",
656
619
  idSmo: this.smo.id
657
620
  }, "*");
658
621
  }
659
622
  printImage(image:string):void{
660
- window.parent.postMessage({
623
+ this.smo.utils.sendToParent({
661
624
  target: "Dnv.smoCallbacks.printImage",
662
625
  objData: {
663
626
  image: image
@@ -689,6 +652,88 @@ class Utils{
689
652
  let rejsn = JSON.stringify(js_obj, undefined, 2).replace(/(\\t|\\r|\\n)/g, '').replace(/"",[\n\t\r\s]+""[,]*/g, '').replace(/(\n[\t\s\r]*\n)/g, '').replace(/[\s\t]{2,}""[,]{0,1}/g, '').replace(/"[\s\t]{1,}"[,]{0,1}/g, '').replace(/\[[\t\s]*\]/g, '""');
690
653
  return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
691
654
  }
655
+ sendToParent(obj:any,dest:string){
656
+ console.log('sendToParent->',obj);
657
+ //@ts-ignore
658
+ if(window.objJS){
659
+ switch (obj.target) {
660
+ case "Dnv.smoCallbacks.onSmoLoad":
661
+ // @ts-ignore
662
+ window.objJS.onSmoLoad();
663
+ break;
664
+
665
+ case "Dnv.smoCallbacks.printTextLine":
666
+ // @ts-ignore
667
+ window.objJS.printTextLine(objData.txt);
668
+ break;
669
+ case "Dnv.smoCallbacks.printBarcode":
670
+ // @ts-ignore
671
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
672
+ break;
673
+ case "Dnv.smoCallbacks.cutPaper":
674
+ // @ts-ignore
675
+ window.objJS.cutPaper(objData.percent);
676
+ break;
677
+ case "Dnv.smoCallbacks.printImage":
678
+ // @ts-ignore
679
+ window.objJS.printImage(obj.idSmo, objData.image);
680
+ break;
681
+ case "Dnv.smoCallbacks.checkHealthPrinter":
682
+ console.log('llamo a checkhealthprinter');
683
+ // @ts-ignore
684
+ window.objJS.checkHealthPrinter(obj.idSmo);
685
+ break;
686
+ case "Dnv.smoCallbacks.checkHealth":
687
+ // @ts-ignore
688
+ window.objJS.checkHealth();
689
+ break;
690
+ case "Dnv.smoCallbacks.getFile":
691
+ // @ts-ignore
692
+ window.objJS.getFile(dest,obj.objData);
693
+ break;
694
+ }
695
+ return;
696
+ }
697
+ /* // @ts-ignore
698
+ window.parent.postMessage = (target,objData,idSmo)=> {
699
+ switch (target.target) {
700
+ case "Dnv.smoCallbacks.onSmoLoad":
701
+ // @ts-ignore
702
+ window.objJS.onSmoLoad();
703
+ break;
704
+
705
+ case "Dnv.smoCallbacks.printTextLine":
706
+ // @ts-ignore
707
+ window.objJS.printTextLine(objData.txt);
708
+ break;
709
+ case "Dnv.smoCallbacks.printBarcode":
710
+ // @ts-ignore
711
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
712
+ break;
713
+ case "Dnv.smoCallbacks.cutPaper":
714
+ // @ts-ignore
715
+ window.objJS.cutPaper(objData.percent);
716
+ break;
717
+ case "Dnv.smoCallbacks.printImage":
718
+ // @ts-ignore
719
+ window.objJS.printImage(idSmo, objData.image);
720
+ break;
721
+ case "Dnv.smoCallbacks.checkHealthPrinter":
722
+ console.log('llamo a checkhealthprinter');
723
+ // @ts-ignore
724
+
725
+ window.objJS.checkHealthPrinter(idSmo);
726
+ break;
727
+ case "Dnv.smoCallbacks.checkHealth":
728
+ // @ts-ignore
729
+ window.objJS.checkHealth();
730
+ break;
731
+
732
+
733
+ }
734
+ }*/
735
+ window.parent.postMessage(obj, dest);
736
+ }
692
737
  setJsonObj(xml: any) {
693
738
  let js_obj = {} as any;
694
739
  if (xml.nodeType == 1) { // Element