PageSourceSearch

https://mdoks.com/js/core.js

js mdoks.com collected 2026-09-25 23:54:15 UTC 12,791 bytes, 452 lines download raw bytes

1/*
2	Copyright © Eleanor CMS
3	URL: http://eleanor-cms.ru, http://eleanor-cms.su, http://eleanor-cms.com, http://eleanor-cms.net, http://eleanor.su
4	E-mail: [email protected]
5	Developing: Alexander Sunvas*
6	Interface: Rumin Sergey
7	=====
8	*Pseudonym
9*/
10
11var uagent=navigator.userAgent.toLowerCase(),
12	CORE={�	//Настройки�	c_domain:"",
13	c_prefix:"",
14	c_time:"",
15	site_path:"",
16	ajax_file:"",
17
18	//Языки
19	language:"",
20	lang:[],
21	Lang:function(arr,a)
22	{�		if(typeof arr=="string")
23		{
24			var ret=typeof CORE.lang[arr]=="undefined" ? "" : CORE.lang[arr],
25				f=false;
26
27			a=a||[];
28			for(var i in a)
29				ret=ret.replace("{"+i+"}",a[i]);
30			return ret;
31		}
32		else
33		{�			a=a||"";�			for(var i in arr)
34				CORE.lang[a+i]=arr[i];
35		}
36	},
37
38	//Браузер
39	browser:
40	{
41		safari:(uagent.indexOf('safari')!=-1 || navigator.vendor=="Apple Computer, Inc." || uagent.indexOf('konqueror')!=-1 || uagent.indexOf('khtml')!=-1),
42		opera:uagent.indexOf('opera')!=-1,
43		ie:(uagent.indexOf('msie')!=-1 && !this.opera && !this.safari),
44		firefox:uagent.indexOf('firefox')!=-1,
45		chrome:uagent.indexOf('chrome')!=-1
46	},
47�	//Ajax обертка
48	in_ajax:[],
49	after_ajax:[],
50	Ajax:function(arr,func,err)
51	{�		var info={};
52		switch(typeof func)
53		{�			case "function":
54				info.OnSuccess=func;
55			break;
56			case "object":
57				info=func;�		}
58		if(typeof err!="undefined")
59			info.OnFail=err;
60		info=$.extend(
61			{�				OnBegin:function(){ CORE.ShowLoading() },
62				OnEnd:function(){ CORE.HideLoading() },
63				OnSuccess:function(){},
64				OnFail:function(s){ alert(s) }�			},
65			info
66		);
67		CORE.in_ajax.push(true);
68		$.ajax({�			type:"POST",
69			url:CORE.site_path+CORE.ajax_file,
70			data:arr,
71			beforeSend:info.OnBegin,
72			success:function(r)
73			{�				function Soccess()
74				{�					try{info.OnSuccess(r.data)}catch(e){}
75					$.each(r.head,function(i,H){ CORE.AddHead(i,H) });
76				}
77				if(!r || r.error || typeof r.data=="undefined")
78					try{info.OnFail(r.error ? r.error : r||"No data")}catch(e){}
79				else if($.isArray(r.scripts) && r.scripts.length>0)
80					CORE.AddScript(r.scripts,Soccess);
81				else
82					Soccess();
83			},
84			dataType:"json",
85			complete:function(jqXHR,status){�				info.OnEnd(jqXHR,status);
86				CORE.in_ajax.pop();
87				if(CORE.in_ajax.length==0)
88				{
89					var len=CORE.after_ajax.length;
90					$.each(CORE.after_ajax,function(i,F){ try{F()}catch(e){} });
91					CORE.after_ajax.splice(0,len);
92				}�			},
93			error:function(jqXHR,status,error){ try{info.OnFail(error,status,jqXHR)}catch(e){} }
94		});�	},
95	QAjax:function()
96	{�		var a=arguments;�		if(CORE.in_ajax.length)
97			CORE.after_ajax.push(function(){�				CORE.Ajax.apply(CORE,a);�			});
98		else
99			CORE.Ajax.apply(CORE,a);�	},
100	Inputs2object:function(O,ef)//Empty filler
101	{
102		var R={};
103
104		if(O instanceof jQuery)
105		{�			if(O.size()==0)
106				return {};
107			var params={};
108			$.each(O.serializeArray(),function(i,n){
109				params[n.name+"+"+i]=n.value;
110			});
111			O=params;
112		}
113		else if($.isEmptyObject(O))
114			return {};
115
116		$.each(O,function(k,v){�			var emp="",
117				LR=R;
118			k=k.replace(/\+\d+$/,"");
119			$.each(k ? k.replace(/^\[|\]/g,"").split("[") : [],function(kk,vv){�				if(vv=="")
120				{�					emp+="*";
121					if(typeof ef!="object")
122						ef={};
123					if(typeof ef[emp]=="undefined")
124						ef[emp]=0;
125					vv=ef[emp]++;
126				}
127				else
128					emp+=vv+"|";
129
130				if(typeof LR[vv]!="object")
131					LR[vv]={};
132				LR=LR[vv];�			});
133			LR[""]=v;
134		});
135		CORE.NormObj(R);
136		return R;
137	},
138	NormObj:function(O)
139	{�		var i;�		for(i in O)
140			if(typeof O[i][""]!="undefined")
141				O[i]=O[i][""];
142			else if(typeof O[i]=="object")
143				CORE.NormObj(O[i]);
144	},
145
146	loading:"#loading",
147	ShowLoading:function()
148	{�		if(CORE.loading)
149			$(CORE.loading).show().trigger("show");�	},
150	HideLoading:function()
151	{�		if(CORE.loading)
152			$(CORE.loading).hide().trigger("hide");�	},
153
154	//Установка и удаление кук
155	SetCookie:function(name,value,ctime)
156	{
157		var data=new Date();
158		data.setTime(data.getTime()+(ctime ? ctime : CORE.c_time)*1000);
159		document.cookie=escape(CORE.c_prefix+name)+"="+escape(value)+';expires='+data.toGMTString()+";domain="+CORE.c_domain+";path="+CORE.site_path;
160	},
161	GetCookie:function(name)
162	{
163		var res;
164		if(res=document.cookie.match(new RegExp(escape(CORE.c_prefix+name)+"=([^;]+)","i")))
165			return unescape(res[1]);
166		return false;
167	},
168
169	//Переход по страницам
170	JumpToPage:function(result,pages)
171	{
172		var s=prompt(CORE.Lang('page_jump'),'');
173		if(!s || isNaN(s) || (s=parseInt(s))<=0)
174			return;
175		pages=parseInt(pages);
176		if(s>pages)
177			s=pages;
178		if(typeof result=="function")
179			result(s);
180		else
181			window.location.href=result.replace('{page}',s);
182	},
183
184	//Добавляем стиль
185	head:[],//Дополнения в head
186	AddHead:function(key,data)
187	{�		var m=false;�		if(m=key.match(/^[0-9]+$/) || $.inArray(key,CORE.head)!=1)
188		{
189			$("head:first").append(data);
190			if(!m)
191				CORE.head.push(key);
192		}
193	},
194
195	//Загружаемые скрипты
196	scripts:[],
197	AddScript:function(s,func)
198	{�		if(!$.isArray(s))
199			s=[s];
200
201		var num=0,
202			texts={},
203			F=function(){if(s.length==num){�				$.each(s,function(i,n){�					if(texts[i])
204						$.globalEval(texts[i]);�				});
205				if($.isFunction(func))
206					func();�			}};
207		$.each(s,function(i,n){�			if(n && $.inArray(n,CORE.scripts)==-1)
208			{�				if(n.indexOf("://")>0)
209					$.ajax({
210						url:n,
211						success:function(d){
212							CORE.scripts.push(n);
213							texts[i]=false;
214							num++;
215							F();
216						},
217						dataType:"script",
218						async:false,
219						cache:true
220					});
221				else
222					$.get(n,{},function(d){�						CORE.scripts.push(n);�						texts[i]=d;
223						num++;
224						F();�					},"text");�			}
225			else
226			{�				texts[i]=false;
227				num++;
228				F();�			}�		});
229	},
230
231	//Для манипуляции с историей
232	history:false,
233	//Opera bug :-(
234	OB:function(){ if(CORE.browser.opera) with(window.location){ $("head base").prop("href",protocol+"//"+hostname+(port ? ":"+port : "")+CORE.site_path) } },
235	HistoryInit:function(F,data)
236	{�		CORE.history=[];
237		if($.isFunction(F))
238			CORE.history.push(F);
239		else
240			F=false;
241		try
242		{
243			history.replaceState({f:F ? CORE.history.length-1 : false,data:data||false},"",window.location.href);
244			CORE.OB();
245		}catch(e){}
246
247		var OnPop=function(e){�			var st=e.state||false;
248			if(st && st.f!==false && typeof CORE.history[st.f]!="undefined")
249				CORE.history[st.f](st.data);
250		}
251		if(window.addEventListener)
252			window.addEventListener("popstate",OnPop,false);
253		else
254			window.attachEvent("onpopstat",OnPop);
255	},
256	HistoryPush:function(href,F,data)
257	{�		if($.isFunction(F))
258			CORE.history.push(F);
259		else
260			F=false;
261		try
262		{�			history.pushState({f:F ? CORE.history.length-1 : false,data:data||false},"",href);
263			CORE.OB();
264		}catch(e){}�	},
265
266	//MultiSite
267	mssites:[],
268	msisuser:false,
269	msservice:"",
270	MSQueue:1,
271	MSLogin:function(sn)
272	{�		if(CORE.state()!="resolved" || typeof CORE.mssites[sn]=="undefined" || CORE.msisuser)
273			return;
274		var ls=true,
275			Mess=function(r)
276			{
277				//Ни IE, ни Chrome не умеют напрямую принимать объекты... А опере придется страдать из-за этого :(
278				var data=$.parseJSON(r.data);
279				if(data.w=="ms-getlogin")
280					CORE.Ajax(
281						$.extend(
282							data,
283							{�								direct:"mslogin",
284								type:"login",
285								sn:sn,
286								service:CORE.msservice
287							}
288						),
289						{�							OnBegin:function(){ ls=false; },
290							OnSuccess:function(r){�								if(r)
291									window.location.reload();�							}�						}
292					);
293			}
294		if(window.addEventListener)
295			window.addEventListener("message",Mess,false);
296		else
297			window.attachEvent("onmessage",Mess);
298
299		CORE.ShowLoading();
300		var fr=$("<iframe>").prop({
301				src:CORE.mssites[sn].address+"ajax.php?direct=mslogin&type=getlogin&service="+CORE.msservice+(CORE.mssites[sn].secret ? "&secret=1" : ""),
302				style:"display:none"
303			})
304			.css({position:"absolute",left:"-1000px",top:"-1000px"}).width("1px").height("1px")
305			.load(function(){
306				setTimeout(function(){
307					if(window.removeEventListener)
308						window.removeEventListener("message",Mess,false);
309					else
310						window.detachEvent("onmessage",Mess);
311					fr.remove();
312					if(ls)
313						CORE.HideLoading();
314				},1000);
315			}).appendTo("body");
316	},
317	MSJump:function(sn)
318	{�		if(typeof CORE.mssites[sn]=="undefined" || !CORE.msisuser)
319			return false;
320		CORE.Ajax(
321			{�				direct:"mslogin",
322				type:"prejump",
323				sn:sn,
324				service:CORE.msservice�			},
325			function(r)
326			{�				var form=$("<form method=\"post\">").prop("action",r.address+"ajax.php?direct=mslogin&type=jump&service="+CORE.msservice);
327				$.each(r,function(k,v){�					$("<input type=\"hidden\">").prop({�						name:k,
328						value:v�					}).appendTo(form);�				})
329				form.appendTo("body").submit();�			}
330		);
331	}
332},
333EDITOR=
334{
335	active:null,
336	editors:[],
337	Insert:function(text,id)
338	{
339		if(!id)
340			id=this.active;
341		if(id && typeof this.editors[id]=='object' && typeof this.editors[id]['insert']=='function')
342			try
343			{
344				return this.editors[id]['insert'](text);
345			}catch(e){}
346		return false;
347	},
348	GetValue:function(id)
349	{
350		if(!id)
351			id=this.active;
352		if(id && typeof this.editors[id]=='object' && typeof this.editors[id]['getvalue']=='function')
353			try
354			{
355				return this.editors[id]['getvalue']();
356			}catch(e){}
357		return false;
358	},
359	SetValue:function(text,id)
360	{
361		if(!id)
362			id=this.active;
363		if(id && typeof this.editors[id]=='object' && typeof this.editors[id]['setvalue']=='function')
364			return this.editors[id]['setvalue'](text);
365		return false;
366	},
367	ReplaceSelection:function(pre,after,textfunc,id)
368	{
369		if(!id)
370			id=this.active;
371		if(id && typeof this.editors[id]=='object')
372			try
373			{
374				return typeof this.editors[id]['selection']=='function' ? this.editors[id]['selection'](pre,after,textfunc) : this.Insert(pre+after,id);
375			}catch(e){}
376		return false;
377	},
378	//Служебные функции
379	NewEditor:function(id,insert_cb,setvalue_cb,getvalue_cb,insert_selection_cb)
380	{
381		if(!id || typeof insert_cb!='function')
382			return false;
383		this.editors[id]={
384			insert:insert_cb,
385			setvalue:setvalue_cb,
386			getvalue:getvalue_cb,
387			selection:insert_selection_cb
388		};
389		this.active=id;
390		return true;
391	},
392	RemoveEditor:function(id)
393	{
394		if(!id)
395			id=this.active;
396		this.editors[id]=null;
397	},
398	ActivateEditor:function(id)
399	{
400		if(id && typeof this.editors[id]=='object')
401			this.active=id;
402	}
403}
404CORE.MSQueue=$.Deferred();
405$(function(){�	if(CORE.mssites || CORE.msisuser)
406	{�		var n=0,
407			logined=[],
408			Mess=function(r)
409			{�				//Ни IE, ни Chrome не умеют напрямую принимать объекты... А опере придется страдать из-за этого :(�				var data=$.parseJSON(r.data);
410				if(data.w=="ms-check")
411					logined[data.sn]=data.login;�			}
412		if(window.addEventListener)
413			window.addEventListener("message",Mess,false);
414		else
415			window.attachEvent("onmessage",Mess);
416
417		$.each(CORE.mssites,function(sn,site){�			n++;�			var fr=$("<iframe>").prop({�					src:site.address+"ajax.php?direct=mslogin&type=check&service="+CORE.msservice+"&sn="+sn,
418					style:"display:none"
419				})
420				.css({position:"absolute",left:"-1000px",top:"-1000px"}).width("1px").height("1px")
421				.load(function(){�					setTimeout(function(){�						if(--n==0)
422						{�							if(window.removeEventListener)
423								window.removeEventListener("message",Mess,false);
424							else
425								window.detachEvent("onmessage",Mess);�							CORE.MSQueue.resolve(logined);
426						}�						fr.remove();
427					},1000);�				}).appendTo("body");
428		});
429	}
430	else
431		CORE.MSQueue.reject();
432�	//Подсветим активные пункты меню
433	var now="";
434	with(window.location)
435	{
436		now+=protocol+"//"+hostname+(port ? ":"+port : "")+CORE.site_path;
437		now=href.substr(now.length);
438	}
439	$("nav a").filter(function(){�		return $(this).attr("href")==now;�	}).addClass("active");
440
441	//Определим какие скрипты подключены
442	var cut=$("head base").attr("href");
443	$("head script").each(function(){�		if($(this).attr("src"))
444			CORE.scripts.push(this.src.indexOf(cut)==-1 ? this.src : this.src.substr(cut.length));
445	});
446
447	//CTRL + Enter для всех форм
448	$(document).on("keypress","form textarea",function(e){
449		if(e.keyCode==13 && e.ctrlKey)
450			$(this).closest("form").submit();
451	});
452});

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.