@denevads/dnv-smo 1.0.3 → 1.0.5
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/dnvsmo.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/dist/interfaces/callbacks.d.ts +15 -0
- package/dist/smo.d.ts +31 -15
- package/dist/smo.js +176 -94
- package/package.json +2 -1
- package/src/interfaces/callbacks.ts +19 -1
- package/src/smo.ts +201 -86
package/.idea/dnvsmo.iml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -31,3 +31,18 @@ export interface Notify {
|
|
|
31
31
|
destion: string;
|
|
32
32
|
value: any;
|
|
33
33
|
}
|
|
34
|
+
export interface VideoClips {
|
|
35
|
+
codigo: number;
|
|
36
|
+
fechaInicio: Date;
|
|
37
|
+
fechaFin: Date;
|
|
38
|
+
recursos: Recurso[];
|
|
39
|
+
}
|
|
40
|
+
export interface VideoClipsRelleno {
|
|
41
|
+
codigo: number;
|
|
42
|
+
recursos: Recurso[];
|
|
43
|
+
}
|
|
44
|
+
export interface Recurso {
|
|
45
|
+
codigo: number;
|
|
46
|
+
url: string;
|
|
47
|
+
duracion: number;
|
|
48
|
+
}
|
package/dist/smo.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { Observable } from 'rxjs';
|
|
5
|
-
export declare class SMO extends EventEmitter {
|
|
1
|
+
import { setDatasource, variable, location, DataSalida, ExecFunction, Notify, start, VideoClips, VideoClipsRelleno } from "./interfaces/callbacks";
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
export declare class SMO {
|
|
6
4
|
vars: any;
|
|
7
5
|
id: string;
|
|
6
|
+
private intervalsubscriptionDataSource;
|
|
7
|
+
intervalDataSource$: import("rxjs").Observable<number>;
|
|
8
8
|
smoCallBacks: smoCallBacks;
|
|
9
9
|
utils: Utils;
|
|
10
10
|
events: SmoEvents;
|
|
@@ -18,15 +18,22 @@ export declare class SMO extends EventEmitter {
|
|
|
18
18
|
infoCurrentLocation(location: location): void;
|
|
19
19
|
setSalidaData(data: DataSalida): void;
|
|
20
20
|
updatefromsalida(data: any): void;
|
|
21
|
+
getVideoClips(data: VideoClips): void;
|
|
22
|
+
getVideosRelleno(data: VideoClipsRelleno): void;
|
|
23
|
+
getVariableStorage(variable: variable): void;
|
|
21
24
|
}
|
|
22
25
|
declare class SmoEvents {
|
|
23
|
-
start:
|
|
24
|
-
setDatasource:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
start: Subject<start>;
|
|
27
|
+
setDatasource: Subject<setDatasource>;
|
|
28
|
+
setDatasourceJson: Subject<any>;
|
|
29
|
+
getVariable: Subject<variable>;
|
|
30
|
+
setCurrentStream: Subject<string>;
|
|
31
|
+
infoCurrentLocation: Subject<location>;
|
|
32
|
+
setSalidaData: Subject<DataSalida>;
|
|
33
|
+
updatefromsalida: Subject<any>;
|
|
34
|
+
getVideoClips: Subject<VideoClips>;
|
|
35
|
+
getVideosRelleno: Subject<VideoClipsRelleno>;
|
|
36
|
+
getVariableStorage: Subject<variable>;
|
|
30
37
|
constructor(smo: SMO);
|
|
31
38
|
}
|
|
32
39
|
declare class smoCallBacks {
|
|
@@ -60,14 +67,19 @@ declare class smoCallBacks {
|
|
|
60
67
|
playOnceChannel(codigoCanal: string): void;
|
|
61
68
|
stopPlayChannel(): void;
|
|
62
69
|
editWrapperStyle(obj: any): void;
|
|
70
|
+
getVideoClips(): void;
|
|
71
|
+
getVideosRelleno(): void;
|
|
72
|
+
setVariableStorage(variable: string, valor: string): void;
|
|
73
|
+
getVariableStorage(variable: string): void;
|
|
63
74
|
}
|
|
64
75
|
declare class Utils {
|
|
65
76
|
smo: SMO;
|
|
66
77
|
smoCallBacks: smoCallBacks;
|
|
67
78
|
constructor(_smo: SMO, _smoCallBacks: smoCallBacks);
|
|
79
|
+
xmlToJSON(xml: string): string;
|
|
80
|
+
jsonToStr(js_obj: any): string;
|
|
81
|
+
setJsonObj(xml: any): any;
|
|
68
82
|
dataToJSON(data: setDatasource): any;
|
|
69
|
-
getDatasource(): void;
|
|
70
|
-
startCheckDatasource(): void;
|
|
71
83
|
}
|
|
72
84
|
export declare enum SMO_EVENT_TYPE {
|
|
73
85
|
start = "start",
|
|
@@ -76,7 +88,11 @@ export declare enum SMO_EVENT_TYPE {
|
|
|
76
88
|
setCurrentStream = "setCurrentStream",
|
|
77
89
|
infoCurrentLocation = "infoCurrentLocation",
|
|
78
90
|
setSalidaData = "setSalidaData",
|
|
79
|
-
updatefromsalida = "updatefromsalida"
|
|
91
|
+
updatefromsalida = "updatefromsalida",
|
|
92
|
+
setDatasourceJson = "setDatasourceJson",
|
|
93
|
+
getVideoClips = "getVideoClips",
|
|
94
|
+
getVideosRelleno = "getVideosRelleno",
|
|
95
|
+
getVariableStorage = "getVariableStorage"
|
|
80
96
|
}
|
|
81
97
|
export declare enum LogLevel {
|
|
82
98
|
Debug = 0,
|
package/dist/smo.js
CHANGED
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.AlarmaLevel = exports.LogLevel = exports.SMO_EVENT_TYPE = exports.SMO = void 0;
|
|
19
|
-
var events_1 = require("events");
|
|
20
4
|
var rxjs_1 = require("rxjs");
|
|
21
|
-
var SMO = /** @class */ (function (
|
|
22
|
-
__extends(SMO, _super);
|
|
5
|
+
var SMO = /** @class */ (function () {
|
|
23
6
|
function SMO() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return _this;
|
|
7
|
+
this.vars = {};
|
|
8
|
+
this.id = "";
|
|
9
|
+
this.intervalDataSource$ = (0, rxjs_1.interval)(5 * 60 * 1000);
|
|
10
|
+
this.init();
|
|
11
|
+
this.initOnMessage();
|
|
12
|
+
this.smoCallBacks = new smoCallBacks(this);
|
|
13
|
+
this.utils = new Utils(this, this.smoCallBacks);
|
|
14
|
+
this.events = new SmoEvents(this);
|
|
33
15
|
}
|
|
34
16
|
SMO.prototype.init = function () {
|
|
17
|
+
var _this = this;
|
|
35
18
|
var match, pl = /\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) {
|
|
36
19
|
return decodeURIComponent(s.replace(pl, " "));
|
|
37
20
|
}, query = window.location.search.substring(1);
|
|
38
21
|
while (match = search.exec(query)) {
|
|
39
22
|
this.vars[decode(match[1])] = decode(match[2]);
|
|
40
23
|
}
|
|
24
|
+
/* let hash;
|
|
25
|
+
let hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");
|
|
26
|
+
for (var i = 0; i < hashes.length; i++) {
|
|
27
|
+
hash = hashes[i].split("=");
|
|
28
|
+
this.vars[hash[0]] = hash[1];
|
|
29
|
+
}*/
|
|
41
30
|
if (this.vars.idSmo) {
|
|
42
31
|
this.id = this.vars.idSmo;
|
|
43
|
-
|
|
32
|
+
if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
|
|
33
|
+
this.smoCallBacks.onSmoLoad();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.vars["url"] != undefined) {
|
|
37
|
+
this.smoCallBacks.getFile(this.vars["url"]);
|
|
38
|
+
this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
|
|
39
|
+
_this.smoCallBacks.getFile(_this.vars["url"]);
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (this.vars["LocalData"] != undefined) {
|
|
44
|
+
this.smoCallBacks.getLocalData(this.vars["LocalData"]);
|
|
45
|
+
this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
|
|
46
|
+
_this.smoCallBacks.getLocalData(_this.vars["LocalData"]);
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
console.warn("No idSmo found in URL");
|
|
46
52
|
};
|
|
53
|
+
/*getDatasource():void{
|
|
54
|
+
if(this.smo.vars.url == undefined){
|
|
55
|
+
this.smoCallBacks.getFile(this.smo.vars.LocalData);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.smoCallBacks.getFile(this.smo.vars.url);
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
startCheckDatasource(timeout: number = 10):void{
|
|
62
|
+
this.getDatasource();
|
|
63
|
+
let self = this;
|
|
64
|
+
setInterval(function() {
|
|
65
|
+
self.getDatasource();
|
|
66
|
+
}, timeout * 1000);
|
|
67
|
+
}*/
|
|
47
68
|
SMO.prototype.initOnMessage = function () {
|
|
48
69
|
var selft = this;
|
|
49
70
|
window.onmessage = function (e) {
|
|
@@ -78,56 +99,68 @@ var SMO = /** @class */ (function (_super) {
|
|
|
78
99
|
selft.updatefromsalida(e.data.objdata);
|
|
79
100
|
return;
|
|
80
101
|
}
|
|
102
|
+
if (func == SMO_EVENT_TYPE.getVideoClips) {
|
|
103
|
+
selft.getVideoClips(e.data.objData);
|
|
104
|
+
}
|
|
105
|
+
if (func == SMO_EVENT_TYPE.getVideosRelleno) {
|
|
106
|
+
selft.getVideosRelleno(e.data.objData);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (func == SMO_EVENT_TYPE.getVariableStorage) {
|
|
110
|
+
selft.getVariableStorage(e.data.objData);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
81
113
|
console.warn("message not implemented!!" + func);
|
|
82
|
-
/* try {
|
|
83
|
-
var targets = e.data.target.split('.');
|
|
84
|
-
var fn = window;
|
|
85
|
-
var obj = window;
|
|
86
|
-
for (var i = 0; i < targets.length; i++) {
|
|
87
|
-
obj = fn;
|
|
88
|
-
fn = obj[targets[i]];
|
|
89
|
-
}
|
|
90
|
-
fn.call(obj, e.data.objData); // conservamos el valor de this
|
|
91
|
-
} catch (ex) {
|
|
92
|
-
//Si no ha podido llamar es porque no existe el entorno
|
|
93
|
-
|
|
94
|
-
}*/
|
|
95
114
|
}
|
|
96
115
|
};
|
|
97
116
|
};
|
|
98
117
|
SMO.prototype.start = function () {
|
|
99
|
-
this.
|
|
118
|
+
this.events.start.next({});
|
|
100
119
|
};
|
|
101
120
|
SMO.prototype.setDatasource = function (datasource) {
|
|
102
|
-
this.
|
|
121
|
+
this.events.setDatasource.next(datasource);
|
|
122
|
+
this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
|
|
103
123
|
};
|
|
104
124
|
SMO.prototype.getVariable = function (variable) {
|
|
105
|
-
this.
|
|
125
|
+
this.events.getVariable.next(variable);
|
|
106
126
|
};
|
|
107
127
|
SMO.prototype.setCurrentStream = function (stream) {
|
|
108
|
-
this.
|
|
128
|
+
this.events.setCurrentStream.next(stream);
|
|
109
129
|
};
|
|
110
130
|
SMO.prototype.infoCurrentLocation = function (location) {
|
|
111
|
-
this.
|
|
131
|
+
this.events.infoCurrentLocation.next(location);
|
|
112
132
|
};
|
|
113
133
|
SMO.prototype.setSalidaData = function (data) {
|
|
114
|
-
this.
|
|
134
|
+
this.events.setSalidaData.next(data);
|
|
115
135
|
};
|
|
116
136
|
SMO.prototype.updatefromsalida = function (data) {
|
|
117
|
-
this.
|
|
137
|
+
this.events.updatefromsalida.next(data);
|
|
138
|
+
};
|
|
139
|
+
SMO.prototype.getVideoClips = function (data) {
|
|
140
|
+
this.events.getVideoClips.next(data);
|
|
141
|
+
};
|
|
142
|
+
SMO.prototype.getVideosRelleno = function (data) {
|
|
143
|
+
this.events.getVideosRelleno.next(data);
|
|
144
|
+
};
|
|
145
|
+
SMO.prototype.getVariableStorage = function (variable) {
|
|
146
|
+
this.events.getVariableStorage.next(variable);
|
|
118
147
|
};
|
|
119
148
|
return SMO;
|
|
120
|
-
}(
|
|
149
|
+
}());
|
|
121
150
|
exports.SMO = SMO;
|
|
122
151
|
var SmoEvents = /** @class */ (function () {
|
|
123
152
|
function SmoEvents(smo) {
|
|
124
|
-
this.start =
|
|
125
|
-
this.setDatasource =
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
153
|
+
this.start = new rxjs_1.Subject();
|
|
154
|
+
this.setDatasource = new rxjs_1.Subject();
|
|
155
|
+
this.setDatasourceJson = new rxjs_1.Subject();
|
|
156
|
+
this.getVariable = new rxjs_1.Subject();
|
|
157
|
+
this.setCurrentStream = new rxjs_1.Subject();
|
|
158
|
+
this.infoCurrentLocation = new rxjs_1.Subject();
|
|
159
|
+
this.setSalidaData = new rxjs_1.Subject();
|
|
160
|
+
this.updatefromsalida = new rxjs_1.Subject();
|
|
161
|
+
this.getVideoClips = new rxjs_1.Subject();
|
|
162
|
+
this.getVideosRelleno = new rxjs_1.Subject();
|
|
163
|
+
this.getVariableStorage = new rxjs_1.Subject();
|
|
131
164
|
}
|
|
132
165
|
return SmoEvents;
|
|
133
166
|
}());
|
|
@@ -192,7 +225,7 @@ var smoCallBacks = /** @class */ (function () {
|
|
|
192
225
|
window.parent.postMessage({
|
|
193
226
|
target: "Dnv.smoCallbacks.reiniciarDispositivo",
|
|
194
227
|
objData: {
|
|
195
|
-
txt: msn // Razón del reinicio
|
|
228
|
+
txt: msn // Razón del reinicio
|
|
196
229
|
},
|
|
197
230
|
idSmo: this.smo.id
|
|
198
231
|
}, "*");
|
|
@@ -353,13 +386,45 @@ var smoCallBacks = /** @class */ (function () {
|
|
|
353
386
|
parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
|
|
354
387
|
};
|
|
355
388
|
smoCallBacks.prototype.editWrapperStyle = function (obj) {
|
|
356
|
-
/*{"posX": "0px","posY": "0px","alto": "0px","ancho": "0px","overflow": "hidden","scale": 0.1,"zindex": 0.1,"opacidad": 0.1,"isMaestro": true} */
|
|
389
|
+
/*{"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} */
|
|
357
390
|
parent.postMessage({
|
|
358
391
|
target: "Dnv.smoCallbacks.editWrapperStyle",
|
|
359
392
|
objData: obj,
|
|
360
393
|
idSmo: this.smo.id
|
|
361
394
|
}, "*");
|
|
362
395
|
};
|
|
396
|
+
smoCallBacks.prototype.getVideoClips = function () {
|
|
397
|
+
parent.postMessage({
|
|
398
|
+
target: "Dnv.smoCallbacks.getVideoClips",
|
|
399
|
+
idSmo: this.smo.id
|
|
400
|
+
}, "*");
|
|
401
|
+
};
|
|
402
|
+
smoCallBacks.prototype.getVideosRelleno = function () {
|
|
403
|
+
parent.postMessage({
|
|
404
|
+
target: "Dnv.smoCallbacks.getVideosRelleno",
|
|
405
|
+
idSmo: this.smo.id
|
|
406
|
+
}, "*");
|
|
407
|
+
};
|
|
408
|
+
smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
|
|
409
|
+
window.parent.postMessage({
|
|
410
|
+
target: "Dnv.smoCallbacks.setVariableStorage",
|
|
411
|
+
objData: {
|
|
412
|
+
variable: variable,
|
|
413
|
+
valor: valor
|
|
414
|
+
},
|
|
415
|
+
idSmo: this.smo.id
|
|
416
|
+
}, "*");
|
|
417
|
+
};
|
|
418
|
+
smoCallBacks.prototype.getVariableStorage = function (variable) {
|
|
419
|
+
window.parent.postMessage({
|
|
420
|
+
target: "Dnv.smoCallbacks.getVariableStorage",
|
|
421
|
+
objData: {
|
|
422
|
+
variable: variable
|
|
423
|
+
},
|
|
424
|
+
idSmo: this.smo.id
|
|
425
|
+
}, "*");
|
|
426
|
+
/* MIRAR SMO.getVariable */
|
|
427
|
+
};
|
|
363
428
|
return smoCallBacks;
|
|
364
429
|
}());
|
|
365
430
|
var Utils = /** @class */ (function () {
|
|
@@ -367,6 +432,55 @@ var Utils = /** @class */ (function () {
|
|
|
367
432
|
this.smo = _smo;
|
|
368
433
|
this.smoCallBacks = _smoCallBacks;
|
|
369
434
|
}
|
|
435
|
+
// Funciones para XML to JSON
|
|
436
|
+
Utils.prototype.xmlToJSON = function (xml) {
|
|
437
|
+
var getxml = new DOMParser();
|
|
438
|
+
var xmlDoc = getxml.parseFromString(xml, "text/xml");
|
|
439
|
+
// gets the JSON string
|
|
440
|
+
var json_str = this.jsonToStr(this.setJsonObj(xmlDoc));
|
|
441
|
+
// sets and returns the JSON object, if "rstr" undefined (not passed), else, returns JSON string
|
|
442
|
+
return json_str;
|
|
443
|
+
};
|
|
444
|
+
Utils.prototype.jsonToStr = function (js_obj) {
|
|
445
|
+
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, '""');
|
|
446
|
+
return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
|
|
447
|
+
};
|
|
448
|
+
Utils.prototype.setJsonObj = function (xml) {
|
|
449
|
+
var js_obj = {};
|
|
450
|
+
if (xml.nodeType == 1) { // Element
|
|
451
|
+
if (xml.attributes.length > 0) {
|
|
452
|
+
js_obj["@attributes"] = {};
|
|
453
|
+
for (var j = 0; j < xml.attributes.length; j++) {
|
|
454
|
+
var attribute = xml.attributes.item(j);
|
|
455
|
+
js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
else if (xml.nodeType == 3) { // Text
|
|
460
|
+
js_obj = xml.nodeValue;
|
|
461
|
+
}
|
|
462
|
+
else if (xml.nodeType == 4) { // CDATA
|
|
463
|
+
js_obj = xml.nodeValue;
|
|
464
|
+
}
|
|
465
|
+
if (xml.hasChildNodes()) {
|
|
466
|
+
for (var i = 0; i < xml.childNodes.length; i++) {
|
|
467
|
+
var item = xml.childNodes.item(i);
|
|
468
|
+
var nodeName = item.nodeName;
|
|
469
|
+
if (typeof (js_obj[nodeName]) == "undefined") {
|
|
470
|
+
js_obj[nodeName] = this.setJsonObj(item);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
if (typeof (js_obj[nodeName].push) == "undefined") {
|
|
474
|
+
var old = js_obj[nodeName];
|
|
475
|
+
js_obj[nodeName] = [];
|
|
476
|
+
js_obj[nodeName].push(old);
|
|
477
|
+
}
|
|
478
|
+
js_obj[nodeName].push(this.setJsonObj(item));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return js_obj;
|
|
483
|
+
};
|
|
370
484
|
Utils.prototype.dataToJSON = function (data) {
|
|
371
485
|
try {
|
|
372
486
|
var parser = new DOMParser();
|
|
@@ -379,20 +493,6 @@ var Utils = /** @class */ (function () {
|
|
|
379
493
|
return {};
|
|
380
494
|
}
|
|
381
495
|
};
|
|
382
|
-
Utils.prototype.getDatasource = function () {
|
|
383
|
-
if (this.smo.vars.url == undefined) {
|
|
384
|
-
this.smoCallBacks.getFile(this.smo.vars.LocalData);
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
this.smoCallBacks.getFile(this.smo.vars.url);
|
|
388
|
-
};
|
|
389
|
-
Utils.prototype.startCheckDatasource = function () {
|
|
390
|
-
this.getDatasource();
|
|
391
|
-
var self = this;
|
|
392
|
-
setInterval(function () {
|
|
393
|
-
self.getDatasource();
|
|
394
|
-
}, 10000);
|
|
395
|
-
};
|
|
396
496
|
return Utils;
|
|
397
497
|
}());
|
|
398
498
|
var SMO_EVENT_TYPE;
|
|
@@ -404,29 +504,11 @@ var SMO_EVENT_TYPE;
|
|
|
404
504
|
SMO_EVENT_TYPE["infoCurrentLocation"] = "infoCurrentLocation";
|
|
405
505
|
SMO_EVENT_TYPE["setSalidaData"] = "setSalidaData";
|
|
406
506
|
SMO_EVENT_TYPE["updatefromsalida"] = "updatefromsalida";
|
|
507
|
+
SMO_EVENT_TYPE["setDatasourceJson"] = "setDatasourceJson";
|
|
508
|
+
SMO_EVENT_TYPE["getVideoClips"] = "getVideoClips";
|
|
509
|
+
SMO_EVENT_TYPE["getVideosRelleno"] = "getVideosRelleno";
|
|
510
|
+
SMO_EVENT_TYPE["getVariableStorage"] = "getVariableStorage";
|
|
407
511
|
})(SMO_EVENT_TYPE = exports.SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = {}));
|
|
408
|
-
/* start():void{
|
|
409
|
-
this.emit("start");
|
|
410
|
-
}
|
|
411
|
-
setDatasource(datasource:setDatasource):void {
|
|
412
|
-
this.emit("setDatasource",datasource);
|
|
413
|
-
}
|
|
414
|
-
getVariable(variable:variable):void{
|
|
415
|
-
this.emit("getVariable",variable);
|
|
416
|
-
}
|
|
417
|
-
setCurrentStream(stream:string):void{
|
|
418
|
-
this.emit("setCurrentStream",stream);
|
|
419
|
-
}
|
|
420
|
-
infoCurrentLocation(location:location):void{
|
|
421
|
-
this.emit("infoCurrentLocation",location);
|
|
422
|
-
}
|
|
423
|
-
setSalidaData(data:DataSalida):void{
|
|
424
|
-
this.emit("setSalidaData",data);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
updatefromsalida(data:any):void{
|
|
428
|
-
this.emit("updatefromsalida",data);
|
|
429
|
-
} */
|
|
430
512
|
var LogLevel;
|
|
431
513
|
(function (LogLevel) {
|
|
432
514
|
LogLevel[LogLevel["Debug"] = 0] = "Debug";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denevads/dnv-smo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "SMO module",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@types/node": "^17.0.42"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"mitt": "^3.0.0",
|
|
21
22
|
"rxjs": "^7.5.6"
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -33,4 +33,22 @@ export interface ExecFunction{
|
|
|
33
33
|
export interface Notify{
|
|
34
34
|
destion:string,
|
|
35
35
|
value:any
|
|
36
|
-
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface VideoClips {
|
|
39
|
+
codigo: number;
|
|
40
|
+
fechaInicio: Date;
|
|
41
|
+
fechaFin: Date;
|
|
42
|
+
recursos: Recurso[];
|
|
43
|
+
}
|
|
44
|
+
export interface VideoClipsRelleno {
|
|
45
|
+
codigo: number;
|
|
46
|
+
recursos: Recurso[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface Recurso {
|
|
50
|
+
codigo: number;
|
|
51
|
+
url: string;
|
|
52
|
+
duracion: number;
|
|
53
|
+
}
|
|
54
|
+
|
package/src/smo.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
setDatasource,
|
|
3
|
+
variable,
|
|
4
|
+
location,
|
|
5
|
+
DataSalida,
|
|
6
|
+
ExecFunction,
|
|
7
|
+
Notify,
|
|
8
|
+
start,
|
|
9
|
+
VideoClips, VideoClipsRelleno
|
|
10
|
+
} from "./interfaces/callbacks";
|
|
11
|
+
import {interval, Subject, Subscription} from 'rxjs';
|
|
12
|
+
export class SMO {
|
|
13
|
+
public vars:any = {};
|
|
14
|
+
public id:string = "";
|
|
15
|
+
private intervalsubscriptionDataSource!: Subscription;
|
|
16
|
+
intervalDataSource$ = interval(5 * 60 * 1000);
|
|
7
17
|
public smoCallBacks:smoCallBacks;
|
|
8
18
|
public utils:Utils;
|
|
9
19
|
public events:SmoEvents;
|
|
10
20
|
constructor(){
|
|
11
|
-
super();
|
|
12
21
|
this.init();
|
|
13
22
|
this.initOnMessage();
|
|
14
23
|
this.smoCallBacks = new smoCallBacks(this);
|
|
@@ -26,13 +35,52 @@ export class SMO extends EventEmitter{
|
|
|
26
35
|
while (match = search.exec(query)) {
|
|
27
36
|
this.vars[decode(match[1])] = decode(match[2]);
|
|
28
37
|
}
|
|
29
|
-
|
|
38
|
+
/* let hash;
|
|
39
|
+
let hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");
|
|
40
|
+
for (var i = 0; i < hashes.length; i++) {
|
|
41
|
+
hash = hashes[i].split("=");
|
|
42
|
+
this.vars[hash[0]] = hash[1];
|
|
43
|
+
}*/
|
|
30
44
|
if (this.vars.idSmo) {
|
|
31
45
|
this.id = this.vars.idSmo;
|
|
32
|
-
|
|
46
|
+
if(this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)){
|
|
47
|
+
this.smoCallBacks.onSmoLoad();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if(this.vars["url"] != undefined ){
|
|
51
|
+
this.smoCallBacks.getFile(this.vars["url"]);
|
|
52
|
+
this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(() => {
|
|
53
|
+
this.smoCallBacks.getFile(this.vars["url"]);
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if(this.vars["LocalData"] != undefined ){
|
|
58
|
+
this.smoCallBacks.getLocalData(this.vars["LocalData"]);
|
|
59
|
+
this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(() => {
|
|
60
|
+
this.smoCallBacks.getLocalData(this.vars["LocalData"]);
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
33
64
|
}
|
|
34
65
|
console.warn("No idSmo found in URL");
|
|
66
|
+
|
|
67
|
+
|
|
35
68
|
}
|
|
69
|
+
/*getDatasource():void{
|
|
70
|
+
if(this.smo.vars.url == undefined){
|
|
71
|
+
this.smoCallBacks.getFile(this.smo.vars.LocalData);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.smoCallBacks.getFile(this.smo.vars.url);
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
startCheckDatasource(timeout: number = 10):void{
|
|
78
|
+
this.getDatasource();
|
|
79
|
+
let self = this;
|
|
80
|
+
setInterval(function() {
|
|
81
|
+
self.getDatasource();
|
|
82
|
+
}, timeout * 1000);
|
|
83
|
+
}*/
|
|
36
84
|
initOnMessage():void{
|
|
37
85
|
let selft = this;
|
|
38
86
|
window.onmessage = function(e) {
|
|
@@ -53,7 +101,7 @@ export class SMO extends EventEmitter{
|
|
|
53
101
|
}
|
|
54
102
|
if(func ==SMO_EVENT_TYPE.setCurrentStream){
|
|
55
103
|
selft.setCurrentStream(e.data.objData);
|
|
56
|
-
return;
|
|
104
|
+
return;
|
|
57
105
|
}
|
|
58
106
|
if(func==SMO_EVENT_TYPE.infoCurrentLocation){
|
|
59
107
|
selft.infoCurrentLocation(e.data.objData);
|
|
@@ -67,64 +115,69 @@ export class SMO extends EventEmitter{
|
|
|
67
115
|
selft.updatefromsalida(e.data.objdata);
|
|
68
116
|
return;
|
|
69
117
|
}
|
|
118
|
+
if(func == SMO_EVENT_TYPE.getVideoClips){
|
|
119
|
+
selft.getVideoClips(e.data.objData);
|
|
120
|
+
}
|
|
121
|
+
if(func == SMO_EVENT_TYPE.getVideosRelleno){
|
|
122
|
+
selft.getVideosRelleno(e.data.objData);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if(func == SMO_EVENT_TYPE.getVariableStorage){
|
|
126
|
+
selft.getVariableStorage(e.data.objData);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
70
129
|
console.warn("message not implemented!!" +func);
|
|
71
|
-
/* try {
|
|
72
|
-
var targets = e.data.target.split('.');
|
|
73
|
-
var fn = window;
|
|
74
|
-
var obj = window;
|
|
75
|
-
for (var i = 0; i < targets.length; i++) {
|
|
76
|
-
obj = fn;
|
|
77
|
-
fn = obj[targets[i]];
|
|
78
|
-
}
|
|
79
|
-
fn.call(obj, e.data.objData); // conservamos el valor de this
|
|
80
|
-
} catch (ex) {
|
|
81
|
-
//Si no ha podido llamar es porque no existe el entorno
|
|
82
|
-
|
|
83
|
-
}*/
|
|
84
130
|
}
|
|
85
131
|
}
|
|
86
132
|
}
|
|
87
133
|
start():void{
|
|
88
|
-
this.
|
|
134
|
+
this.events.start.next({});
|
|
89
135
|
}
|
|
90
136
|
setDatasource(datasource:setDatasource):void {
|
|
91
|
-
this.
|
|
137
|
+
this.events.setDatasource.next(datasource);
|
|
138
|
+
this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
|
|
92
139
|
}
|
|
93
140
|
getVariable(variable:variable):void{
|
|
94
|
-
this.
|
|
141
|
+
this.events.getVariable.next(variable);
|
|
95
142
|
}
|
|
96
143
|
setCurrentStream(stream:string):void{
|
|
97
|
-
|
|
144
|
+
this.events.setCurrentStream.next(stream);
|
|
98
145
|
}
|
|
99
146
|
infoCurrentLocation(location:location):void{
|
|
100
|
-
this.
|
|
147
|
+
this.events.infoCurrentLocation.next(location);
|
|
101
148
|
}
|
|
102
149
|
setSalidaData(data:DataSalida):void{
|
|
103
|
-
|
|
150
|
+
this.events.setSalidaData.next(data);
|
|
104
151
|
}
|
|
105
|
-
|
|
152
|
+
|
|
106
153
|
updatefromsalida(data:any):void{
|
|
107
|
-
this.
|
|
154
|
+
this.events.updatefromsalida.next(data);
|
|
155
|
+
}
|
|
156
|
+
getVideoClips(data:VideoClips):void{
|
|
157
|
+
this.events.getVideoClips.next(data);
|
|
158
|
+
}
|
|
159
|
+
getVideosRelleno(data:VideoClipsRelleno):void{
|
|
160
|
+
this.events.getVideosRelleno.next(data);
|
|
161
|
+
}
|
|
162
|
+
getVariableStorage(variable:variable):void{
|
|
163
|
+
this.events.getVariableStorage.next(variable);
|
|
108
164
|
}
|
|
109
|
-
|
|
165
|
+
|
|
110
166
|
}
|
|
167
|
+
|
|
111
168
|
class SmoEvents{
|
|
112
|
-
public start:
|
|
113
|
-
public setDatasource:
|
|
114
|
-
public
|
|
115
|
-
public
|
|
116
|
-
public
|
|
117
|
-
public
|
|
118
|
-
public
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.infoCurrentLocation = fromEvent<location>(smo,SMO_EVENT_TYPE.infoCurrentLocation);
|
|
125
|
-
this.setSalidaData = fromEvent<DataSalida>(smo,SMO_EVENT_TYPE.setSalidaData);
|
|
126
|
-
this.updatefromsalida = fromEvent<any>(smo,SMO_EVENT_TYPE.updatefromsalida);
|
|
127
|
-
}
|
|
169
|
+
public start: Subject<start> = new Subject<start>();
|
|
170
|
+
public setDatasource: Subject<setDatasource> = new Subject<setDatasource>();
|
|
171
|
+
public setDatasourceJson: Subject<any> = new Subject<any>();
|
|
172
|
+
public getVariable: Subject<variable> = new Subject<variable>();
|
|
173
|
+
public setCurrentStream: Subject<string> = new Subject<string>();
|
|
174
|
+
public infoCurrentLocation: Subject<location> = new Subject<location>();
|
|
175
|
+
public setSalidaData: Subject<DataSalida> = new Subject<DataSalida>();
|
|
176
|
+
public updatefromsalida: Subject<any> = new Subject<any>();
|
|
177
|
+
public getVideoClips: Subject<VideoClips> = new Subject<VideoClips>();
|
|
178
|
+
public getVideosRelleno: Subject<VideoClipsRelleno> = new Subject<VideoClipsRelleno>();
|
|
179
|
+
public getVariableStorage: Subject<variable> = new Subject<variable>();
|
|
180
|
+
constructor(smo:SMO){}
|
|
128
181
|
}
|
|
129
182
|
class smoCallBacks{
|
|
130
183
|
smo:SMO;
|
|
@@ -132,7 +185,7 @@ class smoCallBacks{
|
|
|
132
185
|
this.smo =_smo;
|
|
133
186
|
}
|
|
134
187
|
public onSmoLoad():void {
|
|
135
|
-
|
|
188
|
+
|
|
136
189
|
window.parent.postMessage({
|
|
137
190
|
target: "Dnv.smoCallbacks.onSmoLoad",
|
|
138
191
|
objData: undefined,
|
|
@@ -190,7 +243,7 @@ class smoCallBacks{
|
|
|
190
243
|
window.parent.postMessage({
|
|
191
244
|
target: "Dnv.smoCallbacks.reiniciarDispositivo",
|
|
192
245
|
objData: {
|
|
193
|
-
txt: msn // Razón del reinicio
|
|
246
|
+
txt: msn // Razón del reinicio
|
|
194
247
|
},
|
|
195
248
|
idSmo: this.smo.id
|
|
196
249
|
}, "*");
|
|
@@ -260,7 +313,7 @@ class smoCallBacks{
|
|
|
260
313
|
getLocalData(variable:string):void {
|
|
261
314
|
parent.postMessage({
|
|
262
315
|
target: "Dnv.smoCallbacks.getLocalData",
|
|
263
|
-
objData: variable, // nameData
|
|
316
|
+
objData: variable, // nameData
|
|
264
317
|
idSmo: this.smo.id
|
|
265
318
|
}, "*");
|
|
266
319
|
/* MIRAR SMO.setDatasource */
|
|
@@ -277,14 +330,14 @@ class smoCallBacks{
|
|
|
277
330
|
finAviso(id:string):void {
|
|
278
331
|
parent.postMessage({
|
|
279
332
|
target: "Dnv.smoCallbacks.finAviso",
|
|
280
|
-
objData: id, // id del aviso
|
|
333
|
+
objData: id, // id del aviso
|
|
281
334
|
idSmo: this.smo.id
|
|
282
335
|
}, "*");
|
|
283
336
|
}
|
|
284
337
|
refreshDatasource(codigo:string):void {
|
|
285
338
|
parent.postMessage({
|
|
286
339
|
target: "Dnv.smoCallbacks.refreshDatasource",
|
|
287
|
-
objData: codigo, // Codigo del datasource
|
|
340
|
+
objData: codigo, // Codigo del datasource
|
|
288
341
|
idSmo: this.smo.id
|
|
289
342
|
}, "*");
|
|
290
343
|
}
|
|
@@ -299,15 +352,15 @@ class smoCallBacks{
|
|
|
299
352
|
getSalidaData(data:string):void {
|
|
300
353
|
parent.postMessage({
|
|
301
354
|
target: "Dnv.smoCallbacks.getSalidaData",
|
|
302
|
-
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.
|
|
355
|
+
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.
|
|
303
356
|
idSmo: this.smo.id
|
|
304
357
|
}, "*");
|
|
305
358
|
/* MIRAR SMO.setSalidaData */
|
|
306
359
|
}
|
|
307
360
|
ejecutaFuncion(data:ExecFunction):void {
|
|
308
361
|
/*data ={
|
|
309
|
-
funcion: "", // Nombre de la función que se debe ejecutar
|
|
310
|
-
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
|
|
362
|
+
funcion: "", // Nombre de la función que se debe ejecutar
|
|
363
|
+
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
|
|
311
364
|
} */
|
|
312
365
|
parent.postMessage({
|
|
313
366
|
target: "Dnv.smoCallbacks.ejecutaFuncion",
|
|
@@ -353,13 +406,47 @@ class smoCallBacks{
|
|
|
353
406
|
parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
|
|
354
407
|
}
|
|
355
408
|
editWrapperStyle(obj: any):void{
|
|
356
|
-
|
|
409
|
+
/*{"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} */
|
|
357
410
|
parent.postMessage({
|
|
358
411
|
target: "Dnv.smoCallbacks.editWrapperStyle",
|
|
359
412
|
objData: obj,
|
|
360
413
|
idSmo: this.smo.id
|
|
361
414
|
}, "*");
|
|
362
415
|
}
|
|
416
|
+
getVideoClips():void{
|
|
417
|
+
parent.postMessage({
|
|
418
|
+
target: "Dnv.smoCallbacks.getVideoClips",
|
|
419
|
+
idSmo: this.smo.id
|
|
420
|
+
}, "*");
|
|
421
|
+
}
|
|
422
|
+
getVideosRelleno():void{
|
|
423
|
+
parent.postMessage({
|
|
424
|
+
target: "Dnv.smoCallbacks.getVideosRelleno",
|
|
425
|
+
idSmo: this.smo.id
|
|
426
|
+
}, "*");
|
|
427
|
+
}
|
|
428
|
+
setVariableStorage(variable:string, valor:string) {
|
|
429
|
+
window.parent.postMessage({
|
|
430
|
+
target: "Dnv.smoCallbacks.setVariableStorage",
|
|
431
|
+
objData: {
|
|
432
|
+
variable: variable,
|
|
433
|
+
valor: valor
|
|
434
|
+
},
|
|
435
|
+
idSmo: this.smo.id
|
|
436
|
+
}, "*");
|
|
437
|
+
}
|
|
438
|
+
getVariableStorage(variable:string):void {
|
|
439
|
+
window.parent.postMessage({
|
|
440
|
+
target: "Dnv.smoCallbacks.getVariableStorage",
|
|
441
|
+
objData: {
|
|
442
|
+
variable: variable
|
|
443
|
+
},
|
|
444
|
+
idSmo: this.smo.id
|
|
445
|
+
}, "*");
|
|
446
|
+
/* MIRAR SMO.getVariable */
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
|
|
363
450
|
}
|
|
364
451
|
class Utils{
|
|
365
452
|
smo:SMO;
|
|
@@ -368,6 +455,52 @@ class Utils{
|
|
|
368
455
|
this.smo = _smo;
|
|
369
456
|
this.smoCallBacks =_smoCallBacks;
|
|
370
457
|
}
|
|
458
|
+
// Funciones para XML to JSON
|
|
459
|
+
xmlToJSON(xml:string) {
|
|
460
|
+
let getxml = new DOMParser();
|
|
461
|
+
let xmlDoc = getxml.parseFromString(xml,"text/xml");
|
|
462
|
+
// gets the JSON string
|
|
463
|
+
let json_str = this.jsonToStr(this.setJsonObj(xmlDoc));
|
|
464
|
+
// sets and returns the JSON object, if "rstr" undefined (not passed), else, returns JSON string
|
|
465
|
+
return json_str;
|
|
466
|
+
}
|
|
467
|
+
jsonToStr(js_obj:any) {
|
|
468
|
+
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, '""');
|
|
469
|
+
return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
|
|
470
|
+
}
|
|
471
|
+
setJsonObj(xml: any) {
|
|
472
|
+
let js_obj = {} as any;
|
|
473
|
+
if (xml.nodeType == 1) { // Element
|
|
474
|
+
if (xml.attributes.length > 0) {
|
|
475
|
+
js_obj["@attributes"] = {};
|
|
476
|
+
for (let j = 0; j < xml.attributes.length; j++) {
|
|
477
|
+
let attribute = xml.attributes.item(j);
|
|
478
|
+
js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
} else if (xml.nodeType == 3) { // Text
|
|
482
|
+
js_obj = xml.nodeValue;
|
|
483
|
+
} else if (xml.nodeType == 4) { // CDATA
|
|
484
|
+
js_obj = xml.nodeValue;
|
|
485
|
+
}
|
|
486
|
+
if (xml.hasChildNodes()) {
|
|
487
|
+
for (let i = 0; i < xml.childNodes.length; i++) {
|
|
488
|
+
let item = xml.childNodes.item(i);
|
|
489
|
+
let nodeName = item.nodeName;
|
|
490
|
+
if (typeof (js_obj[nodeName]) == "undefined") {
|
|
491
|
+
js_obj[nodeName] = this.setJsonObj(item);
|
|
492
|
+
} else {
|
|
493
|
+
if (typeof (js_obj[nodeName].push) == "undefined") {
|
|
494
|
+
let old = js_obj[nodeName];
|
|
495
|
+
js_obj[nodeName] = [];
|
|
496
|
+
js_obj[nodeName].push(old);
|
|
497
|
+
}
|
|
498
|
+
js_obj[nodeName].push(this.setJsonObj(item));
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return js_obj;
|
|
503
|
+
}
|
|
371
504
|
dataToJSON(data:setDatasource):any {
|
|
372
505
|
try {
|
|
373
506
|
var parser = new DOMParser();
|
|
@@ -379,21 +512,21 @@ class Utils{
|
|
|
379
512
|
return {};
|
|
380
513
|
}
|
|
381
514
|
}
|
|
382
|
-
getDatasource():void{
|
|
515
|
+
/*getDatasource():void{
|
|
383
516
|
if(this.smo.vars.url == undefined){
|
|
384
517
|
this.smoCallBacks.getFile(this.smo.vars.LocalData);
|
|
385
518
|
return;
|
|
386
519
|
}
|
|
387
520
|
this.smoCallBacks.getFile(this.smo.vars.url);
|
|
388
|
-
|
|
521
|
+
|
|
389
522
|
}
|
|
390
|
-
startCheckDatasource():void{
|
|
523
|
+
startCheckDatasource(timeout: number = 10):void{
|
|
391
524
|
this.getDatasource();
|
|
392
525
|
let self = this;
|
|
393
526
|
setInterval(function() {
|
|
394
527
|
self.getDatasource();
|
|
395
|
-
},
|
|
396
|
-
}
|
|
528
|
+
}, timeout * 1000);
|
|
529
|
+
}*/
|
|
397
530
|
}
|
|
398
531
|
export enum SMO_EVENT_TYPE{
|
|
399
532
|
start = "start",
|
|
@@ -402,30 +535,12 @@ export enum SMO_EVENT_TYPE{
|
|
|
402
535
|
setCurrentStream = "setCurrentStream",
|
|
403
536
|
infoCurrentLocation = "infoCurrentLocation",
|
|
404
537
|
setSalidaData ="setSalidaData",
|
|
405
|
-
updatefromsalida = "updatefromsalida"
|
|
538
|
+
updatefromsalida = "updatefromsalida",
|
|
539
|
+
setDatasourceJson = "setDatasourceJson",
|
|
540
|
+
getVideoClips = "getVideoClips",
|
|
541
|
+
getVideosRelleno = "getVideosRelleno",
|
|
542
|
+
getVariableStorage = "getVariableStorage"
|
|
406
543
|
}
|
|
407
|
-
/* start():void{
|
|
408
|
-
this.emit("start");
|
|
409
|
-
}
|
|
410
|
-
setDatasource(datasource:setDatasource):void {
|
|
411
|
-
this.emit("setDatasource",datasource);
|
|
412
|
-
}
|
|
413
|
-
getVariable(variable:variable):void{
|
|
414
|
-
this.emit("getVariable",variable);
|
|
415
|
-
}
|
|
416
|
-
setCurrentStream(stream:string):void{
|
|
417
|
-
this.emit("setCurrentStream",stream);
|
|
418
|
-
}
|
|
419
|
-
infoCurrentLocation(location:location):void{
|
|
420
|
-
this.emit("infoCurrentLocation",location);
|
|
421
|
-
}
|
|
422
|
-
setSalidaData(data:DataSalida):void{
|
|
423
|
-
this.emit("setSalidaData",data);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
updatefromsalida(data:any):void{
|
|
427
|
-
this.emit("updatefromsalida",data);
|
|
428
|
-
} */
|
|
429
544
|
export enum LogLevel {
|
|
430
545
|
Debug= 0,
|
|
431
546
|
Info= 1,
|
|
@@ -439,4 +554,4 @@ Scanning= 2,
|
|
|
439
554
|
Timeout= 3,
|
|
440
555
|
Warning= 4,
|
|
441
556
|
Error= 5
|
|
442
|
-
}
|
|
557
|
+
}
|