PageSourceSearch

https://www.diana-bad.de/_assets/3b77347e6af9894dee9ff78f594b4d2a/JavaScript/FeManager/Femanager.js?1624011862

js diana-bad.de collected 2026-10-04 20:37:51 UTC 5,174 bytes, 177 lines download raw bytes

1jQuery(document).ready(function($) {
2	// javascript validation
3	$('.feManagerValidation').femanagerValidation($);
4
5	// ajax uploader
6	var images = createUploader($);
7	// Store initially present filenames from hidden #image input in data structure
8	if ($('#femanager_field_image').length > 0) {
9		$.each($('#femanager_field_image').val().split(','), function(index, filename) {
10			if(filename.trim().length > 0) {
11				images.addImageName(filename, filename)
12			}
13		});
14	}
15
16	// delete image
17	$('#femanager_field_preview-image').find('.qq-upload-delete').click(function(e) {
18		e.preventDefault();
19
20		var item = $(e.target).parent();
21		// Remove filename from hidden #image input
22		images.deleteImageName(item.find('.qq-upload-file').text());
23
24		item.fadeOut('', function() {
25			$(this).remove();
26		});
27	});
28
29	// confirmation
30	$('*[data-confirm]').click(function(e) {
31		var message = $(this).attr('data-confirm');
32		if (!confirm(message)) {
33			e.preventDefault();
34		}
35	});
36});
37
38/**
39 * Create Fileuploader
40 *
41 * @return object
42 */
43function createUploader($) {
44
45	if ($('#femanager_field_fine-uploader').length == 0) {
46		return;
47	}
48
49	var imageNameHandler = {
50		// Data structure to store image names for Femanager
51		imageNames: {},
52		// Join image names in data structure to be stored in hidden #image input
53		getImageNames: function () {
54			return $.map(this.imageNames, function(item) { return item; } ).join(',');
55		},
56		// Add filename to data structure and hidden #image input
57		addImageName: function(id, filename) {
58			this.imageNames[id] = filename;
59			$('#femanager_field_image').val(this.getImageNames());
60		},
61		// Remove filename from data structure and hidden #image input
62		deleteImageName: function (idToDelete) {
63			delete this.imageNames[idToDelete];
64			$('#femanager_field_image').val(this.getImageNames());
65		}
66	};
67	var uploader = new qq.FineUploader({
68
69		element: document.getElementById('femanager_field_fine-uploader'),
70		request: {
71			endpoint: Femanager.getBaseUrl() + 'index.php?eID=femanagerFileUpload&id=' + $('#femanagerPid').val(),
72			customHeaders: {
73				Accept: 'application/json'
74			}
75		},
76		multiple: true,
77		template: $('.image_container_template:first').html(),
78		fileTemplate: '<li>' +
79			'<div class="qq-progress-bar"></div>' +
80			'<span class="qq-upload-spinner"></span>' +
81			'<span class="qq-upload-finished"></span>' +
82			'<span class="qq-upload-file"></span>' +
83			'<span class="qq-upload-size"></span>' +
84			'<a class="qq-upload-cancel" href="#">{cancelButtonText}</a>' +
85			'<a class="qq-upload-retry" href="#">{retryButtonText}</a>' +
86			'<a class="qq-upload-delete icon-trash" href="#">{deleteButtonText}</a>' +
87			'<span class="qq-upload-status-text">{statusText}</span>' +
88			'</li>',
89		deleteFile: {
90			enabled: true,
91			forceConfirm: true,
92			endpoint: Femanager.getBaseUrl() + 'index.php?eID=femanagerFileDelete&id=' + $('#femanagerPid').val() // TODO delete file on server
93		},
94		classes: {
95			success: 'alert alert-success',
96			fail: 'alert alert-error'
97		},
98		validation: {
99			allowedExtensions: getValueFromField('#uploadFileExtension', 'jpeg, jpg, gif, png, bmp', 'array'), // allowed file extensions
100			sizeLimit: getValueFromField('#uploadSize', 25000000, 'int'), // in bytes
101			itemLimit: getValueFromField('#uploadAmount', 1, 'int') // limit number of uploads
102		},
103		callbacks: {
104			onComplete: function(id, fileName, responseJSON) {
105				if (responseJSON.success) {
106					// show preview image
107					var image = $('<img />')
108						.addClass('fileupload_image')
109						.prop('src', $('#uploadFolder').val() + '/' + responseJSON.uploadName)
110						.prop('alt', responseJSON.uploadName)
111
112					image.appendTo(this.getItemByFileId(id));
113
114					// add filename to Femanager data structure
115					imageNameHandler.addImageName(id, responseJSON.uploadName);
116				}
117			},
118			onDeleteComplete: function(id, xhr, isError) {
119				// Remove filename from Femanager data structure
120				imageNameHandler.deleteImageName(id);
121			}
122		}
123	});
124	return imageNameHandler;
125}
126
127window.Femanager = {};
128
129/**
130 * Get value from a hidden field
131 *
132 * @param selector string
133 * @param fallback mixed
134 * @param mode string ("int", "array")
135 * @returns {*}
136 */
137function getValueFromField(selector, fallback, mode) {
138	var value = fallback;
139	if ($(selector).length) {
140		value = $(selector).val();
141	}
142	if (mode !== undefined) {
143		if (mode === 'int') {
144			value = parseInt(value);
145		} else if (mode === 'array') {
146			value = value.toString();
147			value = value.replace(/[\s,]+/g, ','); // replace " , " to ","
148			value = value.split(',');
149		}
150	}
151	return value;
152}
153
154/**
155 * Return BaseUrl as prefix
156 *
157 * @return string Base Url
158 */
159window.Femanager.getBaseUrl = function() {
160	var baseurl;
161	if (jQuery('base').length > 0) {
162		baseurl = jQuery('base').prop('href');
163	} else if (window.location.hostname.indexOf('localhost') !== -1) {
164		baseurl = '';
165	} else {
166		var port = '';
167		if (window.location.port.length > 0) {
168			port = ':' + window.location.port;
169		}
170		if (window.location.protocol !== "https:") {
171			baseurl = 'http://' + window.location.hostname + port + '/';
172		} else {
173			baseurl = 'https://' + window.location.hostname + port + '/';
174		}
175	}
176	return baseurl;
177};

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.