@denevads/dnv-smo 1.0.26 → 1.0.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/smo.ts CHANGED
@@ -11,10 +11,7 @@ import {
11
11
  GetRecursosRelleno
12
12
  } from "./interfaces/callbacks";
13
13
  import {interval, Subject, Subscription} from 'rxjs';
14
- interface Window {
15
- external:ObjJSType;
16
- objJS:ObjJSType;
17
- }
14
+
18
15
  // @ts-ignore
19
16
 
20
17
  export class SMO {
@@ -46,7 +43,9 @@ export class SMO {
46
43
  this.vars[decode(match[1])] = decode(match[2]);
47
44
  }
48
45
  // @ts-ignore
49
- if(window.objJS){
46
+ if(window.objJS && window.self === window.top){
47
+ // @ts-ignore
48
+ console.log("Existe objJS en window -->" + JSON.stringify(window.objJS));
50
49
  // @ts-ignore
51
50
  window.sendToIframefromNet = (target, iframeID, objData) => {
52
51
  console.log("sendToIframefromNet->",JSON.stringify(target));
@@ -58,10 +57,8 @@ export class SMO {
58
57
  this.events.checkHealthPrinter.next(objData);
59
58
  break;
60
59
  }
61
-
62
-
63
60
  }
64
-
61
+ // @ts-ignore
65
62
  window.external = {
66
63
  // @ts-ignore
67
64
  URLNext: window.objJS.urlNext,
@@ -129,6 +126,7 @@ export class SMO {
129
126
  CheckHealth: window.objJS.checkHealth
130
127
  };
131
128
  }else{
129
+ console.log("No existe objJS en window");
132
130
  if (this.vars.idSmo) {
133
131
  this.id = this.vars.idSmo;
134
132
  if(this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)){
@@ -152,6 +150,7 @@ export class SMO {
152
150
  return;
153
151
  }
154
152
  console.warn("No idSmo found in URL");
153
+ return;
155
154
  }
156
155
 
157
156
  if (this.vars.idSmo) {
@@ -192,7 +191,7 @@ export class SMO {
192
191
  return;
193
192
  }
194
193
  if(func ==SMO_EVENT_TYPE.updatefromsalida){
195
- selft.updatefromsalida(e.data.objdata);
194
+ selft.updatefromsalida(e.data.objData);
196
195
  return;
197
196
  }
198
197
  if(func == SMO_EVENT_TYPE.getRecursosByCodigo){
@@ -743,38 +742,45 @@ class Utils{
743
742
  window.parent.postMessage(obj, dest);
744
743
  }
745
744
  setJsonObj(xml: any) {
746
- let js_obj = {} as any;
745
+ let jsonObj = {} as any;
746
+
747
747
  if (xml.nodeType == 1) { // Element
748
748
  if (xml.attributes.length > 0) {
749
- js_obj["@attributes"] = {};
749
+ jsonObj["attributes"] = {};
750
750
  for (let j = 0; j < xml.attributes.length; j++) {
751
751
  let attribute = xml.attributes.item(j);
752
- js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
752
+ jsonObj["attributes"][attribute.nodeName] = attribute.nodeValue;
753
753
  }
754
754
  }
755
755
  } else if (xml.nodeType == 3) { // Text
756
- js_obj = xml.nodeValue;
756
+ jsonObj = xml.nodeValue.trim();
757
757
  } else if (xml.nodeType == 4) { // CDATA
758
- js_obj = xml.nodeValue;
758
+ jsonObj = xml.nodeValue.trim();
759
759
  }
760
+
760
761
  if (xml.hasChildNodes()) {
761
762
  for (let i = 0; i < xml.childNodes.length; i++) {
762
- let item = xml.childNodes.item(i);
763
+ let item = xml.childNodes[i];
763
764
  let nodeName = item.nodeName;
764
- if (typeof (js_obj[nodeName]) == "undefined") {
765
- js_obj[nodeName] = this.setJsonObj(item);
765
+
766
+ if (nodeName == "#text" && item.nodeType == 3) {
767
+ jsonObj = item.nodeValue.trim();
768
+ }else if (nodeName == "#cdata-section" && (item.nodeType == 4 || item.nodeType == 3)) { //Para que quede bonito
769
+ jsonObj["cdata"] = this.setJsonObj(item);
770
+ } else if (typeof jsonObj[nodeName] === "undefined") {
771
+ jsonObj[nodeName] = this.setJsonObj(item);
766
772
  } else {
767
- if (typeof (js_obj[nodeName].push) == "undefined") {
768
- let old = js_obj[nodeName];
769
- js_obj[nodeName] = [];
770
- js_obj[nodeName].push(old);
773
+ if (!Array.isArray(jsonObj[nodeName])) {
774
+ jsonObj[nodeName] = [jsonObj[nodeName]];
771
775
  }
772
- js_obj[nodeName].push(this.setJsonObj(item));
776
+ jsonObj[nodeName].push(this.setJsonObj(item));
773
777
  }
774
778
  }
775
779
  }
776
- return js_obj;
780
+
781
+ return jsonObj;
777
782
  }
783
+
778
784
  dataToJSON(data:setDatasource):any {
779
785
  try {
780
786
  var parser = new DOMParser();