service.js
2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
angular.module('focaBotoneraLateral')
.service('focaBotoneraLateralService', ['$localStorage',
function($localStorage) {
this.botones = {
teclado: true,
salir: false,
cancelar: false,
pausar: false,
guardar: false,
guardando: false,
funcionGuardar: undefined,
pathCancelar: undefined,
custom: []
};
this.pausarData = {
label: '',
val: ''
};
this.rutasPausadas = {
label: 'rutas',
val: []
};
this.showTeclado = function(value) {
this.botones.teclado = value;
};
this.showSalir = function(value) {
this.botones.custom = [];
this.botones.salir = value;
};
this.showPausar = function(value) {
this.botones.custom = [];
this.botones.pausar = value;
};
this.setPausarData = function(obj) {
this.pausarData = obj;
};
this.setRutasPausadas = function(obj) {
var auxArray = [];
this.rutasPausadas.val.push(obj.val);
angular.forEach(this.rutasPausadas.val, function(ruta) {
var exists = false;
angular.forEach(auxArray, function(val2) {
if(angular.equals(ruta, val2)){ exists = true };
});
if(exists == false && ruta !== "") { auxArray.push(ruta); }
});
this.rutasPausadas.val = auxArray;
};
this.showCancelar = function(value, path) {
this.botones.custom = [];
this.botones.cancelar = value;
this.botones.pathCancelar = (path) ? path : undefined;
};
this.showGuardar = function(value, funcion) {
angular.element('#guardar').removeClass('guardado');
this.botones.custom = [];
this.botones.guardar = value;
if (value) this.botones.funcionGuardar = funcion;
};
this.addCustomButton = function(title, funcion) {
this.botones.custom.push({
title: title,
funcion: funcion
});
};
this.startGuardar = function() {
this.botones.guardando = true;
};
this.endGuardar = function(guardado) {
this.botones.guardando = false;
if (guardado) angular.element('#guardar').addClass('guardado');
};
this.setLSItem = function() {
$localStorage[this.pausarData.label] = JSON.stringify(this.pausarData.val);
};
this.setLSRuta = function() {
$localStorage[this.rutasPausadas.label] = JSON.stringify(this.rutasPausadas.val);
};
}]);