PageSourceSearch

https://www.cargo.lt/java/chat.js?v=1.0.4

js cargo.lt collected 2026-10-02 12:11:45 UTC 10,299 bytes, 414 lines download raw bytes

1var oXmlHttp7 = null;
2var chatInterval = 22000;
3
4var sChatTimer=null;
5var chat_info={type:-1,search:"",update:0,region:0};
6var chat_messages=new Array();
7chat_messages[0]=new Array("","","","");
8function cfm_get_chat(sType,sName)
9{
10	var sType=(sType)?sType:0;
11	var sName=(sName)?sName:"";
12
13	if(sType!=chat_info["type"])
14	{
15		//сброс
16		if(sType<4)
17		{
18			document.getElementsByName("CHAT_SEARCH")[0].value="";
19			replace_placeholder(1,"CHAT_SEARCH",0,langs["622"],0);
20		}
21	}
22
23	sObj=document.getElementsByName("chat_history");
24	for(var i=0;i<sObj.length;i++)
25	{
26		var sAction=(i==sType)?"add":"";
27		toggle_class_value("chat_history",i,1,"selected",sAction);
28	}
29
30	if(sType==0&&chat_info["type"]>0)
31	{
32		chat_messages[chat_info["region"]][0]="";
33	}
34	else if(sType==4&&chat_info["search"]!=sName)
35	{
36		chat_messages[chat_info["region"]][4]="";
37	}
38
39	chat_info["type"]=sType;
40	chat_info["search"]=sName;
41
42	if(chat_info["type"]>0)
43	{
44		clearTimeout(sChatTimer);
45	}
46	else
47	{
48		chat_info["update"]=(chat_messages[chat_info["region"]][0]=="")?0:1;
49	}
50
51	if(chat_messages[chat_info["region"]][chat_info["type"]]==""||chat_info["type"]==0)
52	{
53		get_chat_messages();
54	}
55	else
56	{
57		parse_chat_messages();
58	}
59
60	return;
61}
62
63function get_chat_messages() 
64{
65    if (!oXmlHttp7) {
66        oXmlHttp7 = zXmlHttp.createRequest();
67    } else if (oXmlHttp7.readyState != 0) {
68        oXmlHttp7.abort();
69    }
70
71	var sName=encodeURIComponent(chat_info["search"]);
72
73    oXmlHttp7.open("get", "../asp/chat_funcs.asp?NUM=1&ACTION="+chat_info["type"]+"&NAME="+sName+"&CHAT="+chat_info["update"]+"&IDR="+chat_info["region"], true);
74    oXmlHttp7.onreadystatechange = function () {               
75        
76        if (oXmlHttp7.readyState == 4) {
77            if (oXmlHttp7.status == 200) 
78		{
79			var sInfo = oXmlHttp7.responseText;
80			if(sInfo!="")
81			{
82				chat_messages[chat_info["region"]][chat_info["type"]]=sInfo;
83				parse_chat_messages();
84			}
85			if(chat_info["type"]==0)
86			{
87				sChatTimer=setTimeout(cfm_get_chat, chatInterval);             
88			}
89            }                         
90        }
91    };
92
93    oXmlHttp7.send(null);       
94}
95
96function parse_chat_messages()
97{
98	var messages=JSON.parse(chat_messages[chat_info["region"]][chat_info["type"]]);
99
100	if(messages["update"]=="Y")
101	{
102		//accounts
103		var accounts=new Array();
104		for(var i=0;i<messages["accounts"].length;i++)
105		{
106			var account=messages["accounts"][i];
107			accounts[account["id"]]={name:account["name"],idc:account["idc"],company:account["company"],phone:account["phone"],icq:account["icq"],skype:account["skype"],status:account["status"]};
108		}
109
110		var list=document.getElementById("chat_messages");
111		list.innerHTML="";
112
113		var sHeight=(chat_info["type"]==0)?"":(document.body.clientHeight-150)+"px";
114		var sOverflow=(chat_info["type"]==0)?"":"auto";
115		list.style.maxHeight=sHeight;
116		list.style.overflow=sOverflow;
117
118		if(chat_info["type"]==4)
119		{
120			var re = new RegExp("(\\w*|\\s*)("+chat_info["search"]+")(\\w*|\\s*)", "ig");
121		}
122
123		for(i=0;i<messages["messages"].length;i++)
124		{
125			msg=messages["messages"][i];
126			sColor=(msg["diff"]==1)?"black":"dimgray";
127
128			newDIV=document.createElement("DIV");
129			newDIV.setAttribute("id","cm_"+msg["id"]);
130			newDIV.style.color=sColor;
131
132			var account=accounts[msg["account"]];
133	
134			account["name"]=check_search(account["name"]);
135			account["company"]=check_search(account["company"]);
136
137			var sNewElPrms='{"user":"'+sUser+'","id":"'+msg["account"]+'","name":"'+account["name"]+'","status":"'+account["status"]+'","access":"'+messages["access"]["read"]+'"}';
138			var sAccount=generate_fields("account_info",sNewElPrms);
139
140			var sNewElPrms='{"id":"'+account["idc"]+'","name":"'+account["company"]+'","access":"'+messages["access"]["read"]+'"}';
141			var sCompanyInfo=generate_fields("company_name",sNewElPrms);
142
143			var sText=msg["time"]+" "+sAccount+", "+sCompanyInfo;
144
145			newDIV1=document.createElement("DIV");
146			newDIV1.setAttribute("id","cm_contact_"+msg["id"]);
147			newDIV1.setAttribute("class","chat_name");
148			newDIV1.innerHTML=sText+" <a href='#' id='translate=chat-_"+msg["id"]+"' onclick='google_translation_start(\"chat\",this.id); return false;' class='img_button img_right img_translate' title='Перевести'></a>";
149
150			sText=check_search(msg["message"]);
151			if(messages["admin"]>-1)
152			{
153				sText+=" <a href='#' onclick='deletemessage(84,"+msg["id"]+");return false;'><img src='../images/del.gif' id='icon' alt='Удалить сообщение' title='Удалить сообщение'></a>";
154			}
155
156			newDIV2=document.createElement("DIV");
157			newDIV2.innerHTML=sText;
158
159			newDIV.appendChild(newDIV1);
160			newDIV.appendChild(newDIV2);
161
162			list.appendChild(newDIV);
163		}
164	}
165
166	return;
167}
168
169function check_search(sValue)
170{
171	if(chat_info["type"]==4)
172	{
173		var re = new RegExp("(\\w*|\\s*)("+chat_info["search"]+")(\\w*|\\s*)", "ig");
174		sValue=sValue.replace(re, "$1<span class='updates'>$2</span>$3");
175	}
176
177	return sValue;
178}
179
180function change_chat_region(sIDR)
181{
182	if(sIDR!=chat_info["region"]!=sIDR)
183	{
184		if(typeof(chat_messages[sIDR])=="undefined")
185		{
186			chat_messages[sIDR]=new Array("","","","");
187		}
188
189		var sIDRX=(sIDR==0)?sIDR:1;
190		var sObj=document.getElementsByName("chat_regs");
191		for(var i=0;i<sObj.length;i++)
192		{
193			var sBold=(i==sIDRX)?"bold":"";
194			sObj[i].style.fontWeight=sBold;
195		}
196
197		var sIDX=-1;
198		var sObj=document.getElementsByName("CHAT_REG");
199		for(var i=0;i<sObj.length;i++)
200		{
201			if(sObj[i].value==sIDR)
202			{
203				sIDX=i;
204				break;
205			}
206		}
207		sObj[i].setAttribute("checked","checked");
208
209		//в cookie
210		set_cookie("chat_reg",sIDR);
211
212		chat_info["region"]=sIDR;
213		clearTimeout(sChatTimer);
214		cfm_get_chat();
215	}
216
217	return;
218}
219
220function cfm_message_chat()
221{
222	var fields=new Array();
223	fields.push('{"field":"CHAT_NOTES","id":"0","checked":{"isnot":""}}');
224
225	replace_placeholder(1,"CHAT_NOTES",0,langs["2948"],1);
226
227	var sForm=0;
228	var sFormCheck=1;
229	for(var i=0;i<fields.length;i++)
230	{
231		sResult=validate_field(fields[i]);
232		if(sResult==0&&sForm==0)
233		{
234			sFormCheck=0;
235			sForm=1;
236		}
237	}
238
239	if(sFormCheck==1)
240	{
241		document.getElementById("CHAT_SAVE").disabled=true;
242		save_message_chat();
243	}
244
245	return;
246}
247
248function save_message_chat()
249{
250    if (!oXmlHttp7) {
251        oXmlHttp7 = zXmlHttp.createRequest();
252    } else if (oXmlHttp7.readyState != 0) {
253        oXmlHttp7.abort();
254    }    
255    
256	sNotes=document.getElementsByName("CHAT_NOTES")[0].value;
257	sNotes=encodeURIComponent(sNotes);
258
259    oXmlHttp7.open("get", "../asp/chat_funcs.asp?NUM=3&NOTES="+sNotes, true);
260    oXmlHttp7.onreadystatechange = function () 
261	{               
262        if (oXmlHttp7.readyState == 4) 
263	{
264            if (oXmlHttp7.status == 200) 
265		{
266			var sInfo = oXmlHttp7.responseText;
267			if(sInfo!="")
268			{
269				document.getElementsByName("CHAT_NOTES")[0].value="";
270				replace_placeholder(1,"CHAT_NOTES",0,langs["2948"],2);
271				document.getElementById("CHAT_SAVE").disabled=false;
272
273				set_myoffers_total(sInfo);
274
275				clearTimeout(sChatTimer);
276				cfm_get_chat(0);
277			}
278            }                         
279        }
280    };
281    oXmlHttp7.send(null); 
282}
283
284var sChatSearchTimer=null;
285function chat_search(sValue)
286{
287	clearTimeout(sChatSearchTimer);
288	if(sValue.length>2)
289	{
290		sChatSearchTimer=setTimeout("cfm_get_chat(4,'"+sValue+"')", 300); 
291	}
292	else if(sValue.length==0)
293	{
294		cfm_get_chat(0);
295		replace_placeholder(1,"CHAT_SEARCH",0,langs["622"],1);
296	}
297
298	return;
299}
300
301function deletemessage(sNum,sID)
302{
303
304notes=new Array();
305notes[84]="Сообщение из чата будет удалено.";
306
307a=confirm(notes[sNum]+" Вы уверены?");
308if(a==true)
309{
310
311    if (!oXmlHttp7) {
312        oXmlHttp7 = zXmlHttp.createRequest();
313    } else if (oXmlHttp7.readyState != 0) {
314        oXmlHttp7.abort();
315    }    
316	oXmlHttp7.open("get", "../manage/ajax_funcs_ru.asp?NUM="+sNum+"&ID="+sID, true);
317	oXmlHttp7.onreadystatechange = function () 
318	{               
319        if (oXmlHttp7.readyState == 4) 
320	{
321            if (oXmlHttp7.status == 200) 
322		{
323			var sInfo = oXmlHttp7.responseText;
324
325			clearTimeout(sChatTimer);
326			cfm_get_chat(0);
327            }                         
328        }
329    };
330    oXmlHttp7.send(null); 
331}
332}
333
334function open_msg()
335{
336	document.getElementById("chatmsg").style.display="block";
337	if(document.Reg5)
338	{
339		document.getElementById("CHATSAVE").disabled=false;
340		document.Reg5.NOTES.focus();
341	}
342
343	return;
344}
345
346function select_chat(sID)
347{
348	var sObj=document.getElementsByName("CHAT_REG")[1];
349	sObj.value=domains[sID]["region"];
350	sObj.checked=true;
351	
352	document.getElementById("chat_reg_name").innerHTML=domains[sID]["name"];
353
354	change_chat_region(domains[sID]["region"]);
355	toggle_manage_window("CHATS");
356
357	return;
358}
359
360var sChatRegID="";
361var sChatRegDef=0;
362function start_chat()
363{
364	if(document.getElementsByName("CHAT_REG").length>0)
365	{
366		var sChatReg=get_cookies("chat_reg");
367		sChatRegDef=(sChatReg)?sChatReg:0;
368		sChatRegID=(sChatRegDef==0)?-1:sChatReg;
369
370		chat_info["region"]=-1;
371		chat_info["type"]=0;
372
373		get_chat_domain();
374	}
375	else
376	{
377		cfm_get_chat(0);
378	}
379
380	return;
381}
382
383function get_chat_domain() 
384{
385    if (!oXmlHttp7) {
386        oXmlHttp7 = zXmlHttp.createRequest();
387    } else if (oXmlHttp7.readyState != 0) {
388        oXmlHttp7.abort();
389    }
390
391    oXmlHttp7.open("get", "../asp/ajax_funcs_ru.asp?NUM=6&IDR="+sChatRegID, true);
392    oXmlHttp7.onreadystatechange = function () {               
393        
394        if (oXmlHttp7.readyState == 4) {
395            if (oXmlHttp7.status == 200) 
396		{
397			var sInfo = oXmlHttp7.responseText;
398			if(sInfo!="")
399			{
400				var parts=JSON.parse(sInfo);
401				
402				var sObj=document.getElementsByName("CHAT_REG")[1];
403				sObj.value=parts["domains"][0]["region"];
404				document.getElementById("chat_reg_name").innerHTML=parts["domains"][0]["name"];
405
406				var sChatReg=(sChatRegDef==0)?sChatRegDef:parts["domains"][0]["region"];
407				change_chat_region(sChatReg);
408			}
409            }                         
410        }
411    };
412
413    oXmlHttp7.send(null);       
414}

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.