PageSourceSearch

https://www.vardnica.lv/j/j.js?1790247302

js vardnica.lv collected 2026-09-25 10:31:02 UTC 5,672 bytes, 258 lines download raw bytes

1base = {
2	go: function(url) {
3		window.location = url;
4	}
5};
6
7
8
9// ---------------
10
11var comments = {};
12comment = {
13	init: function(dt)
14	{
15		//dt.data=[];
16		comments[dt.id] = dt;
17		$('button[name="comment"]').click(function() {
18			
19			if (!comment.valid(dt)) return;
20
21			var form = $(this).closest('form');
22			var id = form.attr('rel');
23			var data = $(form).serializeArray();
24
25			//data[100] = {};
26			data.push({'name':'dt','value':JSON.stringify(dt)});
27			
28			
29			$('div#'+id+' div.list').load(
30				  dt.url,
31				  data,
32				  function() {
33					  
34					  // Clear form elements
35					  $('div#'+id+' form[rel='+id+'] :input').each(function() {
36					  var type = this.type;
37					  var tag = this.tagName.toLowerCase();
38
39					  if (type == 'text' || tag == 'textarea')
40						this.value = '';
41					  });
42					  
43					  // Make inserted comment more visible
44					  var speed = 'normal';
45					  $('div#'+id+' div.list ul li:first').fadeTo(speed, 0.3, function() {
46						  	$(this).css('background','#E1FFDF');
47					        $(this).fadeTo(speed, 1, function(){$(this).fadeTo(speed, 0.3,function(){
48					        	$(this).fadeTo(speed, 1);
49					        	
50					        });});
51					  });
52					  
53				  }
54				);
55			
56		});
57	},
58	
59	valid: function (dt)
60	{
61		var name = $('div#'+dt.id+' input[name=author]').val();
62		var text = $('div#'+dt.id+' textarea[name=text]').val();
63		
64		if (name=='') 
65		{
66			$('div#'+dt.id+' input[name=author]').focus();
67			$('div#'+dt.id+' input[name=author]').css('background', '#FFDFDF');
68			return false;			
69		}	
70		if (text=='')
71		{
72			$('div#'+dt.id+' textarea[name=text]').focus();
73			$('div#'+dt.id+' textarea[name=text]').css('background', '#FFDFDF');
74			$('div#'+dt.id+' textarea[textarea=text]').css('border', 'solid 1px #000');
75			return false;
76		}	
77		
78		return true;
79	}
80};
81
82
83var rates = {};
84rate = {
85	init: function(dt)
86	{
87		// dt.id : unique id - string
88		// dt.url : ajax url
89		rates[dt.id] = dt;
90		
91		$('#' + dt.id).stars({
92			
93			oneVoteOnly: true,
94			callback: function(ui, type, value){
95				dt.value = value;
96				rate.vote(dt);
97			}
98		}); 
99		
100		//debug(rates[dt.id]);
101	},
102	
103	vote: function(dt)
104	{
105		$.ajax({
106		  url: dt.url,
107		  dataType: 'json',
108		  data: dt,
109		  success: function(data) {
110		    //$('.result').html(data);
111		    rate.parse(data);
112		  }
113		});
114		
115	},
116	
117	parse: function(dt)
118	{
119		$('#'+dt.id).stars('select', Math.round(dt.avg));
120		var text = dt.avg+' ('+dt.quantity+')';
121		$('#'+dt.id+' span').html(text);
122		//debug(dt);
123	}
124		
125};
126
127
128versioning = {
129init: function()
130{
131	$('div.versioning').click(function(){
132		//alert($(this).css('display'));
133		if ($('div.editor').css('display')=='none')
134		{	
135			$('div.editor').slideDown('normal');
136			base.go('#frm_versioning');
137		}
138		else
139		{
140			$('div.editor').slideUp('normal');
141		}		
142	});
143
144	$('button.versioning').click(function(){
145		//alert($(this).css('display'));
146		if ($('div.editor').css('display')=='none')
147		{	
148			$('div.editor').slideDown('normal');
149			base.go('#frm_versioning');
150		}
151		else
152		{
153			$('div.editor').slideUp('normal');
154		}		
155	});
156},
157
158valid: function (OBJECT_ID)
159{
160	if (versioning.validate(OBJECT_ID)==true)
161	{
162		versioning.ajax(OBJECT_ID);
163	}
164},
165
166validate: function()
167{
168	$('div.editor [rel=frm]').each(function(){
169		var val = $.trim($(this).val());
170		if (val == '')
171		{	
172			$(this).focus();
173			$(this).css('background','#FFBFBF');
174			return false;
175		}
176		else
177		{
178			$(this).css('background','#F0FFEF');
179		}				
180	});
181	return true;
182},
183
184ajax: function(OBJECT_ID)
185{
186	var data = $('#frm_versioning').serializeArray();
187	$.ajax({type: "POST",  
188		url: "/ajax.php?object_id="+OBJECT_ID+"&cmd=user_modify",  
189		'data': data,  
190		success:function(d)
191		{
192			if (d==1)
193			{
194				alert('Informacija sėkmingai išiųsta peržiūrai.');
195				$('div.editor').slideUp('normal');
196				$('div.versioning').fadeOut('slow');
197			}
198			else
199			{
200				alert('Informacija negali būti nusiųsta. \r\n1. Patikrinkite ar teisingai suvestas saugos kodas.\r\n2. Nepadarėte jokių pakeitimų.');
201				}	
202			}
203		});
204	}
205};
206
207
208
209/* ------------------------
210// Cookies methods found on w3schools - We need them to not annoy our visitors
211// https://www.w3schools.com/js/js_cookies.asp
212// ------------------------*/
213function setCookie(cname, cvalue, exdays) {
214   var d = new Date();
215   d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
216   var expires = "expires=" + d.toUTCString();
217   document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
218};
219
220function getCookie(cname) {
221   var name = cname + "=";
222   var decodedCookie = decodeURIComponent(document.cookie);
223   var ca = decodedCookie.split(";");
224   for (var i = 0; i < ca.length; i++) {
225       var c = ca[i];
226       while (c.charAt(0) == " ") {
227           c = c.substring(1);
228       }
229       if (c.indexOf(name) == 0) {
230           return c.substring(name.length, c.length);
231       }
232   }
233   return "";
234};
235
236
237//---- document.ready --------------------------------------
238$(document).ready(function(){
239
240	// versioning init
241	//versioning.init();
242
243    if ( typeof commentData != 'undefined' ) {
244        comment.init( commentData );
245    }
246
247});
248
249//2019-01-17
250//$('ul[role=tablist] li.active').removeClass('active').find('a').tab( 'show' );
251//$('.nav-pills, .nav-tabs').tabdrop( {text:'Citi produkti'} );
252
253
254
255
256function debug(o){var s=null;for(p in o)s+=p+' - '+o[p]+'\r\n';alert(s);};
257
258function is_mobile() {try{ document.createEvent("TouchEvent"); return true; } catch(e){ return false; }};

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.