PageSourceSearch

https://coral-squirrel-627945.hostingersite.com/wp-content/plugins…/js/admin/customServiceCategory.js?ver=10.5

js coral-squirrel-627945.hostingersite.com collected 2026-10-03 04:15:21 UTC 3,721 bytes, 115 lines download raw bytes

1jQuery(function ($) {
2    var addingTerm = false;
3
4    sln_categoryLogo($);
5    
6    function sln_categorySend(e){
7        e.preventDefault();
8        e.stopPropagation();
9		var form = $(this).parents('form');
10
11		if ( addingTerm ) {
12			// If we're adding a term, noop the button to avoid duplicate requests.
13			return false;
14		}
15
16		addingTerm = true;
17		form.find( '.submit .spinner' ).addClass( 'is-active' );
18
19		/**
20		 * Does a request to the server to add a new term to the database
21		 *
22		 * @param {string} r The response from the server.
23		 *
24		 * @return {void}
25		 */
26		let serializeArray = $('#addtag').serializeArray();
27        let form_data = new FormData();
28        serializeArray.forEach(function(e){form_data.append(e['name'], e['value'])})
29		$('input[type="file"]').each(function(){form_data.append(this.name, $(this)[0].files[0])});
30		$.ajax({
31            url: ajaxurl,
32            data: form_data, 
33            contentType: false,
34            processData: false,
35            type: 'POST',
36            success: function(r){
37			var res, parent, term, indent, i;
38
39			addingTerm = false;
40			form.find( '.submit .spinner' ).removeClass( 'is-active' );
41
42			$('#ajax-response').empty();
43			res = wpAjax.parseAjaxResponse( r, 'ajax-response' );
44
45			if ( res.errors && res.responses[0].errors[0].code === 'empty_term_name' ) {
46				validateForm( form );
47			}
48
49			if ( ! res || res.errors ) {
50				return;
51			}
52
53			parent = form.find( 'select#parent' ).val();
54
55			// If the parent exists on this page, insert it below. Else insert it at the top of the list.
56			if ( parent > 0 && $('#tag-' + parent ).length > 0 ) {
57				// As the parent exists, insert the version with - - - prefixed.
58				$( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents );
59			} else {
60				// As the parent is not visible, insert the version with Parent - Child - ThisTerm.
61				$( '.tags' ).prepend( res.responses[0].supplemental.parents );
62			}
63
64			$('.tags .no-items').remove();
65
66			if ( form.find('select#parent') ) {
67				// Parents field exists, Add new term to the list.
68				term = res.responses[1].supplemental;
69
70				// Create an indent for the Parent field.
71				indent = '';
72				for ( i = 0; i < res.responses[1].position; i++ )
73					indent += '&nbsp;&nbsp;&nbsp;';
74
75				form.find( 'select#parent option:selected' ).after( '<option value="' + term.term_id + '">' + indent + term.name + '</option>' );
76			}
77
78			$('input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):visible, textarea:visible', form).val('');
79		}
80        });
81
82		return false;
83	}
84    setTimeout(function(){$('#addtag #submit').off('click').on( 'click', sln_categorySend)}, 1);
85
86});
87
88function sln_categoryLogo($) {
89    $("[data-action=select-logo]").on("click", function() {
90        $("#" + $(this).attr("data-target")).trigger("click");
91    });
92
93    $("[data-action=select-file-logo]").on("change", function() {
94        $(this)
95            .closest("form")
96            .find("input:first")
97            .trigger("click");
98            var reader = new FileReader();
99
100        reader.onload = function (e) {
101            $("#logo img").attr("src", e.target.result);
102        }
103        reader.readAsDataURL(this.files[0]);
104        $("#logo img").attr("src", $(this).val());
105        $("#" + $(this).attr("data-target")).val($(this).val());
106        $('#logo').removeClass('hide');
107        $('#select_logo').addClass('hide');
108    });
109
110    $("[data-action=delete-logo]").on("click", function() {
111        $("#" + $(this).attr("data-target-reset")).val("");
112        $("#" + $(this).attr("data-target-show")).removeClass("hide");
113        $("#" + $(this).attr("data-target-remove")).addClass('hide');
114    });
115}

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.