PageSourceSearch

https://www.leinwandfoto.de/wp-content/themes/LWF_new/js/upload.js

js leinwandfoto.de collected 2026-09-26 15:55:51 UTC 19,471 bytes, 545 lines download raw bytes

1var progress_array = new Array();
2var progress;
3var upload_data = new Object();
4
5jQuery(document).ready(function($){
6	
7	$(document).bind('drop dragover', function (e) {
8        e.preventDefault();
9    });
10    
11    $(document).bind('dragover', function (e) {
12        var dropZone = $('.js-dropzone'),
13            timeout = window.dropZoneTimeout;
14        if (!timeout) {
15            dropZone.addClass('in');
16        } else {
17            clearTimeout(timeout);
18        }
19        var found = false,
20            node = e.target;
21        do {
22            if (node === dropZone[0]) {
23                found = true;
24                break;
25            }
26            node = node.parentNode;
27        } while (node != null);
28        if (found) {
29            dropZone.addClass('hover');
30        } else {
31            dropZone.removeClass('hover');
32        }
33        window.dropZoneTimeout = setTimeout(function () {
34            window.dropZoneTimeout = null;
35            dropZone.removeClass('in hover');
36        }, 100);
37    });
38    
39    
40    $('body').on('click', '.js-upload-btn', function(){
41    	var element = $(this);
42    	SetUploadData(element);
43        jQuery.fancybox.open({
44			src: '/apps/lwf_agf_global/themes/LWF_new/js/templates/upload-form.php?vlog='+xVlog+'&language='+xLanguage,
45			type: 'ajax',
46			touch: false,
47			afterLoad: function(){
48			    ShowPreselectBar();
49			    if (element.attr('data-upload-type') == 2) {
50			        SetUploadState(2);
51			    }
52			    if (element.attr('data-upload-type') == 5 || element.attr('data-upload-type') == 6) {
53			        jQuery('.upload-step-2 form, .upload-step-2 .buttons').remove();
54			    }
55			},
56			afterShow: function(instance, current) {
57				$('.fb-upload .js-upload').each(function(){
58    				InitFileUpload($(this));
59			    });
60			},
61			beforeClose: function() {
62	            if (element.attr('data-upload-type') != 6) {
63	                if ((jQuery('.upload-step-2').is(':visible') || jQuery('.upload-step-3').is(':visible')) && jQuery('.upload-step-2').hasClass('finished')) {
64					    if ('mehrteiler' in upload_data) {
65					        RedirectAtUpload('mehrteiler', upload_data['mehrteiler']);
66					    } else {
67					        RedirectAtUpload();
68					    }
69					}
70				}
71			},
72			afterClose: function(instance, slide) {
73		        if (element.attr('data-upload-type') != 6) {
74		            if (typeof upload_data['object'] != 'undefined') {
75						upload_data['object'].abort();
76					}
77					upload_data['error'] = 0;
78					delete upload_data['size'];
79					HidePreselectBar();
80					SetUploadState(1);
81				}
82			}
83		});
84		
85    });
86    
87    
88    $('.js-upload').each(function(){
89    	InitFileUpload($(this));
90    });
91    
92    
93    $('.js-lead-refuse').on('click', function(){
94        RedirectAtUpload();
95    });
96    
97});
98
99
100function InitFileUpload(target) {
101	if (target.attr('data-upload-type') == 2) {
102		var drop_zone = jQuery('.upload-combi .js-dropzone');
103	} else 	if (target.attr('data-upload-type') == 6 && target.parents('.js-dropzone').length) {
104        var drop_zone = jQuery('.upload-tester .js-dropzone');
105    } else if (target.parents('.fb-upload').length) {
106        var drop_zone = target.parents('.fb-upload').find('.js-dropzone');
107    } else {
108		drop_zone = false;
109    }
110	target.fileupload({
111        url: '/global/functions/upload.php',
112        dataType: 'json',
113        dropZone: drop_zone,
114        autoUpload: true,
115        singleFileUploads: false,
116        sequentialUploads: true,
117        acceptFileTypes: /(\.|\/)(jpe?g|png)$/i,
118        disableImageResize: false,
119        disableExif: true,
120        disableImageMetaDataSave: true,
121        disableImageMetaDataLoad: true,
122        disableImagePreview: true,
123        loadImageMaxFileSize: 1000000000,
124        imageMaxWidth: 9000,
125        imageMaxHeight: 9000
126    }).on('fileuploadadd', function (e, data) {
127    	HidePreselectBar();
128        upload_data['object'] = null;
129        if (typeof upload_data['special'] != 'undefined') {
130            data.url = '/global/functions/upload.php?special=sw';
131        }
132        if (typeof upload_data['filter'] != 'undefined') {
133          data.url = '/global/functions/upload.php?filter='+upload_data['filter'];
134      }
135        if ('mehrteiler' in upload_data) {
136            data.url = '/global/functions/upload.php?mehrteiler';
137            upload_data['object'] = data.submit();
138            SetUploadState(2);
139        } else if (jQuery(e.target).attr('data-upload-type') == 4) {
140            SetUploadProgress(0);
141            SetPromotionState(3);
142            //jQuery.fancybox.update();
143            setTimeout(function(){
144                upload_data['object'] = data.submit();
145            }, 200);
146        } else if (jQuery(e.target).attr('data-upload-type') == 3) { // 3 = contact
147            SetContactUploadProgress(0);
148            data.url = '/global/functions/upload.php?contact';
149            jQuery('.contact-upload .loading').addClass('progressing');
150            jQuery('.contact-upload p').text(data.files[0].name);
151            upload_data['object'] = data.submit();
152        } else if (jQuery(e.target).attr('data-upload-type') == 2) {
153            SetUploadProgress(0);
154            OpenFancyBox(jQuery(e.target), 'upload');
155            setTimeout(function(){
156                upload_data['object'] = data.submit();
157            }, 200);
158        } else if (jQuery(e.target).attr('data-upload-type') == 6) { // 6 = tester
159            //data.url = '/global/functions/upload.php?special=tester';
160            if (e.target.hasAttribute('data-pg')) {
161		        upload_data['pg'] = jQuery(e.target).attr('data-pg');
162		    }
163            jQuery.fancybox.close();
164            SetUploadState(2);
165            SetUploadProgress(0);
166            OpenFancyBox(jQuery(e.target), 'upload');
167            setTimeout(function(){
168                upload_data['object'] = data.submit();
169            }, 200);
170        } else {
171            upload_data['object'] = data.submit();
172            if (typeof upload_data['code'] != 'undefined') {
173                SetUploadState(0);
174                Cookies.set('COUPON', upload_data['code'], { expires: 3, domain: translate['cookie_domain'], path: '/' });
175            } else {
176                SetUploadState(2);
177            }
178        }
179    }).on('fileuploadstart', function (e, data) {
180        // alert('start');
181    }).on('fileuploadprocessfail', function (e, data) {
182    	
183        //alert('process fail');
184    }).on('fileuploadprocessdone', function (e, data) {
185        //console.log(data);
186        //console.log('processing fertig');
187    }).on('fileuploadprogressall', function (e, data) {
188        progress = parseInt(data.loaded / (data.total * 1.05) * 100, 10);
189        progress_array.push(progress);
190        if (progress >= getMaxOfArray(progress_array)) {
191            if (jQuery(e.target).attr('data-upload-type') == 3) {
192                SetContactUploadProgress(progress);
193            } else {
194                SetUploadProgress(progress);
195            }
196        }
197    }).on('fileuploaddone', function (e, data) {
198        SetUploadProgress(0);
199        upload_data['error'] = 1;
200        console.log(1);
201        if (typeof data.result.files[0].error != 'undefined') {
202            if (jQuery(e.target).attr('data-upload-type') == 6) {
203				jQuery.fancybox.close();
204				OpenFancyBox(null, 'tester-negative');
205			} else {
206				ShowPreselectBar(data.result.files[0].error);
207			}
208        } else {
209            if (upload_data['error'] == 0) {
210                //ShowPreselectBar();
211            }
212            if (jQuery(e.target).attr('data-upload-type') == 3) {
213                jQuery('.contact-upload .loading, .contact-upload input').remove();
214                //jQuery('.contact-upload .loading').removeClass('progressing');
215                jQuery('.contact-upload').attr('data-filename', data.result.files[0].name);
216                if (jQuery('.help-widget-form').length) {
217					jQuery('.help-widget-form input[name="file"]').val(data.result.files[0].name);
218                } else {
219					jQuery('form[name="contact"]').prepend('<input type="hidden" name="file" value="'+data.result.files[0].name+'" />');
220                }
221                jQuery('.contact-upload p').text(translate['contact_upload_finished']);
222            } else if (jQuery(e.target).attr('data-upload-type') == 6) {
223				jQuery.fancybox.close();
224				jQuery('.fb-tester-positive a.btn').attr('href', '/tunnel/?step=1&vlog='+xVlog+'&ref='+xRef+'&language='+xLanguage+'&currency='+xCurrency+'&pg='+upload_data['pg']);
225				jQuery('.fb-tester-positive img').attr('src', '/global/images/temp_uploads/thumbs/'+data.result.files[0]['300Url']);
226				OpenFancyBox(null, 'tester-positive');
227            } else if (!jQuery('.upload-step-2 form').is(':visible')) {
228                jQuery('.upload-step-2').addClass('finished');
229                jQuery('.js-lead-refuse, .upload-progress').removeClass('error');
230                if ('wandcollage' in upload_data) {
231                    RedirectAtUpload('wandcollage', upload_data['wandcollage']);
232                } else if ('mehrteiler' in upload_data) {
233                    RedirectAtUpload('mehrteiler', upload_data['mehrteiler']);
234                } else {
235                    RedirectAtUpload();
236                }
237            } else {
238                jQuery('.upload-step-2').addClass('finished');
239                jQuery('.upload-step-2 > .headline').html(translate['upload_2_headline_finished']);
240                jQuery('.js-lead-refuse, .upload-progress').removeClass('error');
241                SetUploadLink();
242            }
243        }
244    });
245}
246
247
248function RedirectAtUpload(mode, params) {
249    if (mode == 'mehrteiler') {
250        params = params.split('-');
251        var urls = {
252			'de': {
253				1: '/mehrteilige-leinwand-selbst-gestalten/mehrteiler-erstellen/',
254				3: '/mehrteiler-erstellen/',
255				4: '/mehrteiler-erstellen/',
256			},
257			'en': {
258				1: '/split-canvas-prints/create-split-canvas/',
259				3: '/split-acrylic-prints/create-split-canvas/',
260				4: '/split-acrylic-prints/create-split-canvas/',
261			},
262			'fr': {
263				1: '/tableau-multi-panneaux-personnalise/creer-multi-panneaux/',
264				3: '/tableau-multi-panneaux-personnalise/creer-multi-panneaux/',
265				4: '/tableau-multi-panneaux-personnalise/creer-multi-panneaux/',
266			},
267			'nl': {
268				1: '/drieluik-canvas/meerluik-maken/',
269				3: '/drieluik-plexiglas/meerluik-maken/',
270				4: '/drieluik-plexiglas/meerluik-maken/',
271
272			},
273			'es': {
274				1: '/triptico/crear-triptico/',
275				3: '/triptico/crear-triptico/',
276				4: '/triptico/crear-triptico/',
277			},
278			'it': {
279				1: '/trittico/crea-foto-multi-pannello/',
280				3: '/trittico/crea-foto-multi-pannello/',
281				4: '/trittico/crea-foto-multi-pannello/',
282			},
283        };
284	        
285        if (params.length == 3) {
286			var pg = params[2];
287		} else {
288			var pg = 1;
289		}
290		
291        var url = urls[xLanguage][pg];
292        if (jQuery('.upload-step-2').hasClass('finished')) {
293        	Redirect(url, 'parts='+params[0]+'&version='+params[1]+'&pg='+pg);
294        } else {
295            jQuery('.js-lead-refuse, .upload-progress').addClass('error');
296        }
297    } else if (mode == 'wandcollage') {
298        params = params.split('-');
299        switch(xLanguage) {
300            case 'de':
301                var url = '/bilderwand/';
302                break;
303            case 'en':
304                var url = '/split-canvas-prints/create-split-canvas/';
305                break;
306            case 'fr':
307                var url = '/tableau-multi-panneaux-personnalise/creer-multi-panneaux/';
308                break;
309            case 'nl':
310                var url = '/drieluik/meerluik-maken/';
311                break;
312            case 'es':
313                var url = '/triptico/crear-triptico/';
314                break;
315            case 'it':
316                var url = '/trittico/crea-foto-multi-pannello/';
317                break;
318        }
319        
320        if (jQuery('.upload-step-2').hasClass('finished')) {
321            Redirect(url, 'parts='+params[0]+'&version='+params[1]);
322        } else {
323            jQuery('.js-lead-refuse, .upload-progress').addClass('error');
324        }
325    } else {
326        var url = 'step=1&vlog='+xVlog+'&ref='+xRef+'&language='+xLanguage+'&currency='+xCurrency;
327        
328        if (typeof upload_data['pid'] != 'undefined') {
329            url += '&pid='+upload_data['pid'];
330        }
331        if (typeof upload_data['pg'] != 'undefined') {
332            url += '&pg='+upload_data['pg'];
333        }
334        if (typeof upload_data['delivery'] != 'undefined') {
335            url += '&delivery='+upload_data['delivery'];
336        }
337        if (typeof upload_data['type_group'] != 'undefined') {
338            url += '&type_group='+upload_data['type_group'];
339        }
340        if (typeof upload_data['property_1'] != 'undefined') {
341            url += '&property_1='+upload_data['property_1'];
342        }
343        
344        if (jQuery('.upload-step-2').hasClass('finished')) {
345            Redirect('/tunnel/', url);
346        } else {
347            jQuery('.js-lead-refuse, .upload-progress').addClass('error');
348        }
349    }
350}
351
352
353function SetUploadLink() {
354    var url = '/tunnel/?step=1&vlog='+xVlog+'&ref='+xRef+'&language='+xLanguage+'&currency='+xCurrency;
355    
356    if (typeof upload_data['pid'] != 'undefined') {
357        url += '&pid='+upload_data['pid'];
358    }
359    if (typeof upload_data['pg'] != 'undefined') {
360        url += '&pg='+upload_data['pg'];
361    }
362    if (typeof upload_data['delivery'] != 'undefined') {
363        url += '&delivery='+upload_data['delivery'];
364    }
365    if (typeof upload_data['type_group'] != 'undefined') {
366        url += '&type_group='+upload_data['type_group'];
367    }
368    if (typeof upload_data['property_1'] != 'undefined') {
369        url += '&property_1='+upload_data['property_1'];
370    }
371    
372    if ('mehrteiler' in upload_data) {
373        params = upload_data['mehrteiler'].split('-');
374        var urls = {
375			'de': {
376				1: '/mehrteilige-leinwand-selbst-gestalten/mehrteiler-erstellen/',
377				3: '/mehrteiler-erstellen/',
378				4: '/mehrteiler-erstellen/',
379			},
380			'en': {
381				1: '/split-canvas-prints/create-split-canvas/',
382			},
383			'fr': {
384				1: '/tableau-multi-panneaux-personnalise/creer-multi-panneaux/',
385			},
386			'nl': {
387				1: '/drieluik/meerluik-maken/',
388			},
389			'es': {
390				1: '/triptico/crear-triptico/',
391			},
392			'it': {
393				1: '/trittico/crea-foto-multi-pannello/',
394			},
395        };
396	        
397        if (params.length == 3) {
398			var pg = params[2];
399		} else {
400			var pg = 1;
401		}
402		
403        var url = urls[xLanguage][pg];
404        url += '?parts='+params[0]+'&version='+params[1]+'&pg='+pg;
405    }
406    
407    jQuery('.js-lead-refuse').prop('href', url);
408}
409
410
411function SetPromotionState(state) {
412    if (state == 2) {
413        jQuery('.fb-promotion .step-1').hide();
414        jQuery('.fb-promotion .step-2').show();
415    } else if (state == 3) {
416        jQuery('.fb-promotion .step-2').hide();
417        jQuery('.fb-promotion .step-3').show();
418        setTimeout(function(){
419            //jQuery.fancybox.reposition();
420        }, 100);
421    }
422}
423
424
425function SetUploadState(state) {
426    if (state == 0) {
427        //jQuery('.fancybox-wrap, .fancybox-inner').width(650);
428        jQuery('.upload-step-2').removeClass('finished');
429        jQuery('.upload-step-1, .upload-step-2 form, .upload-step-2 .buttons').hide();
430        jQuery('.upload-step-2').show();
431        //jQuery.fancybox.update();
432    } else if (state == 1) {
433        jQuery('.upload-step-2, .upload-step-3, .upload-error').hide();
434        jQuery('.upload-step-1').show();
435        jQuery('.upload-step-2 > .headline').html(translate['upload_2_headline']);
436        jQuery('.upload-step-2').removeClass('finished');
437        if (jQuery('.fb-upload .upload-preselect-bar').hasClass('error')) {
438            HidePreselectBar();
439        }
440        jQuery('.fb-upload .error').removeClass('error');
441    } else if (state == 2) {
442        //jQuery('.fancybox-wrap, .fancybox-inner').width(650);
443        jQuery('.upload-step-2').removeClass('finished');
444        jQuery('.upload-step-1').hide();
445        jQuery('.upload-step-2').show();
446        //jQuery.fancybox.update();
447    } else if (state == 3) {
448        jQuery('.upload-step-2').hide();
449        jQuery('.upload-step-3').show();
450        //jQuery.fancybox.update();
451    }
452}
453
454
455function SetUploadProgress(progress) {
456    jQuery('.upload-progress > div').css(
457        'width',
458        progress + '%'
459    );
460    jQuery('.upload-progress div span').text(progress + '%');
461}
462
463
464function SetContactUploadProgress(progress) {
465    jQuery('.contact-upload .loading').css(
466        'width',
467        progress + '%'
468    );
469}
470
471
472function SetUploadData(element) {
473    if (element[0].hasAttribute('data-pid')) {
474        upload_data['pid'] = element.attr('data-pid');
475    }
476    if (element[0].hasAttribute('data-pg')) {
477        upload_data['pg'] = element.attr('data-pg');
478    } else {
479        upload_data['pg'] = 1;
480    }
481    if (element[0].hasAttribute('data-price')) {
482        upload_data['price'] = element.attr('data-price');
483    }
484    if (element[0].hasAttribute('data-delivery')) {
485        upload_data['delivery'] = element.attr('data-delivery');
486    }
487    if (element[0].hasAttribute('data-size')) {
488        upload_data['size'] = element.attr('data-size');
489        if (element[0].hasAttribute('data-price')) {
490            upload_data['text'] = translate['upload_preselect_1'];
491        } else {
492            upload_data['text'] = translate['upload_preselect_2'];
493        }
494        //if (element[0].hasAttribute('data-size-inch') && element.attr('data-size-inch') != '') {
495        if (false) {
496            upload_data['size_inch'] = element.attr('data-size-inch');
497            upload_data['text'] = upload_data['text'].replace('[xxx]</strong>', '[xxx]</strong> ('+upload_data['size']+')');
498            upload_data['text'] = upload_data['text'].replace('[xxx]', upload_data['size_inch']);
499        } else {
500            upload_data['text'] = upload_data['text'].replace('[xxx]', upload_data['size']);
501        }
502        
503        upload_data['text'] = upload_data['text'].replace('[yyy]', priceFormat(upload_data['price'], xLanguage, 'currency'));
504        upload_data['text'] = '<span class="icon-ok green"></span> '+upload_data['text'];
505    }
506    if (element[0].hasAttribute('data-type-group')) {
507        upload_data['type_group'] = element.attr('data-type-group');
508    }
509    if (element[0].hasAttribute('data-code')) {
510        upload_data['code'] = element.attr('data-code');
511    }
512    if (element[0].hasAttribute('data-special')) {
513        upload_data['special'] = element.attr('data-special');
514    }
515    if (element[0].hasAttribute('data-filter')) {
516      upload_data['filter'] = element.attr('data-filter');
517  }
518}
519
520
521function HidePreselectBar() {
522    jQuery('.fancybox-is-open .fb-upload .upload-preselect-bar').removeClass('error').hide();
523}
524
525
526function ShowPreselectBar(error) {
527    if (jQuery('.fb-promotion').is(':visible')) {
528        var preselect_bar = jQuery('.fb-promotion .upload-preselect-bar');
529    } else {
530        var preselect_bar = jQuery('.fancybox-is-open .fb-upload .upload-preselect-bar');
531    }
532                
533    if (upload_data['error'] == 1) {
534        SetUploadState(1);
535        //jQuery.fancybox.update();
536        preselect_bar.addClass('error').html('<span class="icon icon-ok"></span> '+error);
537        upload_data['error'] = 0;
538        preselect_bar.show();
539    } else if (typeof upload_data['size'] != 'undefined') {
540        preselect_bar.removeClass('error').html(upload_data['text']);
541        preselect_bar.show();
542    } else {
543        HidePreselectBar();
544    }
545}

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.