-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
138 lines (105 loc) · 4.79 KB
/
app.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
let tabsCode = [];
let idElement = 0;
let idDiv = 0;
var codePreview = { "tabs": tabsCode };
/* Get for ID Element*/
function getIDElement() {
return idElement;
}
/*Set for ID Element */
function setIDElement() {
idElement = idElement + 1;
}
/* Get for IDdiv Element*/
function getIDdiv() {
return idDiv;
}
/*Set for IDdiv Element */
function setIDdiv() {
idDiv = idDiv + 1;
}
/*Generate ID for the document tree based on the user_id, deleting accents and blank spaces.
For example:
id_user = NOMBRE TÉCNICO
sys_id = NOMBRETECNICO
*/
function generateID(id_user, typeElement) {
if (id_user.length >= 15) {
id_user = id_user.slice(0, 10);
}
let id_sys;
id_sys = id_user.normalize('NFD').replace(/[\u0300-\u036f]/g, "");
id_sys = id_sys.replace(/\./g, "");
id_sys = id_sys.replace(/\,/g, "");
id_sys = id_sys.replace(/\;/g, "");
id_sys = id_sys.replace(/\(/g, "");
id_sys = id_sys.replace(/\)/g, "");
id_sys = id_sys.replace(/\d/g, "");
id_sys = id_sys.replace(/\:/g, "");
id_sys = (id_sys.replace(/\s/g, "") + getIDElement() + typeElement).toLowerCase();
setIDElement();
return id_sys;
}
/* Launch Sucess Modal */
function launchModal(msg) {
$("#opSuccess").remove();
$("body").append("<div class='fade modal modal-success'aria-hidden=true aria-labelledby=myModalLabel1 id=opSuccess role=dialog style=display:block tabindex=-1><div class=modal-dialog><div class=modal-content><div class=modal-header><h4 class=modal-title id=myModalLabel13>Operacion Exitosa </h4></div><div class=modal-body><img src='src/images/tick_mark-128.png' style=margin-left:auto;margin-right:auto;display:block width=150px><h4 style=text-align:center>" + msg + "</h4><h5 style=text-align:center>Buen trabajo, Sigue agregando más componentes !<br>Haz que tu plantilla sea la mejor experiencia para todos los usuarios .</h5></div><div class=modal-footer><input class='btn btn-sucess'data-dismiss=modal type=button value=Continuar></div></div></div></div>");
$("#opSuccess").modal('show');
}
/* Launch Error Modal */
function launchErrorModal(msg) {
$("#opError").remove();
$("body").append("<div class='fade modal modal-danger'aria-hidden=true aria-labelledby=myModalLabel2 id=opError role=dialog style=display:block tabindex=-1><div class=modal-dialog><div class=modal-content><div class=modal-header><h4 class=modal-title id=myModalLabel13>Upps, ha ocurrido un error </h4></div><div class=modal-body><img src='src/images/error-128.png' style=margin-left:auto;margin-right:auto;display:block width=150px><h4 style=text-align:center> Codigo No valido ! </h4><h5 style=text-align:center>"+msg+"</h5></div><div class=modal-footer><input class='btn btn-sucess'data-dismiss=modal type=button value=Revisar Codigo></div></div></div></div>");
$("#opError").modal('show');
}
function getCodePreview() {
return codePreview;
}
function checkTree() {
if (codePreview.tabs[0] != undefined) {
if (codePreview.tabs[0].panel[0].subpanel.length > 0) {
return true;
}
return false;
}
else {
return false;
}
}
function downloadJSON(fileName_user) {
var saveData = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (data, fileName) {
var json = JSON.stringify(data),
blob = new Blob([json], { type: "octet/stream" }),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
var data = codePreview,
fileName = fileName_user+".json";
saveData(data, fileName);
}
function launchJSONmodal() {
$("#JSONdownload").remove();
$("body").append("<div class='fade modal'aria-hidden=true aria-labelledby=myModalLabel1 id=JSONdownload role=dialog style=display:block tabindex=-1><div class=modal-dialog><div class=modal-content><div class=modal-header><h4 class=modal-title id=myModalLabel13>Descarga Codigo Generado </h4></div><div class=modal-body><label>Nombre Plantilla </label><input type ='text' id='file_name'class='form-control'/></div><div class=modal-footer><input id='JSONdownload_action' class='btn btn-sucess' type=button disabled=true value=Descargar></div></div></div></div>");
$("#file_name").on("input",function(){
let file_name = $("#file_name").val();
if(file_name.length > 0){
$("#JSONdownload_action").attr("disabled",false);
}
else{
$("#JSONdownload_action").attr("disabled",true);
}
});
$("#JSONdownload_action").click(function (){
let file_name = $("#file_name").val();
downloadJSON(file_name);
});
$("#JSONdownload").modal('show');
}