-
Notifications
You must be signed in to change notification settings - Fork 0
/
vanilla.js
2653 lines (2099 loc) · 61.4 KB
/
vanilla.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
VanillaJS v1.0
Released into the Public Domain
<input type='text' class='subInputChat' spellcheck='false' autocomplete='new-password' onfocusout="mod_session.outUserNameInput();" placeholder=' . . .' value='' />
.split() .join()
replace(/reemplazar todos los lugares en que este esto/g, 'por esto');
.replaceAll('.','');
{a,b} -> {a: a, b: b}
location.reload();
location.href = "https://www.w3schools.com";
obtener contenido .value
incitar focus .focus() fuera focus .blur()
.attr = ''
.includes('php') detectar string en string
async function load_foro_sietechakras() {
const foro_sietechakras = await import('https://www.somosindia.cl/sv/gestor/foro_sietechakras.js');
}
load_foro_sietechakras();
JSON.parse() JSON.stringify()
str.trim() limpiar string
this.className.split('_')
s().onevent = ()=>{}; sobree escritura de evento
parseFloat(Math.round( num * 100) / 100).toFixed(2);
s('html').scrollTop = s('html').scrollHeight;
s('html').scrollTop = s(('.preg-id-'+id_last_false)).offsetTop;
s('.'+name+'-input-focus').onmouseout
typeof -> que tipo de var es o si existe
s('body').onkeydown = () => {
switch (window.event.keyCode) {
case 13:
logIn();
break;
default:
}
};
.splice(i, 1);
console.log(arr.join()); // Jani,Hege,Stale,Kai Jim,Borge
arr.splice(2, 0, "Lene");
console.log(arr.join()); // Jani,Hege,Lene,Stale,Kai Jim,Borge
.push();
async function loop(time) { await timer(time); }
<input type='checkbox' class='factura' />
type="number"
.checked
<textarea placeholder=' Ingrese Una Nota'></textarea>
▲▼►◄△▽▷◁
<select name='select'>
<option value='' selected disabled style='display: none;'>
LISTA
</option>
<option value='OP 1'>OP 1</option>
<option value='OP 1'>OP 2</option>
</select>
https://google-map-generator.com/
let lang = req.body.lang=='es' ? 1 : 0;
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard
navigator.clipboard.writeText(newClip).then(function() {
clipboard successfully set
}, function() {
clipboard write failed
});
navigator.clipboard.readText().then(
clipText => console.log(clipText) );
printer impresora
window.print();
var w = window.innerWidth;
var h = window.innerHeight;
<input type="datetime-local" class='dateTime'
value=" new Date(time_email).toISOString().split(".")[0] "
>
<input type="time" class='dateTime1'>
<input type="date" class='dateTime2'>
s('.dateTime').onchange = (event)=>{
console.log(event);
console.log(s('.dateTime').value);
console.log(new Date(s('.dateTime').value));
console.log(new Date(s('.dateTime').value).getTime());
};
// Contenido del <strong> dentro de .titulo dentro de #contenedor
document.querySelector('#contenedor .titulo strong').textContent
// Todos los <span> y <img> de una página
document.querySelectorAll('span, img')
*/
function s(div){
return document.querySelector(div);
}
function sa(div){
return document.querySelectorAll(div);
/* document.querySelectorAll(".btn-group")[3].style.display = 'none'; */
}
function intxt(div, content){
return div.innerText = content;
/* intxt(sa('.test-1')[0], 'test'); */
}
function outs(div, content){
return div.outerHTML = content;
/* content includes tag -> outs(sa('div')[1], 'asdasd'); */
}
function siframe(iframe, div){
return s(iframe).contentWindow.document.querySelector(div);
}
function append(div, html){
s(div).insertAdjacentHTML('beforeend', html);
}
function prepend(div, html){
s(div).insertAdjacentHTML('afterbegin', html);
}
function htmls(div, html){
s(div).innerHTML = html;
}
function htmlsa(i_, div, html){
sa(div)[i_].innerHTML = html;
}
function getHtml(div){
return s(div).innerHTML.trim();
}
function sremove(div){
s(div).parentNode.removeChild(s(div));
}
function renderMedia(obj){
/*
video/mp4
audio/mpeg
*/
let type = '';
if(obj.tag=='audio'){
type = 'audio/mpeg';
}
if(obj.tag=='video'){
type = 'video/mp4';
}
/*--------------------*/
/*--------------------*/
let poster = '';
if(obj.src_poster!=''){
poster = `poster='`+obj.src_poster+`'`;
}
/*--------------------*/
/*--------------------*/
let source = '';
if(obj.source){
source = `
<source src='`+obj.src+`' type='`+type+`'>
`;
}
/*--------------------*/
/*--------------------*/
let download = '';
if(!obj.download){
download=`controlsList='nodownload'`;
}
/*--------------------*/
/*--------------------*/
let render = `
<`+obj.tag+`
`+obj.controls+` `+obj.autoplay+` `+obj.muted+` `+obj.loop+` class='`+obj.class+`' style='`+obj.style+`'
`+download+`
`+poster+`
>
`+source+`
</`+obj.tag+`>
`;
return render;
/*
append('body', renderMedia({
tag: 'video',
source: true,
controls: 'controls',
download: true,
autoplay: '',
muted: '',
loop: '',
class: 'in',
src_poster: 'https://www.nexodev.org/assets/social.jpg',
src: 'http://techslides.com/demos/sample-videos/small.mp4',
style: `
width: 400px;
height: 300px;
margin: auto;
`
}));
*/
};
function renderYouTube(obj){
let id = YoutubeUrl(obj.url).split('/');
let ind = l(id)-1;
id = id[ind];
let render = `
<iframe style='`+obj.style+`' width='`+obj.w+`' height='`+obj.h+`' class='`+obj.class+`'
src='https://www.youtube.com/embed/`+id+`?autoplay=`+obj.autoplay+`'
frameborder='0'
allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen>
</iframe>
`;
return render;
/*
append('body', renderYouTube({
url: 'https://www.youtube.com/watch?v=jgHfPgcFsOM&list=RD_NGdzZfJi-4&index=4',
autoplay: '0',
w: '300px',
h: '200px',
class: 'in',
style: 'margin: auto;'
}));
*/
}
function fadeOut(el){
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
};
function fadeIn(el, display){
el.style.opacity = 0;
el.style.display = display || "block";
(function fade() {
let val = parseFloat(el.style.opacity);
if (!((val += .1) > 1)) {
el.style.opacity = val;
requestAnimationFrame(fade);
}
})();
};
function fadeGlobal(fadein, div, time, from_dis, to_dis){
const fadeGoblalMsgError = " warn -> fadeGlobal not div";
const total_iter = 100;
let time_interval = time/total_iter;
let total_time = total_iter*time_interval;
let time_cont = 0;
for(let i=1;i<=total_iter;i++){
setTimeout(()=>{
let por;
if(fadein){por = (i/total_iter);}
else{por = 1 - (i/total_iter);}
s(div) ? s(div).style.opacity = (''+por):
console.warn(fadeGoblalMsgError);
if(i==1){s(div) ? s(div).style.display = from_dis:
console.warn(fadeGoblalMsgError);}
if(i==total_iter){s(div) ? s(div).style.display = to_dis:
console.warn(fadeGoblalMsgError);}
},time_cont);
time_cont = time_cont + time_interval;
}
};
function sliderV1(sli_l, name, time, arrow_izq, arrow_der, tim_x, tim_y, animate_loop){
let stop_ = false;
let sli = 0;
let change_ = true;
let intervalReturn;
function nextV1(t_a, t_b, sum){
if(!stop_){
change_ = false;
setTimeout(()=>{
change_ = true;
}, Math.max.apply(null, tim_x));
}
fadeGlobal(false, (name+sli), t_a, 'block', 'none');
if(sum){sli++;}else{sli--;}
if(sli>sli_l){
sli = 0;
}
if(sli<0){
sli = sli_l;
}
fadeGlobal(true, (name+sli), t_b, 'block', 'block');
}
if(animate_loop){
intervalReturn = setInterval(function(){
if(!stop_){
nextV1(tim_x[0], tim_x[1], true);
}
}, time);
}
s(arrow_der).onclick = () => {
if(change_){
nextV1(tim_y[0], tim_y[1], true);
}
stop_ = true;
};
s(arrow_izq).onclick = () => {
if(change_){
nextV1(tim_y[0], tim_y[1], false);
}
stop_ = true;
};
/* sliderV1(5, '.testi-', 4000, '.s8-izq', '.s8-der', [1000, 2000], [500, 500]); */
return intervalReturn;
}
var mod_scroll = {
scrollPos: 0,
init: (div, log, fn)=>{
window.onscroll = ()=>{
let aux_scroll = -1*div.getBoundingClientRect().top;
if(log){
if (aux_scroll > this.scrollPos){
console.log(('scroll ↓ '+(aux_scroll)+' + innerHeight: '+window.innerHeight));
}else{
console.log(('scroll ↑ '+(aux_scroll)+' + innerHeight: '+window.innerHeight));
}
}
this.scrollPos = aux_scroll;
fn(this.scrollPos);
};
}
/*
setTimeout(()=>{
let display_ball = false;
mod_scroll.init(s('body'), false, scroll => {
// console.log(s('.content-main-ball-content').offsetTop*0.95);
if(scroll>s('.content-main-ball-content').offsetTop*0.95 && !display_ball){
setTimeout(()=>{
console.warn('display scroll -> display_ball');
display_ball = true;
// fadeGlobal(true, '.main-ball-content', 200, 'block', 'block');
s('.main-ball-content').style.opacity = '1';
animateStaticsBall();
}, 400);
}
});
}, 2000);
require TweenMax Lib ->
Counter:
function count(nameClass, limit){
let counter = { var: 0 };
TweenMax.to(counter, 5, {
var: limit,
onUpdate: function () {
let number = Math.ceil(counter.var);
htmls(nameClass, number);
// if(number === counter.var){ count.kill(); }
},
onComplete: function(){
setTimeout(()=>{
count(nameClass, limit);
}, 3000);
},
ease:Circ.easeOut
});
};
*/
};
function toUpBtn(btn_, limit_){
setTimeout(()=>{
if(-1*s('html').getBoundingClientRect().top>limit_ && s(btn_).style.display == 'none'){
s(btn_).style.display = 'block';
}
}, 0);
return scroll => {
if(scroll>limit_ && s(btn_).style.display == 'none'){
fadeIn(s(btn_));
}else if(scroll <= limit_ && s(btn_).style.display == 'block' ){
fadeOut(s(btn_));
}
}
};
let mod_key = {
keyState: [],
init: function(){
window.addEventListener('keydown',function(e){
mod_key.keyState[e.keyCode] = true;
},true);
window.addEventListener('keyup',function(e){
mod_key.keyState[e.keyCode] = false;
},true);
}
/*
https://keycode.info/
mod_key.init();
setInterval(()=>{
if(mod_key.keyState[38]){
console.log('test');
}
},50);
*/
};
function setScrollTouchX(el){
const slider = s(el);
let isDown = false;
let startX;
let scrollLeft;
slider.onmousedown = function (e) {
isDown = true;
slider.classList.add("active");
startX = e.pageX - slider.offsetLeft;
scrollLeft = slider.scrollLeft;
};
slider.onmouseleave = function (e) {
isDown = false;
slider.classList.remove("active");
};
slider.onmouseup = function (e) {
isDown = false;
slider.classList.remove("active");
};
slider.onmousemove = function (e) {
if (!isDown) return;
// e.preventDefault();
const x = e.pageX - slider.offsetLeft;
const walk = x - startX;
slider.scrollLeft = scrollLeft - walk;
};
}
function lang(){
return navigator.language.split('-')[0];
}
function typeWriter(obj){
const child = obj.child;
const id_stop_save = obj.id;
const arrayCharacter = obj.arrayCharacter;
let interval_init_time = parseInt(obj.interval_init_time+'');
const interval_character = obj.interval_character;
htmls(child, '');
for(let character of arrayCharacter){
setTimeout(()=>{
if(id_stop_save==obj.id){
append(child, character);
}
}, interval_init_time);
interval_init_time = interval_init_time + interval_character;
}
}
function fullScreenIn(){
let el = document.documentElement;
let rfs =
el.requestFullScreen
|| el.webkitRequestFullScreen
|| el.mozRequestFullScreen
|| el.msRequestFullScreen
;
if(typeof rfs!="undefined" && rfs){
rfs.call(el);
} else if(typeof window.ActiveXObject!="undefined"){
let wscript = new ActiveXObject("WScript.Shell");
if (wscript!=null) {
wscript.SendKeys("{F11}");
}
}
}
function fullScreenOut(){
document.exitFullscreen();
}
async function ajax(type, url, obj, end){
let xhr = new XMLHttpRequest();
xhr.open(type, url, true);
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.send(JSON.stringify(obj));
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
end(JSON.parse(this.responseText));
}
};
}
/*ajax('POST', '/check_input', {
name: name,
value: val
}, function(res){
//console.log('ajax response');
//console.log(res);
if(res.adv!=''){
htmls(('.error-input-txt-'+name), res.adv[it]);
fadeIn(s('.error-input-'+name), 'block');
}
});*/
async function postData(url = '', data = {}, obj) {
obj == undefined ? obj = { type:'POST' } : null;
const response = await fetch(url, {
method: obj.type,
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json'
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
body: data==null? undefined: JSON.stringify(data)
});
return response.json();
}
/*
postData('/global-consistency', data)
.then(resp => {
console.log(' success /global-consistency ->');
console.log(resp);
}).catch( error => {
console.log(' error /global-consistency ->');
console.log(error);
});
*/
function notclick(div, id, state){
if(id==0){
s(div).oncontextmenu = function(){ return state; }
}
if(id==1){
s(div).ondragstart = function(){ return state; }
}
if(id==2){
s(div).onselectstart = function(){ return state; }
}
}
function allNotClick(div){
let el = div;
if(el == null){el = 'body'}
notclick(el, 0, false);
notclick(el, 1, false);
notclick(el, 2, false);
}
async function sha256(message) {
/* cors restriction
encode as UTF-8 */
const msgBuffer = new TextEncoder().encode(message);
/* hash the message */
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
/* convert ArrayBuffer to Array */
const hashArray = Array.from(new Uint8Array(hashBuffer));
/* convert bytes to hex string */
const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
return hashHex;
/* let result = await sha256('test'); */
}
function displayContentSlice(id_content, ref, transition){
s(id_content).style.transition = transition;
s(id_content).style.opacity = "0";
s(id_content).style.height = "auto";
const h_ = s(ref).clientHeight +"px";
s(id_content).style.height = "0px";
setTimeout(()=>{
s(id_content).style.opacity = "1";
s(id_content).style.height = h_;
}, 10);
}
function dragDrop(div){
let object = s(div),
initX, initY, firstX, firstY;
object.addEventListener('mousedown', function(e) {
// e.preventDefault();
initX = this.offsetLeft;
initY = this.offsetTop;
firstX = e.pageX;
firstY = e.pageY;
this.addEventListener('mousemove', dragIt, false);
window.addEventListener('mouseup', function() {
object.removeEventListener('mousemove', dragIt, false);
}, false);
}, false);
object.addEventListener('touchstart', function(e) {
// e.preventDefault();
initX = this.offsetLeft;
initY = this.offsetTop;
let touch = e.touches;
firstX = touch[0].pageX;
firstY = touch[0].pageY;
this.addEventListener('touchmove', swipeIt, false);
window.addEventListener('touchend', function(e) {
// e.preventDefault();
object.removeEventListener('touchmove', swipeIt, false);
}, false);
}, false);
function dragIt(e) {
this.style.left = initX+e.pageX-firstX + 'px';
this.style.top = initY+e.pageY-firstY + 'px';
}
function swipeIt(e) {
let contact = e.touches;
this.style.left = initX+contact[0].pageX-firstX + 'px';
this.style.top = initY+contact[0].pageY-firstY + 'px';
}
}
var downloader = {
BLOB: (nameFile, blob) => {
let idDownload = makeid(4);
append('body', `<a class='`+idDownload+`' style='display: none'></a>`);
s('.'+idDownload).href = window.URL.createObjectURL(blob);
s('.'+idDownload).download = nameFile;
s('.'+idDownload).click();
s('.'+idDownload).remove();
},
JSON: (exportObj, exportName) => {
let dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
let downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", exportName + ".json");
document.body.appendChild(downloadAnchorNode); // required for firefox
downloadAnchorNode.click();
downloadAnchorNode.remove();
}
}
function renderInput(obj){
/*
<div contenteditable="true">This is the first line.<br>
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
// prevent enter key in form div reload
s(mainCardLoginContent).onsubmit =
() => false;
*/
let value = (isOpenFalse(obj.value)?'':`value="`+obj.value+`"`);
let idR = makeid(4);
let render = `
<style>
.`+obj.id_content_input+` .`+obj.tag_label+` {
position: absolute;
top: `+obj.initLabelPos+`px;
left: `+obj.initLabelPos+`px;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.`+obj.id_content_input+` input:valid + .`+obj.tag_label+`, .`+obj.id_content_input+` input:focus + .`+obj.tag_label+` {
-webkit-transform: translate3d(0, `+obj.endLabelPos+`px, 0);
transform: translate3d(0, `+obj.endLabelPos+`px, 0);
}
.`+obj.id_input+`::placeholder {
`+obj.style_placeholder+`
}
</style>
`+(isOpenFalse(obj.topContent)?'':obj.topContent)+`
<div class="`+obj.underpostClass+` `+obj.id_content_input+`"
style="`+obj.style_content_input+`">
<`+(obj.textarea?'textarea':'input')+` `+(obj.disabled?'disabled':'')+`
`+((!isOpenFalse(obj.placeholder))?`placeholder="`+obj.placeholder+`"`:'')+`
`+value+`
type="`+obj.type+`" class="`+obj.underpostClass+` w-fill
`+(obj.style_outline?`in-outline`:'')+` `+obj.id_input+`" id='`+idR+`'
`+(obj.required?'required':'')+` `+(obj.type=='password'?` autocomplete="new-password"`:'')+`
`+(obj.username?` autocomplete="username"`:'')+`
style="`+obj.style_input+`">`+(obj.textarea?(
isOpenFalse(value)?'':value.split('value="')[1].slice(0, -1)
)+'</textarea>':((obj.active_label&&!obj.disabled)?`<label class='`+obj.tag_label+`' for='`+idR+`' style="`+obj.style_label+`" >
`+obj.text_label+`
</label>`:''))+`
</div>
`+(isOpenFalse(obj.botContent)?'':obj.botContent)+`
`;
// espacions uperios br content
setTimeout(() => {
s('.'+obj.id_content_input).onclick = async () => {
s('.'+obj.id_input).focus();
await obj.fnOnClick();
};
}, 0);
/*
let style_content_input = `
border: 2px solid red;
padding: 5px;
width: 250px;
margin: auto;
`;
let style_input = `
background: green;
font-size: 20px;
height: 40px;
padding: 5px;
`;
let style_label = `
color: red;
font-size: 20px;
`;
let style_placeholder = `
color: orange;
`;
let top_content = spr('<br>', 1);
let bot_content = ``;
let dataInputs = [
{
underpostClass: 'in',
id_content_input: 'a1',
id_input: 'a2',
type: 'text',
required: true,
style_content_input: style_content_input,
style_input: style_input,
style_label: style_label,
style_outline: true,
style_placeholder: style_placeholder,
textarea: false,
active_label: true,
initLabelPos: 15,
endLabelPos: -30,
text_label: 'Ingrese Email',
tag_label: 'a3',
fnOnClick: async () => {
console.log('click input');
},
value: ``,
topContent: top_content,
botContent: bot_content,
placeholder: ''
}
];
for(let di of dataInputs){
append('body', renderInput(di));
}
*/
return render;
}
async function renderSchedule(obj){
let data_ = {
availability: () => {
let availability = [];
for(let rn of range(1, 7)){
let from_ = (+ new Date())+([-1,1][random(0,1)]*60*60*1000*random(0, 9999));
let to_ = from_ + (60*60*1000*random(1, 3));
availability.push({
from: new Date(from_),
to: new Date(to_),
period: false
});
};
availability = availability.concat(data_.period());
// console.log(" availability: () => ");
// console.log(availability);
return orderArrayFromAttrInt(availability, "from", true);
},
period: obj_ => {
let dataPeriod = obj_ != undefined ? obj_.data.periods :
[
{
tipo: 'Presencial',
from: '16:00',
to: '20:00',
day: 7
},
{
tipo: 'Presencial',
from: '12:00',
to: '13:00',
day: 5
}
];
let dataRender = [];
for(let d_ of dataPeriod){
let from_h = parseInt(d_.from.split(':')[0]);
let from_m = parseInt(d_.from.split(':')[1]);
let to_h = parseInt(d_.to.split(':')[0]);
let to_m = parseInt(d_.to.split(':')[1]);
let month_ = new Date().getMonth();