@denevads/dnv-smo 1.0.27 → 1.0.29
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/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/README.md +29 -29
- package/dist/smo.js +24 -15
- package/package.json +1 -1
- package/src/smo.ts +28 -22
package/README.md
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Introduction
|
|
2
|
+
Communication interface library between an HTML5 object and the functions of a Digital Signage Player from DenevaDS CMS.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Here we define the use of the library and the functions provided by the library
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
|
|
7
|
+
# Instalation
|
|
8
|
+
The library is intended to be used together with Angular, so if we do not have the Angular CLI in the system it is convenient to install it to initialize the project.
|
|
9
9
|
```sh
|
|
10
10
|
npm install -g @angular/cli
|
|
11
11
|
```
|
|
12
|
-
|
|
12
|
+
We start a test project called html-deneva in the path we are in.
|
|
13
13
|
```sh
|
|
14
14
|
ng new html-deneva
|
|
15
15
|
```
|
|
16
|
-
|
|
16
|
+
Once we have the basic structure of the project we can install the library in the project by executing the following line inside the project folder:
|
|
17
17
|
```sh
|
|
18
18
|
npm install @denevads/dnv-smo
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
#
|
|
21
|
+
# Initialization
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Once we have the Angular project initialized, we proceed to import the module.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Inside the app.module definition in the app folder, we import the library.
|
|
26
26
|
```ts
|
|
27
27
|
import { SMO } from '@denevads/dnv-smo/dist/smo';
|
|
28
28
|
```
|
|
29
|
-
|
|
29
|
+
and then add it as a provider in @NgModule
|
|
30
30
|
```ts
|
|
31
31
|
providers: [SMO]
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Now all you have to do is add it to the Angular component and start using it.
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Again in app.component we import the library
|
|
37
37
|
```js
|
|
38
38
|
import { LogLevel, SMO } from '@denevads/dnv-smo/dist/smo'
|
|
39
39
|
```
|
|
40
|
-
|
|
40
|
+
And in the export of the AppComponent class, we add the constructor
|
|
41
41
|
```js
|
|
42
42
|
constructor(private smo:SMO){ }
|
|
43
43
|
```
|
|
44
|
-
|
|
44
|
+
In this way we would already have available for use all the calls provided by the library using
|
|
45
45
|
```js
|
|
46
46
|
this.smo.
|
|
47
47
|
```
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
Also in the import we have brought the enumeration of the log levels, which are used to log in the local storage.
|
|
49
|
+
The usage would be as follows:
|
|
50
50
|
```js
|
|
51
|
-
this.smo.smoCallBacks.smoLog('
|
|
51
|
+
this.smo.smoCallBacks.smoLog('Test Message',LogLevel.Info);
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
#
|
|
54
|
+
# Compilation and packaging.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
In order for the project to run on a computer without problems, a couple of changes must be made to the default project code.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
The first one is to modify the tsconfig.json so that the "target" is "ES5" instead of "ES2022".
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
61
|
+
And the second change is in the index file. Here we will do two things:
|
|
62
|
+
-Delete the favicon import (in addition to deleting it from the file folder).
|
|
63
|
+
-And we change the line
|
|
64
64
|
```html
|
|
65
65
|
<base href="/">
|
|
66
66
|
```
|
|
67
|
-
|
|
67
|
+
to
|
|
68
68
|
```html
|
|
69
69
|
<script>document.write('<base href="' + document.location + '" />');</script>
|
|
70
70
|
```
|
|
71
|
-
|
|
71
|
+
With these changes made, we can compile the project by executing the command line
|
|
72
72
|
```sh
|
|
73
73
|
ng b
|
|
74
74
|
```
|
|
75
|
-
|
|
75
|
+
This will generate a dist folder with the content of our compiled HTML5.
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
In order to upload it to the deneva player, we simply have to create a zip with the content in the root, and change the extension to
|
|
78
78
|
```sh
|
|
79
79
|
.wgt
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
npm run build
|
|
83
83
|
npm login
|
|
84
|
-
npm publish
|
|
84
|
+
npm publish
|
package/dist/smo.js
CHANGED
|
@@ -23,7 +23,9 @@ var SMO = /** @class */ (function () {
|
|
|
23
23
|
this.vars[decode(match[1])] = decode(match[2]);
|
|
24
24
|
}
|
|
25
25
|
// @ts-ignore
|
|
26
|
-
if (window.objJS) {
|
|
26
|
+
if (window.objJS != undefined && window !== window.parent && this.vars.ontop != undefined && this.vars.ontop != "") {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
console.log("Existe objJS en window -->" + JSON.stringify(window.objJS));
|
|
27
29
|
// @ts-ignore
|
|
28
30
|
window.sendToIframefromNet = function (target, iframeID, objData) {
|
|
29
31
|
console.log("sendToIframefromNet->", JSON.stringify(target));
|
|
@@ -36,6 +38,7 @@ var SMO = /** @class */ (function () {
|
|
|
36
38
|
break;
|
|
37
39
|
}
|
|
38
40
|
};
|
|
41
|
+
// @ts-ignore
|
|
39
42
|
window.external = {
|
|
40
43
|
// @ts-ignore
|
|
41
44
|
URLNext: window.objJS.urlNext,
|
|
@@ -104,6 +107,7 @@ var SMO = /** @class */ (function () {
|
|
|
104
107
|
};
|
|
105
108
|
}
|
|
106
109
|
else {
|
|
110
|
+
console.log("No existe objJS en window");
|
|
107
111
|
if (this.vars.idSmo) {
|
|
108
112
|
this.id = this.vars.idSmo;
|
|
109
113
|
if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
|
|
@@ -127,6 +131,7 @@ var SMO = /** @class */ (function () {
|
|
|
127
131
|
return;
|
|
128
132
|
}
|
|
129
133
|
console.warn("No idSmo found in URL");
|
|
134
|
+
return;
|
|
130
135
|
}
|
|
131
136
|
if (this.vars.idSmo) {
|
|
132
137
|
this.id = this.vars.idSmo;
|
|
@@ -711,40 +716,44 @@ var Utils = /** @class */ (function () {
|
|
|
711
716
|
window.parent.postMessage(obj, dest);
|
|
712
717
|
};
|
|
713
718
|
Utils.prototype.setJsonObj = function (xml) {
|
|
714
|
-
var
|
|
719
|
+
var jsonObj = {};
|
|
715
720
|
if (xml.nodeType == 1) { // Element
|
|
716
721
|
if (xml.attributes.length > 0) {
|
|
717
|
-
|
|
722
|
+
jsonObj["ATTRIBUTES"] = {};
|
|
718
723
|
for (var j = 0; j < xml.attributes.length; j++) {
|
|
719
724
|
var attribute = xml.attributes.item(j);
|
|
720
|
-
|
|
725
|
+
jsonObj["ATTRIBUTES"][attribute.nodeName] = attribute.nodeValue;
|
|
721
726
|
}
|
|
722
727
|
}
|
|
723
728
|
}
|
|
724
729
|
else if (xml.nodeType == 3) { // Text
|
|
725
|
-
|
|
730
|
+
jsonObj = xml.nodeValue.trim();
|
|
726
731
|
}
|
|
727
732
|
else if (xml.nodeType == 4) { // CDATA
|
|
728
|
-
|
|
733
|
+
jsonObj = xml.nodeValue.trim();
|
|
729
734
|
}
|
|
730
735
|
if (xml.hasChildNodes()) {
|
|
731
736
|
for (var i = 0; i < xml.childNodes.length; i++) {
|
|
732
|
-
var item = xml.childNodes
|
|
737
|
+
var item = xml.childNodes[i];
|
|
733
738
|
var nodeName = item.nodeName;
|
|
734
|
-
if (
|
|
735
|
-
|
|
739
|
+
if (nodeName == "#text" && item.nodeType == 3) {
|
|
740
|
+
jsonObj = item.nodeValue.trim();
|
|
741
|
+
}
|
|
742
|
+
else if (nodeName == "#cdata-section" && (item.nodeType == 4 || item.nodeType == 3)) { //Para que quede bonito
|
|
743
|
+
jsonObj["CDATA"] = this.setJsonObj(item);
|
|
744
|
+
}
|
|
745
|
+
else if (typeof jsonObj[nodeName] === "undefined") {
|
|
746
|
+
jsonObj[nodeName] = this.setJsonObj(item);
|
|
736
747
|
}
|
|
737
748
|
else {
|
|
738
|
-
if (
|
|
739
|
-
|
|
740
|
-
js_obj[nodeName] = [];
|
|
741
|
-
js_obj[nodeName].push(old);
|
|
749
|
+
if (!Array.isArray(jsonObj[nodeName])) {
|
|
750
|
+
jsonObj[nodeName] = [jsonObj[nodeName]];
|
|
742
751
|
}
|
|
743
|
-
|
|
752
|
+
jsonObj[nodeName].push(this.setJsonObj(item));
|
|
744
753
|
}
|
|
745
754
|
}
|
|
746
755
|
}
|
|
747
|
-
return
|
|
756
|
+
return jsonObj;
|
|
748
757
|
};
|
|
749
758
|
Utils.prototype.dataToJSON = function (data) {
|
|
750
759
|
try {
|
package/package.json
CHANGED
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
|
-
|
|
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 != undefined && window !== window.parent && this.vars.ontop != undefined && this.vars.ontop != ""){
|
|
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) {
|
|
@@ -743,38 +742,45 @@ class Utils{
|
|
|
743
742
|
window.parent.postMessage(obj, dest);
|
|
744
743
|
}
|
|
745
744
|
setJsonObj(xml: any) {
|
|
746
|
-
let
|
|
745
|
+
let jsonObj = {} as any;
|
|
746
|
+
|
|
747
747
|
if (xml.nodeType == 1) { // Element
|
|
748
748
|
if (xml.attributes.length > 0) {
|
|
749
|
-
|
|
749
|
+
jsonObj["ATTRIBUTES"] = {};
|
|
750
750
|
for (let j = 0; j < xml.attributes.length; j++) {
|
|
751
751
|
let attribute = xml.attributes.item(j);
|
|
752
|
-
|
|
752
|
+
jsonObj["ATTRIBUTES"][attribute.nodeName] = attribute.nodeValue;
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
} else if (xml.nodeType == 3) { // Text
|
|
756
|
-
|
|
756
|
+
jsonObj = xml.nodeValue.trim();
|
|
757
757
|
} else if (xml.nodeType == 4) { // CDATA
|
|
758
|
-
|
|
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
|
|
763
|
+
let item = xml.childNodes[i];
|
|
763
764
|
let nodeName = item.nodeName;
|
|
764
|
-
|
|
765
|
-
|
|
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 (
|
|
768
|
-
|
|
769
|
-
js_obj[nodeName] = [];
|
|
770
|
-
js_obj[nodeName].push(old);
|
|
773
|
+
if (!Array.isArray(jsonObj[nodeName])) {
|
|
774
|
+
jsonObj[nodeName] = [jsonObj[nodeName]];
|
|
771
775
|
}
|
|
772
|
-
|
|
776
|
+
jsonObj[nodeName].push(this.setJsonObj(item));
|
|
773
777
|
}
|
|
774
778
|
}
|
|
775
779
|
}
|
|
776
|
-
|
|
780
|
+
|
|
781
|
+
return jsonObj;
|
|
777
782
|
}
|
|
783
|
+
|
|
778
784
|
dataToJSON(data:setDatasource):any {
|
|
779
785
|
try {
|
|
780
786
|
var parser = new DOMParser();
|