@denevads/dnv-smo 1.0.15 → 1.0.16

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.js CHANGED
@@ -1,605 +1,605 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlarmaLevel = exports.LogLevel = exports.SMO_EVENT_TYPE = exports.SMO = void 0;
4
- var rxjs_1 = require("rxjs");
5
- var SMO = /** @class */ (function () {
6
- function SMO() {
7
- this.vars = {};
8
- this.id = "";
9
- this.intervalDataSource$ = (0, rxjs_1.interval)(5 * 60 * 1000);
10
- this.initOnMessage();
11
- this.smoCallBacks = new smoCallBacks(this);
12
- this.utils = new Utils(this, this.smoCallBacks);
13
- this.events = new SmoEvents(this);
14
- this.init();
15
- }
16
- SMO.prototype.init = function () {
17
- var _this = this;
18
- var match, pl = /\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) {
19
- return decodeURIComponent(s.replace(pl, " "));
20
- }, query = window.location.search.substring(1);
21
- while (match = search.exec(query)) {
22
- this.vars[decode(match[1])] = decode(match[2]);
23
- }
24
- if (this.vars.idSmo) {
25
- this.id = this.vars.idSmo;
26
- if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
27
- this.smoCallBacks.onSmoLoad();
28
- return;
29
- }
30
- if (this.vars["url"] != undefined) {
31
- this.smoCallBacks.getFile(this.vars["url"]);
32
- this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
33
- _this.smoCallBacks.getFile(_this.vars["url"]);
34
- });
35
- return;
36
- }
37
- if (this.vars["LocalData"] != undefined) {
38
- this.smoCallBacks.getLocalData(this.vars["LocalData"]);
39
- this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
40
- _this.smoCallBacks.getLocalData(_this.vars["LocalData"]);
41
- });
42
- return;
43
- }
44
- return;
45
- }
46
- console.warn("No idSmo found in URL");
47
- };
48
- SMO.prototype.initOnMessage = function () {
49
- var selft = this;
50
- window.onmessage = function (e) {
51
- if (e.data.target) {
52
- var targets = e.data.target.split('.');
53
- var func = targets[targets.length - 1];
54
- if (func == SMO_EVENT_TYPE.start) {
55
- selft.start();
56
- return;
57
- }
58
- if (func == SMO_EVENT_TYPE.setDatasource) {
59
- selft.setDatasource(e.data.objData);
60
- return;
61
- }
62
- if (func == SMO_EVENT_TYPE.getVariable) {
63
- selft.getVariable(e.data.objData);
64
- return;
65
- }
66
- if (func == SMO_EVENT_TYPE.setCurrentStream) {
67
- selft.setCurrentStream(e.data.objData);
68
- return;
69
- }
70
- if (func == SMO_EVENT_TYPE.infoCurrentLocation) {
71
- selft.infoCurrentLocation(e.data.objData);
72
- return;
73
- }
74
- if (func == SMO_EVENT_TYPE.setSalidaData) {
75
- selft.setSalidaData(e.data.objData);
76
- return;
77
- }
78
- if (func == SMO_EVENT_TYPE.updatefromsalida) {
79
- selft.updatefromsalida(e.data.objdata);
80
- return;
81
- }
82
- if (func == SMO_EVENT_TYPE.getRecursos) {
83
- selft.getRecursos(e.data.objData);
84
- }
85
- if (func == SMO_EVENT_TYPE.getRecursosDefault) {
86
- selft.getRecursosDefault(e.data.objData);
87
- }
88
- if (func == SMO_EVENT_TYPE.getRecursosRelleno) {
89
- selft.getRecursosRelleno(e.data.objData);
90
- return;
91
- }
92
- if (func == SMO_EVENT_TYPE.getVariableStorage) {
93
- selft.getVariableStorage(e.data.objData);
94
- return;
95
- }
96
- if (func == SMO_EVENT_TYPE.checkHealth) {
97
- selft.checkHealth(e.data.objData);
98
- return;
99
- }
100
- if (func == SMO_EVENT_TYPE.checkHealthPrinter) {
101
- selft.checkHealthPrinter(e.data.objData);
102
- return;
103
- }
104
- console.warn("message not implemented!!" + func);
105
- }
106
- };
107
- };
108
- SMO.prototype.start = function () {
109
- this.events.start.next({});
110
- };
111
- SMO.prototype.setDatasource = function (datasource) {
112
- this.events.setDatasource.next(datasource);
113
- this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
114
- };
115
- SMO.prototype.getVariable = function (variable) {
116
- this.events.getVariable.next(variable);
117
- };
118
- SMO.prototype.setCurrentStream = function (stream) {
119
- this.events.setCurrentStream.next(stream);
120
- };
121
- SMO.prototype.infoCurrentLocation = function (location) {
122
- this.events.infoCurrentLocation.next(location);
123
- };
124
- SMO.prototype.setSalidaData = function (data) {
125
- this.events.setSalidaData.next(data);
126
- };
127
- SMO.prototype.updatefromsalida = function (data) {
128
- this.events.updatefromsalida.next(data);
129
- };
130
- SMO.prototype.getRecursos = function (data) {
131
- this.events.getRecursos.next(data);
132
- };
133
- SMO.prototype.getRecursosDefault = function (data) {
134
- this.events.getRecursosDefault.next(data);
135
- };
136
- SMO.prototype.getRecursosRelleno = function (data) {
137
- this.events.getRecursosRelleno.next(data);
138
- };
139
- SMO.prototype.getVariableStorage = function (variable) {
140
- this.events.getVariableStorage.next(variable);
141
- };
142
- SMO.prototype.checkHealth = function (json) {
143
- this.events.checkHealth.next(json);
144
- };
145
- SMO.prototype.checkHealthPrinter = function (json) {
146
- this.events.checkHealthPrinter.next(json);
147
- };
148
- return SMO;
149
- }());
150
- exports.SMO = SMO;
151
- var SmoEvents = /** @class */ (function () {
152
- function SmoEvents(smo) {
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.getRecursos = new rxjs_1.Subject();
162
- this.getRecursosDefault = new rxjs_1.Subject();
163
- this.getRecursosRelleno = new rxjs_1.Subject();
164
- this.getVariableStorage = new rxjs_1.Subject();
165
- this.checkHealth = new rxjs_1.Subject();
166
- this.checkHealthPrinter = new rxjs_1.Subject();
167
- }
168
- return SmoEvents;
169
- }());
170
- var smoCallBacks = /** @class */ (function () {
171
- function smoCallBacks(_smo) {
172
- this.smo = _smo;
173
- }
174
- smoCallBacks.prototype.onSmoLoad = function () {
175
- window.parent.postMessage({
176
- target: "Dnv.smoCallbacks.onSmoLoad",
177
- objData: undefined,
178
- idSmo: this.smo.id
179
- }, "*");
180
- };
181
- smoCallBacks.prototype.onSmoReady = function () {
182
- window.parent.postMessage({
183
- target: "Dnv.smoCallbacks.onSmoReady",
184
- objData: undefined,
185
- idSmo: this.smo.id
186
- }, "*");
187
- };
188
- smoCallBacks.prototype.smoLog = function (msn, level) {
189
- if (level == undefined) {
190
- level = LogLevel.Info;
191
- }
192
- //level = Dnv.LogLevel.Debug...
193
- if (level == LogLevel.Debug) {
194
- console.debug(msn);
195
- }
196
- if (level == LogLevel.Info) {
197
- console.log(msn);
198
- }
199
- if (level == LogLevel.Warning) {
200
- console.warn(msn);
201
- }
202
- if (level == LogLevel.Error) {
203
- console.error(msn);
204
- }
205
- if (window.parent != window) {
206
- window.parent.postMessage({
207
- target: "Dnv.smoCallbacks.smoLog",
208
- objData: {
209
- level: level,
210
- txt: msn
211
- },
212
- idSmo: this.smo.id
213
- }, "*");
214
- }
215
- };
216
- smoCallBacks.prototype.smoAlarma = function (msn, level) {
217
- window.parent.postMessage({
218
- target: "Dnv.smoCallbacks.smoAlarma",
219
- objData: {
220
- level: level,
221
- txt: msn
222
- },
223
- idSmo: this.smo.id
224
- }, "*");
225
- };
226
- smoCallBacks.prototype.smoLogStash = function (msn) {
227
- window.parent.postMessage({
228
- target: "Dnv.smoCallbacks.smoLogStash",
229
- objData: {
230
- txt: msn
231
- },
232
- idSmo: this.smo.id
233
- }, "*");
234
- };
235
- smoCallBacks.prototype.smoLogNowShowing = function (msn) {
236
- window.parent.postMessage({
237
- target: "Dnv.smoCallbacks.smoNowShowing",
238
- objData: msn,
239
- idSmo: this.smo.id
240
- }, "*");
241
- };
242
- smoCallBacks.prototype.reiniciarDispositivo = function (msn) {
243
- //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
244
- window.parent.postMessage({
245
- target: "Dnv.smoCallbacks.reiniciarDispositivo",
246
- objData: {
247
- txt: msn // Razón del reinicio
248
- },
249
- idSmo: this.smo.id
250
- }, "*");
251
- };
252
- smoCallBacks.prototype.urlNext = function () {
253
- //Permite avanzar plantilla. Solo si Reloj Maestro activado.
254
- window.parent.postMessage({
255
- target: "Dnv.smoCallbacks.urlNext",
256
- objData: undefined,
257
- idSmo: this.smo.id
258
- }, "*");
259
- };
260
- smoCallBacks.prototype.exitInteractivity = function () {
261
- //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
262
- window.parent.postMessage({
263
- target: "Dnv.smoCallbacks.exitInteractivity",
264
- objData: undefined,
265
- idSmo: this.smo.id
266
- }, "*");
267
- };
268
- smoCallBacks.prototype.showBrowser = function () {
269
- /* DEPRECATED NOT IMPLEMENTED */
270
- };
271
- smoCallBacks.prototype.closeBrowser = function () {
272
- /* DEPRECATED NOT IMPLEMENTED */
273
- };
274
- smoCallBacks.prototype.urlNextDirectamente = function () {
275
- /* NOT IMPLEMENTED */
276
- };
277
- smoCallBacks.prototype.setVariable = function (variable, valor) {
278
- window.parent.postMessage({
279
- target: "Dnv.smoCallbacks.setVariable",
280
- objData: {
281
- variable: variable,
282
- valor: valor
283
- },
284
- idSmo: this.smo.id
285
- }, "*");
286
- };
287
- smoCallBacks.prototype.getVariable = function (variable) {
288
- window.parent.postMessage({
289
- target: "Dnv.smoCallbacks.getVariable",
290
- objData: {
291
- variable: variable
292
- },
293
- idSmo: this.smo.id
294
- }, "*");
295
- /* MIRAR SMO.getVariable */
296
- };
297
- smoCallBacks.prototype.getFile = function (file) {
298
- parent.postMessage({
299
- target: "Dnv.smoCallbacks.getFile",
300
- objData: file,
301
- idSmo: this.smo.id
302
- }, "*");
303
- };
304
- smoCallBacks.prototype.setLocalData = function (variable, valor) {
305
- parent.postMessage({
306
- target: "Dnv.smoCallbacks.setLocalData",
307
- objData: {
308
- nameData: variable,
309
- data: valor
310
- },
311
- idSmo: this.smo.id
312
- }, "*");
313
- };
314
- smoCallBacks.prototype.getLocalData = function (variable) {
315
- parent.postMessage({
316
- target: "Dnv.smoCallbacks.getLocalData",
317
- objData: variable,
318
- idSmo: this.smo.id
319
- }, "*");
320
- /* MIRAR SMO.setDatasource */
321
- };
322
- smoCallBacks.prototype.getCurrentStream = function () {
323
- parent.postMessage({
324
- target: "Dnv.smoCallbacks.getCurrentStream",
325
- objData: undefined,
326
- idSmo: this.smo.id
327
- }, "*");
328
- /* MIRAR SMO.setCurrentStream' */
329
- };
330
- smoCallBacks.prototype.finAviso = function (id) {
331
- parent.postMessage({
332
- target: "Dnv.smoCallbacks.finAviso",
333
- objData: id,
334
- idSmo: this.smo.id
335
- }, "*");
336
- };
337
- smoCallBacks.prototype.refreshDatasource = function (codigo) {
338
- parent.postMessage({
339
- target: "Dnv.smoCallbacks.refreshDatasource",
340
- objData: codigo,
341
- idSmo: this.smo.id
342
- }, "*");
343
- };
344
- smoCallBacks.prototype.getLocation = function () {
345
- parent.postMessage({
346
- target: "Dnv.smoCallbacks.getLocation",
347
- objData: undefined,
348
- idSmo: this.smo.id
349
- }, "*");
350
- /* MIRAR SMO.infoCurrentLocation */
351
- };
352
- smoCallBacks.prototype.getSalidaData = function (data) {
353
- parent.postMessage({
354
- target: "Dnv.smoCallbacks.getSalidaData",
355
- objData: data,
356
- idSmo: this.smo.id
357
- }, "*");
358
- /* MIRAR SMO.setSalidaData */
359
- };
360
- smoCallBacks.prototype.ejecutaFuncion = function (data) {
361
- /*data ={
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
364
- } */
365
- parent.postMessage({
366
- target: "Dnv.smoCallbacks.ejecutaFuncion",
367
- objData: data,
368
- idSmo: this.smo.id
369
- }, "*");
370
- };
371
- smoCallBacks.prototype.addObserver = function (data) {
372
- /*data ="fruta"
373
- */
374
- parent.postMessage({
375
- target: "Dnv.smoCallbacks.addObserver",
376
- objData: data,
377
- idSmo: this.smo.id
378
- }, "*");
379
- };
380
- smoCallBacks.prototype.notify = function (data) {
381
- /*data ={
382
- destino: "fruta",
383
- value: "{'fruta':'manzana', 'color':'roja'}"
384
- } */
385
- parent.postMessage({
386
- target: "Dnv.smoCallbacks.notify",
387
- objData: data,
388
- idSmo: this.smo.id
389
- }, "*");
390
- };
391
- smoCallBacks.prototype.playOnceChannelByTrigger = function (trigger) {
392
- parent.postMessage({
393
- target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
394
- objData: { triggerCanal: trigger },
395
- idSmo: this.smo.id
396
- }, "*");
397
- };
398
- smoCallBacks.prototype.stopPlayOnceChannelByTrigger = function () {
399
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
400
- };
401
- smoCallBacks.prototype.playOnceChannel = function (codigoCanal) {
402
- parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
403
- };
404
- smoCallBacks.prototype.stopPlayChannel = function () {
405
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
406
- };
407
- smoCallBacks.prototype.editWrapperStyle = function (obj) {
408
- /*{"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} */
409
- parent.postMessage({
410
- target: "Dnv.smoCallbacks.editWrapperStyle",
411
- objData: obj,
412
- idSmo: this.smo.id
413
- }, "*");
414
- };
415
- smoCallBacks.prototype.getRecursos = function () {
416
- parent.postMessage({
417
- target: "Dnv.smoCallbacks.getRecursos",
418
- idSmo: this.smo.id
419
- }, "*");
420
- };
421
- smoCallBacks.prototype.getRecursosDefault = function () {
422
- parent.postMessage({
423
- target: "Dnv.smoCallbacks.getRecursosDefault",
424
- idSmo: this.smo.id
425
- }, "*");
426
- };
427
- smoCallBacks.prototype.getRecursosRelleno = function () {
428
- parent.postMessage({
429
- target: "Dnv.smoCallbacks.getRecursosRelleno",
430
- idSmo: this.smo.id
431
- }, "*");
432
- };
433
- smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
434
- window.parent.postMessage({
435
- target: "Dnv.smoCallbacks.setVariableStorage",
436
- objData: {
437
- variable: variable,
438
- valor: valor
439
- },
440
- idSmo: this.smo.id
441
- }, "*");
442
- };
443
- smoCallBacks.prototype.getVariableStorage = function (variable) {
444
- window.parent.postMessage({
445
- target: "Dnv.smoCallbacks.getVariableStorage",
446
- objData: {
447
- variable: variable
448
- },
449
- idSmo: this.smo.id
450
- }, "*");
451
- /* MIRAR SMO.getVariable */
452
- };
453
- smoCallBacks.prototype.printTextLine = function (txt) {
454
- window.parent.postMessage({
455
- target: "Dnv.smoCallbacks.printTextLine",
456
- objData: {
457
- txt: txt
458
- },
459
- idSmo: this.smo.id
460
- }, "*");
461
- };
462
- smoCallBacks.prototype.printBarcode = function (code, width, height) {
463
- window.parent.postMessage({
464
- target: "Dnv.smoCallbacks.printBarcode",
465
- objData: {
466
- code: code,
467
- width: width,
468
- height: height
469
- },
470
- idSmo: this.smo.id
471
- }, "*");
472
- };
473
- smoCallBacks.prototype.cutPaper = function (percent) {
474
- window.parent.postMessage({
475
- target: "Dnv.smoCallbacks.cutPaper",
476
- objData: {
477
- percent: percent
478
- },
479
- idSmo: this.smo.id
480
- }, "*");
481
- };
482
- smoCallBacks.prototype.checkHealth = function () {
483
- window.parent.postMessage({
484
- target: "Dnv.smoCallbacks.checkHealth",
485
- idSmo: this.smo.id
486
- }, "*");
487
- };
488
- smoCallBacks.prototype.checkHealthPrinter = function () {
489
- window.parent.postMessage({
490
- target: "Dnv.smoCallbacks.checkHealthPrinter",
491
- idSmo: this.smo.id
492
- }, "*");
493
- };
494
- smoCallBacks.prototype.printImage = function (image) {
495
- window.parent.postMessage({
496
- target: "Dnv.smoCallbacks.printImage",
497
- objData: {
498
- image: image
499
- },
500
- idSmo: this.smo.id
501
- }, "*");
502
- };
503
- return smoCallBacks;
504
- }());
505
- var Utils = /** @class */ (function () {
506
- function Utils(_smo, _smoCallBacks) {
507
- this.smo = _smo;
508
- this.smoCallBacks = _smoCallBacks;
509
- }
510
- // Funciones para XML to JSON
511
- Utils.prototype.xmlToJSON = function (xml) {
512
- var getxml = new DOMParser();
513
- var xmlDoc = getxml.parseFromString(xml, "text/xml");
514
- // gets the JSON string
515
- var json_str = this.jsonToStr(this.setJsonObj(xmlDoc));
516
- // sets and returns the JSON object, if "rstr" undefined (not passed), else, returns JSON string
517
- return json_str;
518
- };
519
- Utils.prototype.jsonToStr = function (js_obj) {
520
- 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, '""');
521
- return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
522
- };
523
- Utils.prototype.setJsonObj = function (xml) {
524
- var js_obj = {};
525
- if (xml.nodeType == 1) { // Element
526
- if (xml.attributes.length > 0) {
527
- js_obj["@attributes"] = {};
528
- for (var j = 0; j < xml.attributes.length; j++) {
529
- var attribute = xml.attributes.item(j);
530
- js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
531
- }
532
- }
533
- }
534
- else if (xml.nodeType == 3) { // Text
535
- js_obj = xml.nodeValue;
536
- }
537
- else if (xml.nodeType == 4) { // CDATA
538
- js_obj = xml.nodeValue;
539
- }
540
- if (xml.hasChildNodes()) {
541
- for (var i = 0; i < xml.childNodes.length; i++) {
542
- var item = xml.childNodes.item(i);
543
- var nodeName = item.nodeName;
544
- if (typeof (js_obj[nodeName]) == "undefined") {
545
- js_obj[nodeName] = this.setJsonObj(item);
546
- }
547
- else {
548
- if (typeof (js_obj[nodeName].push) == "undefined") {
549
- var old = js_obj[nodeName];
550
- js_obj[nodeName] = [];
551
- js_obj[nodeName].push(old);
552
- }
553
- js_obj[nodeName].push(this.setJsonObj(item));
554
- }
555
- }
556
- }
557
- return js_obj;
558
- };
559
- Utils.prototype.dataToJSON = function (data) {
560
- try {
561
- var parser = new DOMParser();
562
- var xmlDoc = parser.parseFromString(data.xml, "text/xml");
563
- var dataForJSON = xmlDoc.getElementsByTagName("item")[0].innerHTML;
564
- dataForJSON = dataForJSON.replace(/{'/g, '{"').replace(/'}/g, '"}').replace(/:'/g, ':"').replace(/':/g, '":').replace(/,'/g, ',"').replace(/',/g, '",').replace(/\['/g, '["').replace(/'\]/g, '"]').replace(/(\r\n|\n|\r)/gm, "");
565
- return JSON.parse(dataForJSON);
566
- }
567
- catch (error) {
568
- return {};
569
- }
570
- };
571
- return Utils;
572
- }());
573
- var SMO_EVENT_TYPE;
574
- (function (SMO_EVENT_TYPE) {
575
- SMO_EVENT_TYPE["start"] = "start";
576
- SMO_EVENT_TYPE["setDatasource"] = "setDatasource";
577
- SMO_EVENT_TYPE["getVariable"] = "getVariable";
578
- SMO_EVENT_TYPE["setCurrentStream"] = "setCurrentStream";
579
- SMO_EVENT_TYPE["infoCurrentLocation"] = "infoCurrentLocation";
580
- SMO_EVENT_TYPE["setSalidaData"] = "setSalidaData";
581
- SMO_EVENT_TYPE["updatefromsalida"] = "updatefromsalida";
582
- SMO_EVENT_TYPE["setDatasourceJson"] = "setDatasourceJson";
583
- SMO_EVENT_TYPE["getRecursos"] = "getRecursos";
584
- SMO_EVENT_TYPE["getRecursosDefault"] = "getRecursosDefault";
585
- SMO_EVENT_TYPE["getRecursosRelleno"] = "getRecursosRelleno";
586
- SMO_EVENT_TYPE["getVariableStorage"] = "getVariableStorage";
587
- SMO_EVENT_TYPE["checkHealth"] = "checkHealth";
588
- SMO_EVENT_TYPE["checkHealthPrinter"] = "checkHealthPrinter";
589
- })(SMO_EVENT_TYPE = exports.SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = {}));
590
- var LogLevel;
591
- (function (LogLevel) {
592
- LogLevel[LogLevel["Debug"] = 0] = "Debug";
593
- LogLevel[LogLevel["Info"] = 1] = "Info";
594
- LogLevel[LogLevel["Warning"] = 2] = "Warning";
595
- LogLevel[LogLevel["Error"] = 3] = "Error";
596
- })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
597
- var AlarmaLevel;
598
- (function (AlarmaLevel) {
599
- AlarmaLevel[AlarmaLevel["Ok_off"] = 0] = "Ok_off";
600
- AlarmaLevel[AlarmaLevel["Ok"] = 1] = "Ok";
601
- AlarmaLevel[AlarmaLevel["Scanning"] = 2] = "Scanning";
602
- AlarmaLevel[AlarmaLevel["Timeout"] = 3] = "Timeout";
603
- AlarmaLevel[AlarmaLevel["Warning"] = 4] = "Warning";
604
- AlarmaLevel[AlarmaLevel["Error"] = 5] = "Error";
605
- })(AlarmaLevel = exports.AlarmaLevel || (exports.AlarmaLevel = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AlarmaLevel = exports.LogLevel = exports.SMO_EVENT_TYPE = exports.SMO = void 0;
4
+ var rxjs_1 = require("rxjs");
5
+ var SMO = /** @class */ (function () {
6
+ function SMO() {
7
+ this.vars = {};
8
+ this.id = "";
9
+ this.intervalDataSource$ = (0, rxjs_1.interval)(5 * 60 * 1000);
10
+ this.initOnMessage();
11
+ this.smoCallBacks = new smoCallBacks(this);
12
+ this.utils = new Utils(this, this.smoCallBacks);
13
+ this.events = new SmoEvents(this);
14
+ this.init();
15
+ }
16
+ SMO.prototype.init = function () {
17
+ var _this = this;
18
+ var match, pl = /\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) {
19
+ return decodeURIComponent(s.replace(pl, " "));
20
+ }, query = window.location.search.substring(1);
21
+ while (match = search.exec(query)) {
22
+ this.vars[decode(match[1])] = decode(match[2]);
23
+ }
24
+ if (this.vars.idSmo) {
25
+ this.id = this.vars.idSmo;
26
+ if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
27
+ this.smoCallBacks.onSmoLoad();
28
+ return;
29
+ }
30
+ if (this.vars["url"] != undefined) {
31
+ this.smoCallBacks.getFile(this.vars["url"]);
32
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
33
+ _this.smoCallBacks.getFile(_this.vars["url"]);
34
+ });
35
+ return;
36
+ }
37
+ if (this.vars["LocalData"] != undefined) {
38
+ this.smoCallBacks.getLocalData(this.vars["LocalData"]);
39
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
40
+ _this.smoCallBacks.getLocalData(_this.vars["LocalData"]);
41
+ });
42
+ return;
43
+ }
44
+ return;
45
+ }
46
+ console.warn("No idSmo found in URL");
47
+ };
48
+ SMO.prototype.initOnMessage = function () {
49
+ var selft = this;
50
+ window.onmessage = function (e) {
51
+ if (e.data.target) {
52
+ var targets = e.data.target.split('.');
53
+ var func = targets[targets.length - 1];
54
+ if (func == SMO_EVENT_TYPE.start) {
55
+ selft.start();
56
+ return;
57
+ }
58
+ if (func == SMO_EVENT_TYPE.setDatasource) {
59
+ selft.setDatasource(e.data.objData);
60
+ return;
61
+ }
62
+ if (func == SMO_EVENT_TYPE.getVariable) {
63
+ selft.getVariable(e.data.objData);
64
+ return;
65
+ }
66
+ if (func == SMO_EVENT_TYPE.setCurrentStream) {
67
+ selft.setCurrentStream(e.data.objData);
68
+ return;
69
+ }
70
+ if (func == SMO_EVENT_TYPE.infoCurrentLocation) {
71
+ selft.infoCurrentLocation(e.data.objData);
72
+ return;
73
+ }
74
+ if (func == SMO_EVENT_TYPE.setSalidaData) {
75
+ selft.setSalidaData(e.data.objData);
76
+ return;
77
+ }
78
+ if (func == SMO_EVENT_TYPE.updatefromsalida) {
79
+ selft.updatefromsalida(e.data.objdata);
80
+ return;
81
+ }
82
+ if (func == SMO_EVENT_TYPE.getRecursos) {
83
+ selft.getRecursos(e.data.objData);
84
+ }
85
+ if (func == SMO_EVENT_TYPE.getRecursosDefault) {
86
+ selft.getRecursosDefault(e.data.objData);
87
+ }
88
+ if (func == SMO_EVENT_TYPE.getRecursosRelleno) {
89
+ selft.getRecursosRelleno(e.data.objData);
90
+ return;
91
+ }
92
+ if (func == SMO_EVENT_TYPE.getVariableStorage) {
93
+ selft.getVariableStorage(e.data.objData);
94
+ return;
95
+ }
96
+ if (func == SMO_EVENT_TYPE.checkHealth) {
97
+ selft.checkHealth(e.data.objData);
98
+ return;
99
+ }
100
+ if (func == SMO_EVENT_TYPE.checkHealthPrinter) {
101
+ selft.checkHealthPrinter(e.data.objData);
102
+ return;
103
+ }
104
+ console.warn("message not implemented!!" + func);
105
+ }
106
+ };
107
+ };
108
+ SMO.prototype.start = function () {
109
+ this.events.start.next({});
110
+ };
111
+ SMO.prototype.setDatasource = function (datasource) {
112
+ this.events.setDatasource.next(datasource);
113
+ this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
114
+ };
115
+ SMO.prototype.getVariable = function (variable) {
116
+ this.events.getVariable.next(variable);
117
+ };
118
+ SMO.prototype.setCurrentStream = function (stream) {
119
+ this.events.setCurrentStream.next(stream);
120
+ };
121
+ SMO.prototype.infoCurrentLocation = function (location) {
122
+ this.events.infoCurrentLocation.next(location);
123
+ };
124
+ SMO.prototype.setSalidaData = function (data) {
125
+ this.events.setSalidaData.next(data);
126
+ };
127
+ SMO.prototype.updatefromsalida = function (data) {
128
+ this.events.updatefromsalida.next(data);
129
+ };
130
+ SMO.prototype.getRecursos = function (data) {
131
+ this.events.getRecursos.next(data);
132
+ };
133
+ SMO.prototype.getRecursosDefault = function (data) {
134
+ this.events.getRecursosDefault.next(data);
135
+ };
136
+ SMO.prototype.getRecursosRelleno = function (data) {
137
+ this.events.getRecursosRelleno.next(data);
138
+ };
139
+ SMO.prototype.getVariableStorage = function (variable) {
140
+ this.events.getVariableStorage.next(variable);
141
+ };
142
+ SMO.prototype.checkHealth = function (json) {
143
+ this.events.checkHealth.next(json);
144
+ };
145
+ SMO.prototype.checkHealthPrinter = function (json) {
146
+ this.events.checkHealthPrinter.next(json);
147
+ };
148
+ return SMO;
149
+ }());
150
+ exports.SMO = SMO;
151
+ var SmoEvents = /** @class */ (function () {
152
+ function SmoEvents(smo) {
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.getRecursos = new rxjs_1.Subject();
162
+ this.getRecursosDefault = new rxjs_1.Subject();
163
+ this.getRecursosRelleno = new rxjs_1.Subject();
164
+ this.getVariableStorage = new rxjs_1.Subject();
165
+ this.checkHealth = new rxjs_1.Subject();
166
+ this.checkHealthPrinter = new rxjs_1.Subject();
167
+ }
168
+ return SmoEvents;
169
+ }());
170
+ var smoCallBacks = /** @class */ (function () {
171
+ function smoCallBacks(_smo) {
172
+ this.smo = _smo;
173
+ }
174
+ smoCallBacks.prototype.onSmoLoad = function () {
175
+ window.parent.postMessage({
176
+ target: "Dnv.smoCallbacks.onSmoLoad",
177
+ objData: undefined,
178
+ idSmo: this.smo.id
179
+ }, "*");
180
+ };
181
+ smoCallBacks.prototype.onSmoReady = function () {
182
+ window.parent.postMessage({
183
+ target: "Dnv.smoCallbacks.onSmoReady",
184
+ objData: undefined,
185
+ idSmo: this.smo.id
186
+ }, "*");
187
+ };
188
+ smoCallBacks.prototype.smoLog = function (msn, level) {
189
+ if (level == undefined) {
190
+ level = LogLevel.Info;
191
+ }
192
+ //level = Dnv.LogLevel.Debug...
193
+ if (level == LogLevel.Debug) {
194
+ console.debug(msn);
195
+ }
196
+ if (level == LogLevel.Info) {
197
+ console.log(msn);
198
+ }
199
+ if (level == LogLevel.Warning) {
200
+ console.warn(msn);
201
+ }
202
+ if (level == LogLevel.Error) {
203
+ console.error(msn);
204
+ }
205
+ if (window.parent != window) {
206
+ window.parent.postMessage({
207
+ target: "Dnv.smoCallbacks.smoLog",
208
+ objData: {
209
+ level: level,
210
+ txt: msn
211
+ },
212
+ idSmo: this.smo.id
213
+ }, "*");
214
+ }
215
+ };
216
+ smoCallBacks.prototype.smoAlarma = function (msn, level) {
217
+ window.parent.postMessage({
218
+ target: "Dnv.smoCallbacks.smoAlarma",
219
+ objData: {
220
+ level: level,
221
+ txt: msn
222
+ },
223
+ idSmo: this.smo.id
224
+ }, "*");
225
+ };
226
+ smoCallBacks.prototype.smoLogStash = function (msn) {
227
+ window.parent.postMessage({
228
+ target: "Dnv.smoCallbacks.smoLogStash",
229
+ objData: {
230
+ txt: msn
231
+ },
232
+ idSmo: this.smo.id
233
+ }, "*");
234
+ };
235
+ smoCallBacks.prototype.smoLogNowShowing = function (msn) {
236
+ window.parent.postMessage({
237
+ target: "Dnv.smoCallbacks.smoNowShowing",
238
+ objData: msn,
239
+ idSmo: this.smo.id
240
+ }, "*");
241
+ };
242
+ smoCallBacks.prototype.reiniciarDispositivo = function (msn) {
243
+ //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
244
+ window.parent.postMessage({
245
+ target: "Dnv.smoCallbacks.reiniciarDispositivo",
246
+ objData: {
247
+ txt: msn // Razón del reinicio
248
+ },
249
+ idSmo: this.smo.id
250
+ }, "*");
251
+ };
252
+ smoCallBacks.prototype.urlNext = function () {
253
+ //Permite avanzar plantilla. Solo si Reloj Maestro activado.
254
+ window.parent.postMessage({
255
+ target: "Dnv.smoCallbacks.urlNext",
256
+ objData: undefined,
257
+ idSmo: this.smo.id
258
+ }, "*");
259
+ };
260
+ smoCallBacks.prototype.exitInteractivity = function () {
261
+ //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
262
+ window.parent.postMessage({
263
+ target: "Dnv.smoCallbacks.exitInteractivity",
264
+ objData: undefined,
265
+ idSmo: this.smo.id
266
+ }, "*");
267
+ };
268
+ smoCallBacks.prototype.showBrowser = function () {
269
+ /* DEPRECATED NOT IMPLEMENTED */
270
+ };
271
+ smoCallBacks.prototype.closeBrowser = function () {
272
+ /* DEPRECATED NOT IMPLEMENTED */
273
+ };
274
+ smoCallBacks.prototype.urlNextDirectamente = function () {
275
+ /* NOT IMPLEMENTED */
276
+ };
277
+ smoCallBacks.prototype.setVariable = function (variable, valor) {
278
+ window.parent.postMessage({
279
+ target: "Dnv.smoCallbacks.setVariable",
280
+ objData: {
281
+ variable: variable,
282
+ valor: valor
283
+ },
284
+ idSmo: this.smo.id
285
+ }, "*");
286
+ };
287
+ smoCallBacks.prototype.getVariable = function (variable) {
288
+ window.parent.postMessage({
289
+ target: "Dnv.smoCallbacks.getVariable",
290
+ objData: {
291
+ variable: variable
292
+ },
293
+ idSmo: this.smo.id
294
+ }, "*");
295
+ /* MIRAR SMO.getVariable */
296
+ };
297
+ smoCallBacks.prototype.getFile = function (file) {
298
+ parent.postMessage({
299
+ target: "Dnv.smoCallbacks.getFile",
300
+ objData: file,
301
+ idSmo: this.smo.id
302
+ }, "*");
303
+ };
304
+ smoCallBacks.prototype.setLocalData = function (variable, valor) {
305
+ parent.postMessage({
306
+ target: "Dnv.smoCallbacks.setLocalData",
307
+ objData: {
308
+ nameData: variable,
309
+ data: valor
310
+ },
311
+ idSmo: this.smo.id
312
+ }, "*");
313
+ };
314
+ smoCallBacks.prototype.getLocalData = function (variable) {
315
+ parent.postMessage({
316
+ target: "Dnv.smoCallbacks.getLocalData",
317
+ objData: variable,
318
+ idSmo: this.smo.id
319
+ }, "*");
320
+ /* MIRAR SMO.setDatasource */
321
+ };
322
+ smoCallBacks.prototype.getCurrentStream = function () {
323
+ parent.postMessage({
324
+ target: "Dnv.smoCallbacks.getCurrentStream",
325
+ objData: undefined,
326
+ idSmo: this.smo.id
327
+ }, "*");
328
+ /* MIRAR SMO.setCurrentStream' */
329
+ };
330
+ smoCallBacks.prototype.finAviso = function (id) {
331
+ parent.postMessage({
332
+ target: "Dnv.smoCallbacks.finAviso",
333
+ objData: id,
334
+ idSmo: this.smo.id
335
+ }, "*");
336
+ };
337
+ smoCallBacks.prototype.refreshDatasource = function (codigo) {
338
+ parent.postMessage({
339
+ target: "Dnv.smoCallbacks.refreshDatasource",
340
+ objData: codigo,
341
+ idSmo: this.smo.id
342
+ }, "*");
343
+ };
344
+ smoCallBacks.prototype.getLocation = function () {
345
+ parent.postMessage({
346
+ target: "Dnv.smoCallbacks.getLocation",
347
+ objData: undefined,
348
+ idSmo: this.smo.id
349
+ }, "*");
350
+ /* MIRAR SMO.infoCurrentLocation */
351
+ };
352
+ smoCallBacks.prototype.getSalidaData = function (data) {
353
+ parent.postMessage({
354
+ target: "Dnv.smoCallbacks.getSalidaData",
355
+ objData: data,
356
+ idSmo: this.smo.id
357
+ }, "*");
358
+ /* MIRAR SMO.setSalidaData */
359
+ };
360
+ smoCallBacks.prototype.ejecutaFuncion = function (data) {
361
+ /*data ={
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
364
+ } */
365
+ parent.postMessage({
366
+ target: "Dnv.smoCallbacks.ejecutaFuncion",
367
+ objData: data,
368
+ idSmo: this.smo.id
369
+ }, "*");
370
+ };
371
+ smoCallBacks.prototype.addObserver = function (data) {
372
+ /*data ="fruta"
373
+ */
374
+ parent.postMessage({
375
+ target: "Dnv.smoCallbacks.addObserver",
376
+ objData: data,
377
+ idSmo: this.smo.id
378
+ }, "*");
379
+ };
380
+ smoCallBacks.prototype.notify = function (data) {
381
+ /*data ={
382
+ destino: "fruta",
383
+ value: "{'fruta':'manzana', 'color':'roja'}"
384
+ } */
385
+ parent.postMessage({
386
+ target: "Dnv.smoCallbacks.notify",
387
+ objData: data,
388
+ idSmo: this.smo.id
389
+ }, "*");
390
+ };
391
+ smoCallBacks.prototype.playOnceChannelByTrigger = function (trigger) {
392
+ parent.postMessage({
393
+ target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
394
+ objData: { triggerCanal: trigger },
395
+ idSmo: this.smo.id
396
+ }, "*");
397
+ };
398
+ smoCallBacks.prototype.stopPlayOnceChannelByTrigger = function () {
399
+ parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
400
+ };
401
+ smoCallBacks.prototype.playOnceChannel = function (codigoCanal) {
402
+ parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
403
+ };
404
+ smoCallBacks.prototype.stopPlayChannel = function () {
405
+ parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
406
+ };
407
+ smoCallBacks.prototype.editWrapperStyle = function (obj) {
408
+ /*{"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} */
409
+ parent.postMessage({
410
+ target: "Dnv.smoCallbacks.editWrapperStyle",
411
+ objData: obj,
412
+ idSmo: this.smo.id
413
+ }, "*");
414
+ };
415
+ smoCallBacks.prototype.getRecursos = function () {
416
+ parent.postMessage({
417
+ target: "Dnv.smoCallbacks.getRecursos",
418
+ idSmo: this.smo.id
419
+ }, "*");
420
+ };
421
+ smoCallBacks.prototype.getRecursosDefault = function () {
422
+ parent.postMessage({
423
+ target: "Dnv.smoCallbacks.getRecursosDefault",
424
+ idSmo: this.smo.id
425
+ }, "*");
426
+ };
427
+ smoCallBacks.prototype.getRecursosRelleno = function () {
428
+ parent.postMessage({
429
+ target: "Dnv.smoCallbacks.getRecursosRelleno",
430
+ idSmo: this.smo.id
431
+ }, "*");
432
+ };
433
+ smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
434
+ window.parent.postMessage({
435
+ target: "Dnv.smoCallbacks.setVariableStorage",
436
+ objData: {
437
+ variable: variable,
438
+ valor: valor
439
+ },
440
+ idSmo: this.smo.id
441
+ }, "*");
442
+ };
443
+ smoCallBacks.prototype.getVariableStorage = function (variable) {
444
+ window.parent.postMessage({
445
+ target: "Dnv.smoCallbacks.getVariableStorage",
446
+ objData: {
447
+ variable: variable
448
+ },
449
+ idSmo: this.smo.id
450
+ }, "*");
451
+ /* MIRAR SMO.getVariable */
452
+ };
453
+ smoCallBacks.prototype.printTextLine = function (txt) {
454
+ window.parent.postMessage({
455
+ target: "Dnv.smoCallbacks.printTextLine",
456
+ objData: {
457
+ txt: txt
458
+ },
459
+ idSmo: this.smo.id
460
+ }, "*");
461
+ };
462
+ smoCallBacks.prototype.printBarcode = function (code, width, height) {
463
+ window.parent.postMessage({
464
+ target: "Dnv.smoCallbacks.printBarcode",
465
+ objData: {
466
+ code: code,
467
+ width: width,
468
+ height: height
469
+ },
470
+ idSmo: this.smo.id
471
+ }, "*");
472
+ };
473
+ smoCallBacks.prototype.cutPaper = function (percent) {
474
+ window.parent.postMessage({
475
+ target: "Dnv.smoCallbacks.cutPaper",
476
+ objData: {
477
+ percent: percent
478
+ },
479
+ idSmo: this.smo.id
480
+ }, "*");
481
+ };
482
+ smoCallBacks.prototype.checkHealth = function () {
483
+ window.parent.postMessage({
484
+ target: "Dnv.smoCallbacks.checkHealth",
485
+ idSmo: this.smo.id
486
+ }, "*");
487
+ };
488
+ smoCallBacks.prototype.checkHealthPrinter = function () {
489
+ window.parent.postMessage({
490
+ target: "Dnv.smoCallbacks.checkHealthPrinter",
491
+ idSmo: this.smo.id
492
+ }, "*");
493
+ };
494
+ smoCallBacks.prototype.printImage = function (image) {
495
+ window.parent.postMessage({
496
+ target: "Dnv.smoCallbacks.printImage",
497
+ objData: {
498
+ image: image
499
+ },
500
+ idSmo: this.smo.id
501
+ }, "*");
502
+ };
503
+ return smoCallBacks;
504
+ }());
505
+ var Utils = /** @class */ (function () {
506
+ function Utils(_smo, _smoCallBacks) {
507
+ this.smo = _smo;
508
+ this.smoCallBacks = _smoCallBacks;
509
+ }
510
+ // Funciones para XML to JSON
511
+ Utils.prototype.xmlToJSON = function (xml) {
512
+ var getxml = new DOMParser();
513
+ var xmlDoc = getxml.parseFromString(xml, "text/xml");
514
+ // gets the JSON string
515
+ var json_str = this.jsonToStr(this.setJsonObj(xmlDoc));
516
+ // sets and returns the JSON object, if "rstr" undefined (not passed), else, returns JSON string
517
+ return json_str;
518
+ };
519
+ Utils.prototype.jsonToStr = function (js_obj) {
520
+ 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, '""');
521
+ return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
522
+ };
523
+ Utils.prototype.setJsonObj = function (xml) {
524
+ var js_obj = {};
525
+ if (xml.nodeType == 1) { // Element
526
+ if (xml.attributes.length > 0) {
527
+ js_obj["@attributes"] = {};
528
+ for (var j = 0; j < xml.attributes.length; j++) {
529
+ var attribute = xml.attributes.item(j);
530
+ js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
531
+ }
532
+ }
533
+ }
534
+ else if (xml.nodeType == 3) { // Text
535
+ js_obj = xml.nodeValue;
536
+ }
537
+ else if (xml.nodeType == 4) { // CDATA
538
+ js_obj = xml.nodeValue;
539
+ }
540
+ if (xml.hasChildNodes()) {
541
+ for (var i = 0; i < xml.childNodes.length; i++) {
542
+ var item = xml.childNodes.item(i);
543
+ var nodeName = item.nodeName;
544
+ if (typeof (js_obj[nodeName]) == "undefined") {
545
+ js_obj[nodeName] = this.setJsonObj(item);
546
+ }
547
+ else {
548
+ if (typeof (js_obj[nodeName].push) == "undefined") {
549
+ var old = js_obj[nodeName];
550
+ js_obj[nodeName] = [];
551
+ js_obj[nodeName].push(old);
552
+ }
553
+ js_obj[nodeName].push(this.setJsonObj(item));
554
+ }
555
+ }
556
+ }
557
+ return js_obj;
558
+ };
559
+ Utils.prototype.dataToJSON = function (data) {
560
+ try {
561
+ var parser = new DOMParser();
562
+ var xmlDoc = parser.parseFromString(data.xml, "text/xml");
563
+ var dataForJSON = xmlDoc.getElementsByTagName("item")[0].innerHTML;
564
+ dataForJSON = dataForJSON.replace(/{'/g, '{"').replace(/'}/g, '"}').replace(/:'/g, ':"').replace(/':/g, '":').replace(/,'/g, ',"').replace(/',/g, '",').replace(/\['/g, '["').replace(/'\]/g, '"]').replace(/(\r\n|\n|\r)/gm, "");
565
+ return JSON.parse(dataForJSON);
566
+ }
567
+ catch (error) {
568
+ return {};
569
+ }
570
+ };
571
+ return Utils;
572
+ }());
573
+ var SMO_EVENT_TYPE;
574
+ (function (SMO_EVENT_TYPE) {
575
+ SMO_EVENT_TYPE["start"] = "start";
576
+ SMO_EVENT_TYPE["setDatasource"] = "setDatasource";
577
+ SMO_EVENT_TYPE["getVariable"] = "getVariable";
578
+ SMO_EVENT_TYPE["setCurrentStream"] = "setCurrentStream";
579
+ SMO_EVENT_TYPE["infoCurrentLocation"] = "infoCurrentLocation";
580
+ SMO_EVENT_TYPE["setSalidaData"] = "setSalidaData";
581
+ SMO_EVENT_TYPE["updatefromsalida"] = "updatefromsalida";
582
+ SMO_EVENT_TYPE["setDatasourceJson"] = "setDatasourceJson";
583
+ SMO_EVENT_TYPE["getRecursos"] = "getRecursos";
584
+ SMO_EVENT_TYPE["getRecursosDefault"] = "getRecursosDefault";
585
+ SMO_EVENT_TYPE["getRecursosRelleno"] = "getRecursosRelleno";
586
+ SMO_EVENT_TYPE["getVariableStorage"] = "getVariableStorage";
587
+ SMO_EVENT_TYPE["checkHealth"] = "checkHealth";
588
+ SMO_EVENT_TYPE["checkHealthPrinter"] = "checkHealthPrinter";
589
+ })(SMO_EVENT_TYPE = exports.SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = {}));
590
+ var LogLevel;
591
+ (function (LogLevel) {
592
+ LogLevel[LogLevel["Debug"] = 0] = "Debug";
593
+ LogLevel[LogLevel["Info"] = 1] = "Info";
594
+ LogLevel[LogLevel["Warning"] = 2] = "Warning";
595
+ LogLevel[LogLevel["Error"] = 3] = "Error";
596
+ })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
597
+ var AlarmaLevel;
598
+ (function (AlarmaLevel) {
599
+ AlarmaLevel[AlarmaLevel["Ok_off"] = 0] = "Ok_off";
600
+ AlarmaLevel[AlarmaLevel["Ok"] = 1] = "Ok";
601
+ AlarmaLevel[AlarmaLevel["Scanning"] = 2] = "Scanning";
602
+ AlarmaLevel[AlarmaLevel["Timeout"] = 3] = "Timeout";
603
+ AlarmaLevel[AlarmaLevel["Warning"] = 4] = "Warning";
604
+ AlarmaLevel[AlarmaLevel["Error"] = 5] = "Error";
605
+ })(AlarmaLevel = exports.AlarmaLevel || (exports.AlarmaLevel = {}));