plxdcma_iconrendererprotocol 1.0.1

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.
Files changed (4) hide show
  1. package/css.css +0 -0
  2. package/init.js +32 -0
  3. package/js.js +312 -0
  4. package/package.json +6 -0
package/css.css ADDED
File without changes
package/init.js ADDED
@@ -0,0 +1,32 @@
1
+ var plxdcma_standarinit=require(`plxdcma_standarinit`)
2
+ var fs=require(`fs`)
3
+ var path=require(`path`)
4
+ var myux=require(`plxdcma_myux`)
5
+ module.exports.use=function(req){
6
+ if(req.__myAppInternals.iconrenderer == null){
7
+ myux.use(req)
8
+ req.__myAppInternals.iconrenderer=true
9
+ if(req.__myAppInternals.paths == null){
10
+ req.__myAppInternals.paths=[]
11
+ }
12
+ req.__myAppInternals.paths.push(`<script src="/myux/iconrenderer/js.js"></script>`)
13
+ req.__myAppInternals.paths.push(`<link rel="stylesheet" href="/myux/iconrenderer/css.css">`)
14
+ if(req.__myAppInternals.modals == null){
15
+ req.__myAppInternals.modals=[]
16
+ }
17
+ }
18
+ }
19
+ plxdcma_standarinit.use(function(app){
20
+ app.get(`/myux/iconrenderer/css.css`,function(req,res){
21
+ fs.readFile(path.join(__dirname,"css.css"),"utf8",function(err,html){
22
+ res.write(html)
23
+ res.end()
24
+ })
25
+ })
26
+ app.get(`/myux/iconrenderer/js.js`,function(req,res){
27
+ fs.readFile(path.join(__dirname,"js.js"),"utf8",function(err,html){
28
+ res.write(html)
29
+ res.end()
30
+ })
31
+ })
32
+ })
package/js.js ADDED
@@ -0,0 +1,312 @@
1
+
2
+
3
+ function iconsOfSection(){
4
+ var oxscolec=[]
5
+ for(var each in IconSectionsDetails){
6
+ var section=IconSectionsDetails[each].parameters.section
7
+ var ix=IconSectionsDetails[each].slides
8
+ for(var eachslide in ix){
9
+ var zx=ix[eachslide]
10
+
11
+ // var tx=document.getElementById(ix)
12
+ // if(tx == null){
13
+ // continue
14
+ // }
15
+ //var section=ix.split(`_`)[1]
16
+ var parent=zx //tx.parentNode
17
+ var tx=parent
18
+ var htmlsicons=[]
19
+ var htmlvalues=[]
20
+ var htmlcontentvalues=[]
21
+ var htmlmediaelement=[]
22
+ var originalicon=[]
23
+ for(var i = 0 ; i < parent.children.length;i++){
24
+ var ch=parent.children[i]
25
+ var b=ch.getAttribute(`breaker`)
26
+ if(b != null){
27
+ break
28
+ }
29
+ originalicon.push(ch.originalIcon)
30
+ htmlsicons.push(ch)
31
+ }
32
+ for(var each in htmlsicons){
33
+ var h=htmlsicons[each]
34
+ var z=h.querySelectorAll(`*[cxtza]`)
35
+ htmlmediaelement.push(h.tags ?? h.icon)
36
+ htmlvalues.push(z)
37
+ }
38
+ var isivi=true
39
+ for(var each in htmlvalues){
40
+ var v=htmlvalues[each]
41
+ var oxz=originalicon[each]
42
+ console.log(`oxz - oxz`)
43
+ console.log(oxz)
44
+ var ox={
45
+ section:section
46
+ }
47
+ for(var each2 in oxz){
48
+ ox[each2]=oxz[each2]
49
+ }
50
+ // if(isivi){
51
+ // isivi=false
52
+ // continue
53
+ // }
54
+ oxscolec.push(ox)
55
+ // if(htmlmediaelement[each] != null){
56
+ // for(var each2 in htmlmediaelement[each]){
57
+ // ox[each2]=htmlmediaelement[each][each2]
58
+ // }
59
+ // }
60
+ console.log(`Ox at delivery`)
61
+ console.log(ox)
62
+ for(var i = 0;i<v.length;i++){
63
+ var z=v[i]
64
+
65
+ var a=z.getAttribute("cxtza")
66
+ switch (a) {
67
+ case `titulo`:
68
+ case `subtitulo`:
69
+ case `title`:
70
+ case `descripcion`:
71
+ ox[a]=z.innerText.trim()
72
+ break;
73
+ case `img`:
74
+ case `image`:
75
+ ox.image=z.mediaid
76
+ break
77
+ case "icon":
78
+ ox.icon=z.className
79
+ break
80
+ case "icontext":
81
+ ox.icontext=z.innerText.trim()
82
+ break
83
+ }
84
+ }
85
+ htmlcontentvalues.push(ox)
86
+ }
87
+ }
88
+ }
89
+ return oxscolec;
90
+ }
91
+
92
+ function printNewIconIntoSection(section,data){
93
+ iconid=iconid+1;
94
+ var t=document.getElementById(`ivi_${section}`)
95
+
96
+ var prototype=SectionsPrototype[section]
97
+ var slideselected=SectionsSelectedSlide[section]
98
+ var tx=SectionsSlides[section][SectionsSelectedSlide[section]]
99
+ var targethtml=document.getElementById(tx.idOfHtml)
100
+ if(targethtml != null){
101
+ var n=targethtml
102
+ // if(n != null){
103
+ // var id=`icon_${iconid}`
104
+ // iconid=iconid+1;
105
+ // var phtml=prototype(data,true,section)
106
+ // SectionsRealsIcons[section].push(phtml)
107
+ // }
108
+ // var j=SectionsRealsIcons[section].join("")
109
+ // var phtml=prototype(null,true,section)
110
+ //
111
+ // n.innerHTML=`${j}<span breaker="true" style="display:none;"></span>${phtml}`
112
+ var parent=n
113
+ var before_x=[]
114
+ var after_x=[]
115
+ var bf=true
116
+ for(var i = 0 ; i < parent.children.length;i++){
117
+ var ch=parent.children[i]
118
+
119
+ var b=ch.getAttribute(`breaker`)
120
+ if(b != null){
121
+ bf=false
122
+ after_x.push(ch.outerHTML)
123
+ continue
124
+ }
125
+ if(bf){
126
+ before_x.push(ch.outerHTML)
127
+ }else{
128
+ after_x.push(ch.outerHTML)
129
+ }
130
+ }
131
+ before_x.push(prototype(data,true,section))
132
+ n.innerHTML=`${before_x.join("")}${after_x.join("")}`
133
+ console.log(`Nx Nx Nx`)
134
+ console.log(n)
135
+ console.log(`before_x`)
136
+ console.log(before_x)
137
+ }
138
+
139
+ }
140
+ function rendericon_removethisicon(){
141
+ var t=event.target
142
+ var sectiontarget=null;
143
+ if(t.parentNode != null){
144
+ for(var i = 0 ; i < t.parentNode.parentNode.children.length;i++){
145
+ var ch=t.parentNode.parentNode.children[i]
146
+ var tx=ch.getAttribute('breaker')
147
+ if(tx == null){
148
+ continue
149
+ }
150
+ console.log(`tx tx`)
151
+ console.log(tx)
152
+ var sc=ch.getAttribute("section")
153
+ sectiontarget=sc
154
+ break
155
+ }
156
+ if(sectiontarget == null){
157
+ return;
158
+ }
159
+ var section=sectiontarget
160
+ console.log(`sectiontarget ${sectiontarget}`)
161
+ for(var i = 0 ; i < t.parentNode.parentNode.children.length;i++){
162
+ if(t.parentNode.parentNode.children[i] == t.parentNode){
163
+ SectionsRealsIcons[section].splice(i,1)
164
+ break
165
+ }
166
+ }
167
+ t.parentNode.parentNode.removeChild(t.parentNode)
168
+ }
169
+ }
170
+ var iconlistivlist=[]
171
+ function displayIconListTab(section,tab){
172
+ console.log(`displayIconListTab ${section} tab ${tab}`)
173
+ var ax=IconSectionsDetails[section]
174
+ for(var each in ax.slides){
175
+ var xls=ax.slides[each]
176
+ xls.style.display='none'
177
+ }
178
+ ax.slides[tab].style=ax.parameters.typeofdisplay
179
+ }
180
+ var IconSectionsDetails={}
181
+ var ALLRENDEREDICONS=[]
182
+ function newSlideOficons(id){
183
+ var interfacingdata={}
184
+ var sd=IconSectionsDetails[id]
185
+ var sectionid=sd.section
186
+ var parameters=sd.parameters
187
+ var building=sd.building
188
+ var ch=building.containerHtml(sd)
189
+ var newslide=ch
190
+ var id=sd.slides.length
191
+ sd.slides.push(ch)
192
+ sd.html.appendChild(ch)
193
+ if(parameters.canAddNewIcon){
194
+ var h=building.adderIconOnSection(sectionid,sd)
195
+
196
+ if(typeof(h) == "string"){
197
+ var div=document.createElement(`div`)
198
+ div.innerHTML=h
199
+ h=div.children[0]
200
+ }
201
+ if(typeof(h) == "string"){
202
+ var div=document.createElement(`div`)
203
+ div.innerHTML=h
204
+ h=div.children[0]
205
+ }
206
+ h.setAttribute("breaker","true")
207
+ h.onclick=function(){
208
+ //this.iconhtml.parentNode.removeChild(this.iconhtml)
209
+ building.addNewItem(sd.section,function(proceedToAddIcon,newicondata){
210
+ if(proceedToAddIcon){
211
+ var h=building.htmlForIcon(newicondata,sd)
212
+ if(typeof(h) == "string"){
213
+ var dx=document.createElement(`div`)
214
+ dx.innerHTML=h
215
+ h=dx.children[0]
216
+ }
217
+ this.sectionHtml.appendChild(h)
218
+ }
219
+ this.sectionHtml.appendChild(this.iconhtml)
220
+ }.bind(this))
221
+ }.bind({section:sd.section,sectionHtml:ch,iconhtml:h,building:building,interfacingdata:interfacingdata})
222
+ newslide.appendChild(h)
223
+ }
224
+ return id
225
+ }
226
+ function renderIcons(id,fulllist,parameters,building,targetHtml){
227
+ var section=id
228
+ IconSectionsDetails[id]={
229
+ html:targetHtml,
230
+ parameters:parameters,
231
+ slides:[],
232
+ building:building
233
+ }
234
+ var interfacingdata={
235
+ parameters:parameters,
236
+ section:section
237
+ }
238
+ var slides=[]
239
+
240
+ var n=building.numberOfIconSections(fulllist,interfacingdata)
241
+ for(var i = 0 ; i < n;i++){
242
+ slides.push(building.containerHtml(interfacingdata))
243
+ }
244
+ for(var each in fulllist){
245
+ var icon=fulllist[each]
246
+ var h=building.htmlForIcon(icon,interfacingdata)
247
+ if(h == null){
248
+ continue
249
+ }
250
+ if(typeof(h) == "string"){
251
+ var dx=document.createElement(`div`)
252
+ dx.innerHTML=h
253
+ h=dx.children[0]
254
+ }
255
+ var s=building.slideForIcon(icon,interfacingdata)
256
+ h.originalIcon=icon
257
+ ALLRENDEREDICONS.push(h)
258
+ slides[s].appendChild(h)
259
+ }
260
+ IconSectionsDetails[section].slides=slides
261
+ if(parameters.canAddNewIcon){
262
+ for(var i = 0 ; i < slides.length;i++){
263
+ var sx=slides[i]
264
+ var h=building.adderIconOnSection(i,interfacingdata)
265
+ if(typeof(h) == "string"){
266
+ var div=document.createElement(`div`)
267
+ div.innerHTML=h
268
+ h=div.children[0]
269
+ }
270
+
271
+ h.setAttribute("breaker","true")
272
+ h.onclick=function(){
273
+ this.iconhtml.parentNode.removeChild(this.iconhtml)
274
+ this.building.addNewItem(this.section,function(proceedToAddIcon,newicondata){
275
+ if(proceedToAddIcon){
276
+ var h=building.htmlForIcon(newicondata,interfacingdata)
277
+ if(typeof(h) == "string"){
278
+ var dx=document.createElement(`div`)
279
+ dx.innerHTML=h
280
+ h=dx.children[0]
281
+ }
282
+ console.log(`this.sectionHtml`)
283
+ console.log(this.sectionHtml)
284
+ this.slideHtml.appendChild(h)
285
+ }
286
+
287
+ this.slideHtml.appendChild(this.iconhtml)
288
+ }.bind(this))
289
+ }.bind({fulllist:fulllist,section:section,slide:i,slideHtml:sx,iconhtml:h,building:building,interfacingdata:interfacingdata})
290
+ sx.appendChild(h)
291
+ }
292
+ }
293
+ for(var i = 0 ; i < slides.length;i++){
294
+ building.prepareSectionFordisplay(i,slides[i],interfacingdata)
295
+ }
296
+ for(var each in slides){
297
+ var sx=slides[each]
298
+ targetHtml.appendChild(sx)
299
+ }
300
+ }
301
+ function removeThisIcon(htmlid){
302
+ event.stopPropagation()
303
+ if (!confirm("¿Estás seguro de que deseas eliminar este jugador?")) {
304
+ return
305
+ }
306
+
307
+ var iconhtml=document.getElementById(htmlid)
308
+
309
+ if(iconhtml.parentNode != null){
310
+ iconhtml.parentNode.removeChild(iconhtml)
311
+ }
312
+ }
package/package.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "plxdcma_iconrendererprotocol",
3
+ "version": "1.0.1",
4
+ "main": "init.js",
5
+ "license": "MIT"
6
+ }