PageSourceSearch

https://kpkirov.ru/modules/mod_contactus/js/contactus_common.js

js kpkirov.ru collected 2026-09-28 08:44:54 UTC 5,018 bytes, 151 lines download raw bytes

1function contactus_validate(element)
2{
3	var inputs = element.getElementsByClassName("contactus-fields"),
4		errorMessages = element.getElementsByClassName("contactus-error-message");
5	for ( var i = errorMessages.length; i > 0; i-- ) {
6			errorMessages[ i - 1].parentNode.removeChild( errorMessages[ i - 1] );
7			console.log(i);
8		}
9	
10	for (var i = 0; i < inputs.length; i++) {
11		if ((inputs[i].hasAttribute("required")) &&(inputs[i].value.length == 0)) { 
12			event.preventDefault();	
13			parent = inputs[i].parentNode;
14			parent.insertAdjacentHTML( "beforeend", "<div class='contactus-error-message'>" + 
15			   type_field +
16				"</div>" );
17				console.log("ad" + i)
18		}
19	}	
20}
21function joomly_analytics(mod_id){
22	if (contactus_params[mod_id].yandex_metrika_id)
23	{
24		var yaCounter= new Ya.Metrika(contactus_params[mod_id].yandex_metrika_id);
25		yaCounter.reachGoal(contactus_params[mod_id].yandex_metrika_goal);
26	}
27	if (contactus_params[mod_id].google_analytics_category)
28	{
29		ga('send', 'event', contactus_params[mod_id].google_analytics_category, contactus_params[mod_id].google_analytics_action, contactus_params[mod_id].google_analytics_label, contactus_params[mod_id].google_analytics_value);
30	}
31}	
32function contactus_uploader(mod_id){        
33	var input = document.getElementById("file-input" + mod_id);
34	var files = input.files;
35	uploads_counter[mod_id] += files.length;
36	var label = document.getElementById("file-label" + mod_id);
37	var parent = document.getElementById("file-contactus" + mod_id);
38	
39	input.setAttribute("id", "");
40	label.classList.add("contactus-added");
41	
42	new_input = document.createElement("input");
43	new_input.setAttribute("type", "file");
44	new_input.setAttribute("name", "file[]");
45	new_input.setAttribute("multiple", "multiple");
46	new_input.setAttribute("onchange", "contactus_uploader(" + mod_id + ")");
47	new_input.setAttribute("class", "contactus-file");
48	new_input.setAttribute("id", "file-input" + mod_id);
49
50	parent.appendChild(new_input);
51
52	if (uploads_counter[mod_id] > 1)
53	{
54		label.innerHTML = files_added + ": " + uploads_counter[mod_id];   
55	} else
56	{
57		label.innerHTML = input.files[0].name.substr(0,30);
58	}
59}
60function contactus_recaptcha(){
61	var captchas = document.getElementsByClassName("g-recaptcha");
62	for (var i=0; i < captchas.length; i++) {
63		var sitekey = captchas[i].getAttribute("data-sitekey");
64		var size= captchas[i].getAttribute("data-size");
65		if ((captchas[i].innerHTML === "") && (sitekey.length !== 0))
66		{
67			grecaptcha.render(captchas[i], {
68	          'sitekey' : sitekey,
69	          'theme' : 'light',
70	          'size' : size
71	        });		
72		}
73	};
74}
75function getCookie(name) {
76  var matches = document.cookie.match(new RegExp(
77	"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
78  ));
79  return matches ? decodeURIComponent(matches[1]) : undefined;
80}
81function getSendingFlag(m_id){
82	var sendingalert = getCookie("sending-alert"),
83		alerttype = getCookie("alert-type"),
84		sflag = 0;
85		console.log(sendingalert, alerttype);
86	if ((typeof sendingalert !== 'undefined') && (sendingalert == m_id))
87	{
88		al = document.getElementById("contactus-sending-alert" + m_id);
89		if (alerttype == 'success')
90		{
91			sflag = 1;
92		} else if (alerttype == 'captcha')
93		{
94			sflag = 2;
95			al.childNodes[1].style.backgroundColor = "red";
96			al.childNodes[3].childNodes[1].innerHTML = captcha_error;
97		} else if (alerttype == 'file')
98		{
99			sflag = 3;
100			al.childNodes[1].style.backgroundColor = "red";
101			al.childNodes[3].childNodes[1].innerHTML = filesize_error;
102		}
103		document.cookie = 'sending-alert=333; Path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
104		document.cookie = 'alert-type=;Path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
105	} else 
106	{
107		sflag = 0;
108	}	
109	return sflag;
110}
111function remove_alert(lightbox, dimmer)
112{
113	if (lightbox.style.display  != "none")
114	{
115		dimmer.parentNode.removeChild(dimmer);			
116		lightbox.style.display = 'none';
117	}
118}
119function set_dependencys(dependencys)
120{
121	for(var key in dependencys) {
122		var fields = document.getElementsByClassName('field' + key);
123		for (var i=0; i < fields.length; i++) {
124			fields[i].onchange = function(){
125				tag = this.tagName.toLowerCase();
126				element = this;
127				tag = (tag == "input") ? this.type : tag;
128				if (tag == "select")
129				{
130					comparsion = this.selectedIndex;
131				} else if (tag  == "checkbox")
132				{
133					comparsion = (this.checked) ? 1 : 0;
134				} else 
135				{
136					comparsion = this.value;
137				}
138				dependencys[this.getAttribute('data-id')].forEach(function(entry) {
139					if (comparsion == entry.value)
140					{
141						element.parentNode.parentNode.parentNode.getElementsByClassName(entry.child)[0].parentNode.style.display= 'block';
142					} else 
143					{
144						element.parentNode.parentNode.parentNode.getElementsByClassName(entry.child)[0].parentNode.style.display= 'none';
145					}
146				});
147			}
148			fields[i].onchange();
149		}
150	}
151}

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.