PageSourceSearch

https://www.ville-cesson.fr/typo3temp/assets/compressed/form-c1d5b5535faf523e0e5cd0b008b6596e.js?1790372077

js ville-cesson.fr collected 2026-10-02 12:10:56 UTC 40,198 bytes, 1,086 lines download raw bytes

1function ajaxFileUpload(argPrefix, argPath, argElmentFileId, argElmentFileContentId, argElmentContentId, argMaxFile, argFormatAccept, argWeightMax)
2{
3    var _flag = false;
4
5    if(jQuery("#" + argElmentFileId).attr("value") != undefined)
6    {
7        _countFile = document.getElementById(argElmentContentId).childNodes.length;
8        //alert(jQuery(argElmentContentId).childNodes.length);
9        
10        if(_countFile == argMaxFile) 
11        {
12            alert('Vous ne pouvez plus ajouter de photos, la limite est de ' + argMaxFile + ' photos');
13        }
14        else
15        {
16            jQuery("#divMsgLoading").show();
17            jQuery("#btnSubmited").attr("disabled", "disabled");
18        
19            jQuery.ajaxFileUpload
20            (
21                {
22                    url:'/typo3conf/ext/artifica_form/Classes/Userfuncs/doajaxfileupload.php?sessionId=' + _sessionId + '&formatAccept=' + argFormatAccept + '&maxWeight=' + argWeightMax,
23                    secureuri:false,
24                    fileElementId:argElmentFileId,
25                    dataType: 'json',
26                    success: function (data, status)
27                    {
28                        jQuery("#fileToUpload").removeAttr("disabled");
29                        
30                        if(typeof(data.error) != 'undefined')
31                        {
32                            if(data.error != '')
33                            {
34                                alert(data.error);
35                            }
36                            else
37                            {
38                                addRowFile(argPrefix, argElmentContentId, data);
39
40                            }
41                            
42                            updateFileCodeHtml(argElmentContentId);
43                            
44                            var _str = jQuery("#" + argElmentFileContentId).html();             
45                            jQuery("#" + argElmentFileContentId).html(_str);
46                            
47                            jQuery("#divMsgLoading").hide();
48                            jQuery("#btnSubmited").removeAttr("disabled");
49                        }
50                    },
51                    error: function (data, status, e)
52                    {
53                        alert(e);
54                    }
55                }
56            )
57        }
58    }
59    
60    return false;
61}
62
63function IsValidJSONString(str)
64{
65    try {
66        JSON.parse(str);
67    } catch (e) {
68        return false;
69    }
70    return true;
71}
72
73
74(function($) {
75
76    var itemForPlanification = '';
77    var countForPlanification = 1;
78
79    $.fn.outerHTML = function(element) {
80
81        var result = $('<div class="clone">').append(element.clone()).html();
82
83        $('div.clone').remove();
84
85        return result;
86    };
87    $.fn.initForPlanification = function(){
88
89        var element = $(this);
90
91        $('.date-item input.datepicker', element).datepicker('destroy');
92
93        var label = '';
94        var value = '';
95        for(var i = 0; i < 24; i++)
96        {
97            for(var j = 0; j < 60; j+=15)
98            {
99                label = i
100                if(label < 10) label = '0' + i;
101
102                label += ':';
103
104                if(j < 10) label += '0';
105                label += j; 
106
107                value = label;
108
109                $('div.date-item', element).find('select.hourStart').append(new Option(label, value, false, false));
110
111                $('div.date-item', element).find('select.hourEnd').append(new Option(label, value, false, false));
112            }
113        }
114
115        itemForPlanification = element.outerHTML($('div.date-item', element));
116
117        $('div.date-container', element).html('');
118
119        $('button.addDate', element).on('click', function(){
120
121            var parendId = $('> label', element).attr('for');
122
123            $('.date-container', element).append(itemForPlanification);
124
125            $('.date-container .date-item:last button.remove', element).on('click', function(){
126
127                $(this).parents('.date-item').remove();
128            });
129
130            $('.date-container .date-item:last input.dateStart', element).attr('id', parendId + '_planification_dateStart_' + countForPlanification);
131            $('.date-container .date-item:last input.dateEnd', element).attr('id', parendId + '_planification_dateEnd_' + countForPlanification);
132            
133
134            $('.date-item input.datepicker', element).datepicker({
135                inline : false,
136                dateFormat: 'dd/mm/yy',
137                timeFormat:  "hh:mm",
138                minDate: 0
139            }).on("change", function(){
140
141                //console.log($(this).hasClass('dateEnd'));
142
143//to.datepicker( "option", "minDate", getDate( this ) );
144//from.datepicker( "option", "maxDate", getDate( this ) );
145
146                //datepicker( "option", "minDate", getDate(this));
147            });
148
149            countForPlanification++;
150
151        });
152
153        if($('input[type="hidden"]', element).val())
154        {
155            var temp = decodeURIComponent($('input[type="hidden"]', element).val());
156
157            temp = JSON.parse(temp);
158
159            $.each(temp, function(index, val){
160                $('button.addDate', element).click();
161
162                $('.date-container .date-item:last .dateStart', element).val(val.dateStart);
163                $('.date-container .date-item:last .dateEnd', element).val(val.dateEnd);    
164                $('.date-container .date-item:last .hourStart', element).val(val.hourStart);
165                $('.date-container .date-item:last .hourEnd', element).val(val.hourEnd);
166                $('.date-container .date-item:last .description', element).val(val.description);
167            });
168        }
169        else
170        {
171            $('button.addDate', element).click();
172        }
173
174        /*
175        element.parents('form').find('div[class*="require"]').each(function(i){
176
177            var ele = $(this);
178
179            $('input[type="text"], select, textarea', ele).on('blur', function(){
180                
181                var flag = false;
182                
183                ele.removeClass('succes');
184                ele.addClass('alert');
185
186                if($(this).prop('type') == 'select-one')
187                {
188                    if($('option:selected', $(this)).text() != '' && $(this).val()) flag = true;
189                }
190                else if($(this).attr('type') == 'checkbox')
191                {
192                    if($(':checked', ele).length > 0) flag = true;
193                }
194                else if($(this).val())
195                {
196                    flag = true;
197                }
198                
199                if(flag)
200                {
201                    ele.removeClass('alert');
202                    ele.addClass('succes');             
203                }
204            });
205        });
206        */
207
208        element.parents('form').find('button.submit').on('click', function(event){
209
210            var flag = true;
211            var form = $(this).parents('form');
212            var parentId = $('input[type="hidden"]', element).attr('name');
213            //var parendId = $('input[type="hidden"]', element).attr('name');
214            var temp = [];
215            var count = 0;
216
217            if($('.planification').length)
218            {
219                $('.date-container .date-item', element).each(function(index, val){
220
221                    $('input', $(this)).off('blur');
222
223                    //console.log($('.dateStart', $(this)).val() + ' ' + $('.dateEnd', $(this)).val());
224
225                    if($('.dateStart', $(this)).val())
226                    {
227                        count++;
228
229                        if($('.hourStart', $(this)).val() && $('.hourEnd', $(this)).val())
230                        {
231                            var temp2 = {
232                                'dateStart' : $('.dateStart', $(this)).val(),
233                                'dateEnd' : '',
234                                'hourStart' : '',
235                                'hourEnd' : '',
236                                'description' : '',
237                            };
238
239                            if($('.dateEnd', $(this)).val()) temp2['dateEnd'] = $('.dateEnd', $(this)).val();
240                            if($('.hourStart', $(this)).val()) temp2['hourStart'] = $('.hourStart', $(this)).val();
241                            if($('.hourEnd', $(this)).val()) temp2['hourEnd'] = $('.hourEnd', $(this)).val();
242                            if($('.description', $(this)).val()) temp2['description'] = $('.description', $(this)).val();
243
244                            temp.push(temp2);
245                        }
246                    }
247
248                });
249
250                //console.log(temp);
251
252                if(temp.length > 0 && count == temp.length)
253                {
254                    $('.planification').removeClass('has-error'); 
255
256                    temp = JSON.stringify(temp);
257                    temp = encodeURI(temp);
258                }
259                else
260                {
261                    $('.planification').addClass('has-error'); 
262
263                    temp = '';
264                    flag = false;
265                }
266            }
267
268            $('input[name="'+ parentId +'"]').val(temp);
269
270            $('input[type="text"], select, textarea', form).blur();
271
272            $('div[class*="require"]', form).each(function(i){
273                if($(this).hasClass('alert')) flag = false;
274            });
275
276            if(!flag)
277            {
278                event.stopPropagation();
279                event.preventDefault();
280            }
281
282        })
283    };
284
285    $.fn.serializeFiles = function() {
286
287        var form = $(this);
288        var formData = new FormData();
289        var formParams = form.serializeArray();
290
291        $.each(form.find('input[type="file"]'), function(i, tag) {
292            $.each($(tag)[0].files, function(i, file) {
293                formData.append(tag.name, file);
294            });
295        });
296
297        $.each(formParams, function(i, val) {
298            formData.append(val.name, val.value);
299        });
300
301        return formData;
302    };
303
304    $.fn.renderFormAjax = function(element, params, callback){
305
306        var posts = {
307            'pageUid' : TYPO3.settings.rootUid,
308            'action' : 'renderForm',
309        };
310
311        if(typeof params != 'undefined')
312        {
313            if(Object.keys(params).length)
314            {
315                Object.keys(params).forEach(function(key){
316                    posts[key] = params[key];
317                });
318            }
319        }
320
321        $.ajax({
322            url: '/index.php?type=9788&id=' + TYPO3.settings.rootUid,
323            type: 'POST',
324            dataType: 'json',
325            data: posts,
326        }).done(function(result){
327
328            if(result)
329            {
330                element.html(result.html);
331                element.find('form').addClass('collapse');
332
333                var timeout = window.setTimeout(function(){
334
335                    if($('input.datepicker').length > 0)
336                    {
337                        $('input.datepicker').datepicker({
338                            showButtonPanel: true,
339                            minDate: 0,
340                            dateFormat: 'dd/mm/yy'
341                        });
342                    }
343                    
344                    if($('form[id^="myForm"]').length > 0)
345                    {
346                        $('form[id^="myForm"]').artificaForm();
347                    }
348
349                    $('form .planification').initForPlanification();
350
351                    if(typeof(callback) === "function")
352                    {
353                        callback(element, result);
354                    }
355
356                    clearTimeout(timeout);
357
358                }, 700);
359            }
360        });
361
362    };
363
364    $.fn.submitFormAjax = function(element, callback){
365
366        let formData = $(this).serializeFiles();
367        formData.append('action', 'submitData');
368        formData.append('pageUid', TYPO3.settings.pageUid);
369
370        /*
371        for (var key of formData.entries()) {
372            console.log(key[0] + ', ' + key[1]);
373        }
374        */
375
376        $.ajax({
377            url: '/index.php?type=9788&id=' + TYPO3.settings.rootUid,
378            type: 'POST',
379            dataType: 'json',
380            data: formData,
381            contentType: false,
382            cache: false,
383            processData:false,
384        }).done(function(result){
385
386            if(result)
387            {
388                if(typeof(callback) === "function")
389                {
390                    callback(element, result);
391                }
392            }
393        });
394
395    };
396
397    $.fn.fileToUpload = function(options){
398
399        return this.each(function(){
400
401            var artificaFormFileToUpload = this;
402
403            $.extend(this, {
404                $el : $(this),
405                id : $(this).attr('id'),
406                name : $(this).attr('name'),
407                $parent : null,
408                $form : null,
409
410                options : $.extend({
411                    type : 'simple',
412                    max : 0,
413                }, options),
414
415                init : () => {
416
417                    this.$form = this.$el.parents('form');
418
419                    let value = this.$el.attr("value");
420
421                    if(this.options.type == 'gallery')
422                    {
423                        this.renderGallery(value);
424
425                    }
426                    else
427                    {
428                        this.renderSimple(value);
429                    }
430                    // https://fontawesome.com/v4.7.0/icons/
431                    // https://blueimp.github.io/jQuery-File-Upload/
432
433                    // https://usefulangle.com/post/67/pure-javascript-ajax-file-upload-showing-progess-percent
434
435                    // https://icons8.com/icon/pack/files/ios
436
437                    //https://www.pngrepo.com/collection/user-interface/3
438
439
440                },
441
442                renderSimple : (value) => {
443
444                    let title = '';
445                    let file = null;
446
447                    if(value)
448                    {
449                        let temp = decodeURIComponent(value);
450                        if(IsValidJSONString(temp))
451                        {
452                            file = JSON.parse(temp);
453                            title = file.name;
454                        }
455                    }  
456
457                    //let title = value;
458                    //let split = value.split('/');
459                    //if(split) title = split[(split.length - 1)];
460
461                    this.$el.wrap('<div class="form-fileupload-container"></div>');
462                    this.$el.wrap('<span class="btn form-fileinput-button"></span>');
463                    this.$el.before('<i class="icon-file-add"></i><span>
463Cliquez pour ajouter un fichier.</span>');
464
465                    this.$parent = this.$el.parents('.form-fileupload-container');
466
467                    // loading
468                    this.$parent.append('<span class="btn form-fileinput-wait form-fileupload-hide"><i class="icon-file-loading"></i><span>Chargement du fichier ...</span></span>');
469
470                    this.$parent.append('<span class="btn form-fileinput-value form-fileupload-hide"><i class="icon-file-blocked"></i><span>' + title + '</span><button class="remove">Supprimer</button></span>');
471                    this.$parent.append('<input id="fileupload_' + this.id + '" type="hidden" name="' + this.name + '" value="' + value + '" />');
472
473                    //<br /><span>Le fichier est enregistré dans le coffre-fort.</span>
474
475                    document.getElementById(this.id).name = 'fileupload[' + this.id + ']';
476
477                    if(value)
478                    {
479                        this.$parent.find('.form-fileinput-value').removeClass('form-fileupload-hide');
480                        this.$parent.find('.form-fileinput-button').addClass('form-fileupload-hide');                        
481                    }
482
483                    this.$el.on('change', function(){
484                        
485                        let file = document.querySelector('#' + artificaFormFileToUpload.id).files[0];
486
487                        let params = {
488                            'file' : file,
489                            'field' : artificaFormFileToUpload.id,
490                            'reference' : artificaFormFileToUpload.$form.find('#reference_id').val(),
491                            'sys-content-uid' : artificaFormFileToUpload.$form.find('input[name="sys-content-uid"]').val(),
492                        };
493
494                        artificaFormFileToUpload.$parent.find('.form-fileinput-wait').find('span').html('Chargement du fichier ...');
495                        artificaFormFileToUpload.$parent.find('.form-fileinput-wait').removeClass('form-fileupload-hide');
496                        artificaFormFileToUpload.$parent.find('.form-fileinput-button').addClass('form-fileupload-hide');
497
498                        artificaFormFileToUpload.submit($(this), 'fileUpload', params, function(element, result){
499
500                            if(result.status == 'ok')
501                            {
502                                var timeout1 = window.setTimeout(function(){
503
504                                    let myString = JSON.stringify(result.response);
505
506                                    artificaFormFileToUpload.$parent.find('#fileupload_' + artificaFormFileToUpload.id).val(encodeURIComponent(myString));
507
508                                    artificaFormFileToUpload.$parent.find('.form-fileinput-value span').html(file.name);
509                                    artificaFormFileToUpload.$parent.find('.form-fileinput-value').removeClass('form-fileupload-hide');
510                                    artificaFormFileToUpload.$parent.find('.form-fileinput-wait').addClass('form-fileupload-hide');
511
512                                    clearTimeout(timeout1);
513
514                                }, 1500);
515                            }
516
517                        });
518
519                    });
520
521                    this.$parent.find('button.remove').on('click', function(e){
522
523                        e.stopPropagation();
524                        e.preventDefault();
525
526                        if(confirm('Voulez-vous vraiment supprimer ce fichier ?'))
527                        {
528                            let params = {
529                                'field' : artificaFormFileToUpload.id,
530                                'reference' : artificaFormFileToUpload.$form.find('#reference_id').val(),
531                                'sys-content-uid' : artificaFormFileToUpload.$form.find('input[name="sys-content-uid"]').val(),
532                            };
533
534                            artificaFormFileToUpload.$parent.find('.form-fileinput-wait').find('span').html('Suppression du fichier ...');
535                            artificaFormFileToUpload.$parent.find('.form-fileinput-wait').removeClass('form-fileupload-hide');
536                            artificaFormFileToUpload.$parent.find('.form-fileinput-value').addClass('form-fileupload-hide');
537
538                            artificaFormFileToUpload.submit($(this), 'fileRemove', params, function(element, result){
539
540                                if(result.status === 'ok')
541                                {
542                                    var timeout1 = window.setTimeout(function(){
543
544                                        artificaFormFileToUpload.$parent.find('#fileupload_' + artificaFormFileToUpload.id).val('');
545                                        artificaFormFileToUpload.$parent.find('.form-fileinput-value span').html('');
546                                        artificaFormFileToUpload.$parent.find('.form-fileinput-value').addClass('form-fileupload-hide');
547                                        artificaFormFileToUpload.$parent.find('.form-fileinput-button').removeClass('form-fileupload-hide');
548
549                                        artificaFormFileToUpload.$parent.find('.form-fileinput-wait').addClass('form-fileupload-hide');
550
551                                        clearTimeout(timeout1);
552
553                                    }, 1500);
554                                }
555
556                            });
557                        }
558
559                    });
560
561                },
562
563                renderGallery : (value) => {
564
565                    this.$el.wrap('<div class="form-fileupload-gallery-container"></div>');
566                    this.$el.wrap('<span class="btn form-fileinput-button"></span>');
567                    this.$el.before('<i class="icon-file-add"></i><span>
567Cliquez pour ajouter un fichier.</span>');
568                    
569                    this.$parent = this.$el.parents('.form-fileupload-gallery-container');
570
571                    this.$parent.append('<input id="fileupload_' + this.id + '" type="hidden" name="' + this.name + '" value="' + value + '" />');
572
573                    //<br /><span>Le fichier est enregistré dans le coffre-fort.</span>
574
575                    //document.getElementById(this.id).name = 'fileupload[' + this.id + ']';
576                    let images = [];
577
578                    if(value)
579                    {
580                        value = decodeURIComponent(value);
581                        if(IsValidJSONString(value)) images = JSON.parse(value);
582                    }
583
584                    if(images.length)
585                    {
586                        if(images.length >= this.options.max)
587                        {
588                            artificaFormFileToUpload.$parent.find('.form-fileinput-button').addClass('hidden');
589                        }
590
591                        images.forEach(function(val, index){
592
593                            artificaFormFileToUpload.$parent.find('.form-fileinput-button').before('<span class="btn form-fileinput-element form-fileinput-element-' + index + '"><img src="' + val.file + '" width="150" height="150" /></span>');
594                        });
595                    }
596
597                    artificaFormFileToUpload.$parent.find('.form-fileinput-element').on('click', function(e){
598
599                        e.stopPropagation();
600                        e.preventDefault();
601
602                        artificaFormFileToUpload.removeFile($(this), images);
603
604                    });
605
606                    this.$el.on('change', function(){
607                        
608                        let file = document.querySelector('#' + artificaFormFileToUpload.id).files[0];
609
610                        let params = {
611                            'file' : file,
612                            'field' : artificaFormFileToUpload.id,
613                            'reference' : '',
614                            'sys-content-uid' : artificaFormFileToUpload.$form.find('input[name="sys-content-uid"]').val(),
615                        };
616
617                        artificaFormFileToUpload.$parent.find('.form-fileinput-button').addClass('hidden');
618
619                        artificaFormFileToUpload.$parent.find('.form-fileinput-button').before('<span class="btn form-fileinput-element form-fileinput-element-new loading"></span>');
620
621                        artificaFormFileToUpload.submit($(this), 'fileUpload', params, function(element, result){
622
623                            if(result.status == 'ok')
624                            {
625                                var timeout1 = window.setTimeout(function(){
626
627                                    artificaFormFileToUpload.$parent.find('.form-fileinput-element-new').removeClass('loading');
628                                    artificaFormFileToUpload.$parent.find('.form-fileinput-element-new').html('<img src="' + result.response.file + '" width="150" height="150" />');
629
630                                    artificaFormFileToUpload.$parent.find('.form-fileinput-element-new').on('click', function(e){
631
632                                        e.stopPropagation();
633                                        e.preventDefault();
634
635                                        artificaFormFileToUpload.removeFile($(this), images);
636
637                                    });
638
639                                    artificaFormFileToUpload.$parent.find('.form-fileinput-element-new').removeClass('form-fileinput-element-new');
640
641                                    images.push(result.response);
642
643
644                                    if(images.length < artificaFormFileToUpload.options.max)
645                                    {
646                                        artificaFormFileToUpload.$parent.find('.form-fileinput-button').removeClass('hidden');
647                                    }
648
649                                    let myString = JSON.stringify(images);
650
651                                    artificaFormFileToUpload.$parent.find('#fileupload_' + artificaFormFileToUpload.id).attr('value', encodeURIComponent(m
651yString));
652
653                                }, 1500);
654                            }
655                            
656                        });
657
658                    });
659
660                },
661
662                removeFile : (element, images) => {
663
664                    if(confirm('Voulez-vous vraiment supprimer cette photo ?'))
665                    {
666                        let file = element.find('img').attr('src');
667
668                        images.forEach(function(val, index){
669
670                            if(file == val.file)
671                            {
672                                images.splice(index, 1);
673                                element.remove();
674                            }
675
676                        });
677
678                        artificaFormFileToUpload.$parent.find('.form-fileinput-button').removeClass('hidden');
679
680                        let myString = JSON.stringify(images);
681
682                        artificaFormFileToUpload.$parent.find('#fileupload_' + artificaFormFileToUpload.id).attr('value', encodeURIComponent(myString));
683                    }
684
685                },
686
687                submit : (element, action, params, callback) => {
688
689                    let posts = new FormData();
690                    posts.append('action', action);
691                    posts.append('pageUid', TYPO3.settings.pageUid);
692
693                    if(typeof params != 'undefined')
694                    {
695                        if(Object.keys(params).length)
696                        {
697                            Object.keys(params).forEach(function(key){
698                                posts.append(key, params[key]);
699                            });
700                        }
701                    }
702
703                    $.ajax({
704                        url: '/index.php?type=9788&id=' + TYPO3.settings.rootUid,
705                        type: 'POST',
706                        dataType: 'json',
707                        data: posts,
708                        contentType: false,
709                        cache: false,
710                        processData:false,
711                    }).done(function(result){
712
713                        if(result)
714                        {
715                            if(typeof(callback) === "function")
716                            {
717                                callback(element, result);
718                            }
719                        }
720                    });
721
722                },
723
724            });
725
726            this.init();
727
728        });
729
730    };
731
732    $.fn.handleError = function( s, xhr, status, e ){
733
734        // If a local callback was specified, fire it
735        if ( s.error ) {
736            s.error.call( s.context || window, xhr, status, e );
737        }
738
739        // Fire the global callback
740        if ( s.global ) {
741            (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
742        }
743
744    };  
745        
746    $.fn.createUploadIframe = function(id, uri){
747
748        //create frame
749        var frameId = 'jUploadFrame' + id;
750        
751        if(window.ActiveXObject) {
752            var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
753            if(typeof uri== 'boolean'){
754                io.src = 'javascript:false';
755            }
756            else if(typeof uri== 'string'){
757                io.src = uri;
758            }
759        }
760        else {
761            var io = document.createElement('iframe');
762            io.id = frameId;
763            io.name = frameId;
764        }
765        io.style.position = 'absolute';
766        io.style.top = '-1000px';
767        io.style.left = '-1000px';
768
769        document.body.appendChild(io);
770
771        return io;          
772    };
773
774    $.fn.createUploadForm = function(id, fileElementId){
775
776        //create form   
777        var formId = 'jUploadForm' + id;
778        var fileId = 'jUploadFile' + id;
779        var form = $('<form  action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>'); 
780        var oldElement = $('#' + fileElementId);
781        var newElement = $(oldElement).clone();
782        $(oldElement).attr('id', fileId);
783        $(oldElement).before(newElement);
784        $(oldElement).appendTo(form);
785        //set attributes
786        $(form).css('position', 'absolute');
787        $(form).css('top', '-1200px');
788        $(form).css('left', '-1200px');
789        $(form).appendTo('body');       
790        return form;
791    };
792
793    $.fn.ajaxFileUpload = function(s){
794
795        // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout        
796        s = $.extend({}, $.ajaxSettings, s);
797        var id = new Date().getTime()        
798        var form = $.createUploadForm(id, s.fileElementId);
799        var io = $.createUploadIframe(id, s.secureuri);
800        var frameId = 'jUploadFrame' + id;
801        var formId = 'jUploadForm' + id;        
802        // Watch for a new set of requests
803        if ( s.global && ! $.active++ )
804        {
805            $.event.trigger( "ajaxStart" );
806        }            
807        var requestDone = false;
808        // Create the request object
809        var xml = {}   
810        if ( s.global )
811            $.event.trigger("ajaxSend", [xml, s]);
812        // Wait for a response to come back
813        var uploadCallback = function(isTimeout)
814        {           
815            var io = document.getElementById(frameId);
816            try 
817            {               
818                if(io.contentWindow)
819                {
820                     xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
821                     xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
822                     
823                }else if(io.contentDocument)
824                {
825                     xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
826                    xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
827                }                       
828            }catch(e)
829            {
830                $.handleError(s, xml, null, e);
831            }
832            if ( xml || isTimeout == "timeout") 
833            {               
834                requestDone = true;
835                var status;
836                try {
837                    status = isTimeout != "timeout" ? "success" : "error";
838                    // Make sure that the request was successful or notmodified
839                    if ( status != "error" )
840                    {
841                        // process the data (runs the xml through httpData regardless of callback)
842                        var data = $.uploadHttpData( xml, s.dataType );    
843                        // If a local callback was specified, fire it and pass it the data
844                        if ( s.success )
845                            s.success( data, status );
846    
847                        // Fire the global callback
848                        if( s.global )
849                            $.event.trigger( "ajaxSuccess", [xml, s] );
850                    } else
851                        $.handleError(s, xml, status);
852                } catch(e) 
853                {
854                    status = "error";
855                    $.handleError(s, xml, status, e);
856                }
857
858                // The request was completed
859                if( s.global )
860                    $.event.trigger( "ajaxComplete", [xml, s] );
861
862                // Handle the global AJAX counter
863                if ( s.global && ! --$.active )
864                    $.event.trigger( "ajaxStop" );
865
866                // Process result
867                if ( s.complete )
868                    s.complete(xml, status);
869
870                $(io).unbind()
871
872                setTimeout(function()
873                                    {   try 
874                                        {
875                                            $(io).remove();
876                                            $(form).remove();   
877                                            
878                                        } catch(e) 
879                                        {
880                                            $.handleError(s, xml, null, e);
881                                        }                                   
882
883                                    }, 100)
884
885                xml = null
886
887            }
888        }
889        // Timeout checker
890        if ( s.timeout > 0 ) 
891        {
892            setTimeout(function(){
893                // Check to see if the request is still happening
894                if( !requestDone ) uploadCallback( "timeout" );
895            }, s.timeout);
896        }
897        try 
898        {
899           // var io = $('#' + frameId);
900            var form = $('#' + formId);
901            $(form).attr('action', s.url);
902            $(form).attr('method', 'POST');
903            $(form).attr('target', frameId);
904            if(form.encoding)
905            {
906                form.encoding = 'multipart/form-data';              
907            }
908            else
909            {               
910                form.enctype = 'multipart/form-data';
911            }           
912            $(form).submit();
913
914        } catch(e) 
915        {           
916            $.handleError(s, xml, null, e);
917        }
918        if(window.attachEvent){
919            document.getElementById(frameId).attachEvent('onload', uploadCallback);
920        }
921        else{
922            document.getElementById(frameId).addEventListener('load', uploadCallback, false);
923        }       
924        return {abort: function () {}}; 
925
926    };
927
928    $.fn.uploadHttpData = function( r, type ){
929        var data = !type;
930        data = type == "xml" || data ? r.responseXML : r.responseText;
931        // If the type is "script", eval it in global context
932        if ( type == "script" )
933            $.globalEval( data );
934        // Get the JavaScript object, if JSON is used.
935        if ( type == "json" )
936            eval( "data = " + data );
937        // evaluate scripts within html
938        if ( type == "html" )
939            $("<div>").html(data).evalScripts();
940            //alert($('param', data).each(function(){alert($(this).attr('value'));}));
941        return data;
942    };
943
944    $.fn.artificaForm = function(){
945        return this.each(function(){
946
947            var artificaForm = this;
948
949            $.extend(this, {
950                $el : $(this),
951                parentUid : $(this).attr('id'),
952                init : () => {
953
954                    if(typeof this.parentUid == 'string') this.parentUid = parseInt(this.parentUid.replace('myForm', ''));
955
956                    this.$el.find('select').each(function(j){
957
958                        if($(this).find('option[data-condition]').length > 0)
959                        {
960                            $(this).on('change', function(){
961
962                                artificaForm.refresh($(this).find('option:selected'));
963
964                            });
965
966                            if($(this).val()) $(this).trigger('change');
967                        }
968                    });
969
970                    this.$el.find('input[type="radio"][data-condition], input[type="radio"][condition]').each(function(j){
971
972                        var condition = $(this).attr('data-condition');
973                        if(typeof $(this).attr('condition') == 'string') condition = $(this).attr('condition');
974
975                        var split = condition.split('-');
976                        split[5] = split[5].replace('"', '');
977
978                        if(artificaForm.$el.find('div[class*="tx-artificaform-pi1-' + artificaForm.parentUid + '-condition-' + split[5] + '"]').length > 0)
979                        {
980                            $(this).on('click', function(){
981                                artificaForm.refresh($(this));
982                            });
983
984                            if($(this).is(':checked')) $(this).click();
985                        }
986                    });
987
988                    $('.previous').on('click', function(e){
989                        
990                        artificaForm.$el.find('input, textarea, select').each(function(){
991                            $(this).prop('required', false);
992                        });
993
994                    });
995
996                    
997                    this.$el.on('submit', function(e){
998
999                        let flag = true;
1000                        
1001                        //$('input, select', $(this)).blur();
1002
1003                        let params =  {};
1004
1005                        $.each($(this).serializeArray(), function(index, val){
1006                            params[val.name] = val.value;
1007                        });
1008                        
1009                        $('div[class*="require"]', $(this)).each(function(i){
1010                            if($(this).hasClass('has-error')) flag = false;
1011                        });
1012                        
1013                        if(!flag)
1014                        {
1015                            e.stopPropagation();
1016                            e.preventDefault(); 
1017                        }
1018                    });                 
1019
1020                },
1021                refresh : (element) => {
1022
1023                    var timer = null;
1024
1025                    var condition = element.attr('data-condition');
1026                    if(typeof element.attr('condition') == 'string') condition = element.attr('condition');
1027
1028                    var split = condition.split('-');
1029
1030                    split[5] = split[5].replace('"', '');
1031
1032                    //if(typeof split[7] != 'undefined') split[6] += '-' + split[7];
1033
1034                    var field = (split[5] + '-' + split[6]);
1035
1036                    field = field.replace('"', '');
1037                
1038                    var ele = element.parents('div.form-group');
1039                    ele.addClass('loading');
1040
1041                    artificaForm.$el.find('input[data-required],select[data-required],textarea[data-required]').attr('required', 'required').removeAttr('data-required');
1042                    
1043                    timer = window.setTimeout(function(){
1044
1045                        ele.removeClass('loading');
1046
1047                        artificaForm.$el.find('div[class*="tx-artificaform-pi1-' + artificaForm.parentUid + '-condition-' + split[5] + '"]').addClass('invisible').addClass('collapse');
1048
1049                        artificaForm.$el.find('div[class*="tx-artificaform-pi1-' + artificaForm.parentUid + '-condition-' + field + '-end"]').removeClass('invisible').removeClass('collapse');
1050
1051                        artificaForm.$el.find('div.invisible').find('input[required],select[required],textarea[required]').attr('data-required', 'required').removeAttr('required');
1052                    
1053                        window.clearTimeout(timer);
1054                        
1055                    }, 700);
1056
1057                },
1058
1059            });
1060
1061            this.init();
1062        });
1063    };
1064
1065})(jQuery);
1066
1067$(document).ready(function(){
1068
1069    if($('input.datepicker').length > 0)
1070    {
1071        $('input.datepicker').datepicker({
1072            showButtonPanel: true,
1073            minDate: 0,
1074            dateFormat: 'dd/mm/yy'
1075        });
1076    }
1077    
1078    if($('form[id^="myForm"]').length > 0)
1079    {
1080        $('form[id^="myForm"]').artificaForm();
1081    }
1082
1083
1084    $('form .planification').initForPlanification();
1085    
1086});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.