PageSourceSearch

https://tripyar.com/js/eleanor_bb.js

js tripyar.com collected 2026-10-02 06:24:10 UTC 8,859 bytes, 417 lines download raw bytes

1/*
2	Copyright © Eleanor CMS
3	URL: http://eleanor-cms.ru, http://eleanor-cms.com
4	E-mail: [email protected]
5	Developing: Alexander Sunvas*
6	Interface: Rumin Sergey
7	=====
8	*Pseudonym. See addons/copyrights/info.txt for more information.
9	=================
10	Based on TextAreaSelectionHelper by Sardar <[email protected]>
11	http://forum.vingrad.ru/forum/topic-35775.html
12	http://forum.vingrad.ru/forum/topic-84449.html
13*/
14var act_editor;
15function EleanorBBEditor(obj,v)
16{�	obj=Id(obj);
17	this.GetSelectedText=function()
18	{
19		return this.iesel ? this.iesel.text : (this.start>=0 && this.end>this.start) ? obj.value.substring(this.start,this.end) : "";
20	}
21
22	this.SetSelectedText=function(text, secondtag)
23	{
24		if(this.iesel)
25		{
26			if(typeof(secondtag)=="string")
27			{
28				var l=this.iesel.text.length;
29				this.iesel.text=text+this.iesel.text+secondtag;
30				this.iesel.moveEnd("character", -secondtag.length);
31				this.iesel.moveStart("character", -l);
32			}
33			else
34				this.iesel.text=text;
35			this.iesel.select();
36		}
37		else if(this.start>=0&&this.end>=this.start)
38		{
39			var left=obj.value.substring(0,this.start);
40			var right=obj.value.substr(this.end);
41			var scont=obj.value.substring(this.start, this.end);
42			if(typeof(secondtag)=="string")
43			{
44				obj.value=left+text+scont+secondtag+right;
45				this.end=obj.selectionEnd=this.start+text.length+scont.length;
46				this.start=obj.selectionStart=this.start+text.length;
47			}
48			else
49			{
50				obj.value=left+text+right;
51				this.end=obj.selectionEnd=this.start+text.length;
52				this.start=obj.selectionStart=this.start+text.length;
53			}
54			obj.scrollTop=this.scroll;
55			obj.focus();
56		}
57		else
58		{
59			obj.value+=text + ((typeof(secondtag)=="string") ? secondtag : "");
60			if(this.scroll>=0)
61				obj.scrollTop=this.scroll;
62		}
63	}
64
65	this.GetText=function()
66	{
67		return obj.value;
68	}
69
70	this.SetText=function(text)
71	{
72		obj.value=text;
73	}
74
75	this.TextAreaEvent=function()
76	{
77		act_editor=this.carretHandler;
78		EDITOR.ActivateEditor(this.id);
79		if(document.selection)
80			this.carretHandler.iesel = document.selection.createRange().duplicate();
81		else if(typeof(this.selectionStart)!="undefined")
82		{
83			this.carretHandler.start=this.selectionStart;
84			this.carretHandler.end=this.selectionEnd;
85			this.carretHandler.scroll=this.scrollTop;
86		}
87		else
88			this.carretHandler.start=this.carretHandler.end=-1;
89	}
90
91	this.Bold=function()
92	{�		this.SetSelectedText("[b]","[/b]");
93		return false;
94	}
95
96	this.Strike=function()
97	{
98		this.SetSelectedText("[s]","[/s]");
99		return false;
100	}
101
102	this.Italic=function()
103	{
104		this.SetSelectedText("[i]","[/i]");
105		return false;
106	}
107
108	this.Li=function()
109	{
110		this.SetSelectedText("[*]");
111		return false;
112	}
113
114	this.Ol=function()
115	{
116		this.SetSelectedText("[ol]\r[*]\r[*]\r[*]\r","[/ol]");
117		return false;
118	}
119
120	this.Ul=function()
121	{
122		this.SetSelectedText("[ul]\r[*]\r[*]\r[*]\r","[/ul]");
123		return false;
124	}
125
126	this.UnderLine=function()
127	{
128		this.SetSelectedText("[u]","[/u]");
129		return false;
130	}
131
132	this.Hr=function()
133	{
134		this.SetSelectedText("[hr]");
135		return false;
136	}
137
138	this.Tab=function()
139	{
140		this.SetSelectedText("\t");
141		return false;
142	}
143
144	this.Left=function()
145	{
146		this.SetSelectedText("[left]","[/left]");
147		return false;
148	}
149
150	this.Right=function()
151	{
152		this.SetSelectedText("[right]","[/right]");
153		return false;
154	}
155
156	this.Center=function()
157	{
158		this.SetSelectedText("[center]","[/center]");
159		return false;
160	}
161
162	this.Justify=function()
163	{
164		this.SetSelectedText("[justify]","[/justify]");
165		return false;
166	}
167
168	this.C=function()
169	{
170		this.SetSelectedText("[c]");
171		return false;
172	}
173
174	this.R=function()
175	{
176		this.SetSelectedText("[r]");
177		return false;
178	}
179
180	this.Nobb=function()
181	{
182		this.SetSelectedText("[nobb]","[/nobb]");
183		return false;
184	}
185
186	this.Tm=function()
187	{
188		this.SetSelectedText("[tm]");
189		return false;
190	}
191
192	this.Url=function()
193	{
194		var text = this.GetSelectedText();
195		var link = prompt(el_lang['enter_adress'],"http://");
196		if (link==null)
197			return false;
198		text = prompt(el_lang['link_text'],text);
199		if (text==null)
200			return false;
201		this.SetSelectedText("[url="+link+"]"+text+"[/url]");
202		return false;
203	}
204
205	this.Img=function()
206	{
207		var link = this.GetSelectedText();
208		if (!link)
209			link = prompt(el_lang['enter_image_addr'],link);
210		if (link==null)
211			return false;
212		this.SetSelectedText("[img]"+link+"[/img]");
213		return false;
214	}
215
216	this.Mail=function()
217	{
218		var link=this.GetSelectedText();
219		var link=prompt(el_lang['enter_adress'],link);
220		if (link==null)
221			return false;
222		if (!IsEmail(link) && !confirm(el_lang['wrong_email']))
223			return this.Mail();
224		text=prompt(el_lang['link_text'],link);
225		if (text==null)
226			return false;
227		this.SetSelectedText("[email="+link+"]"+text+"[/email]");
228		return false;
229	}
230
231	this.Color=function(cn)
232	{�		if (!cn)
233			return false;
234		this.SetSelectedText("[color="+cn+"]","[/color]");
235	}
236
237	this.BackGround=function(cn)
238	{
239		if (!cn)
240			return false;
241		this.SetSelectedText("[background="+cn+"]","[/background]");
242	}
243
244	this.Size=function(s)
245	{
246		if (!s)
247			return false;
248		this.SetSelectedText("[size="+s+"]","[/size]");
249	}
250
251	this.Font=function(s)
252	{
253		if (!s)
254			return false;
255		this.SetSelectedText("[font="+s+"]","[/font]");
256	}
257
258
259	this.Plus=function()
260	{�		obj.rows+=5;�		return false;
261	}
262
263	this.Minus=function()
264	{�		if (obj.rows>=10)
265			obj.rows-=5;�		return false;
266	}
267
268	this.Preview=function()
269	{�		var area=Id('prev_'+v);
270		Ajax(
271			'-1',
272			{�				'type':'bbpreview',
273				'service':EDITOR.serid,
274				'text':this.GetText(),
275				'key':v
276			},
277			function(result)
278			{�				$(area).html(result).show();
279			},
280			false
281		);
282		return false;�	}
283
284	this.HidePrev=function()
285	{�		$('#prev_'+v).hide();�	}
286
287	obj.carretHandler=this;
288	obj.onchange=obj.onclick=obj.onkeyup=obj.onfocus=this.TextAreaEvent;
289	if(!document.selection)
290		obj.onSelect=this.TextAreaEvent;
291	this.start=-1;
292	this.end=-1;
293	this.scroll=-1;
294	this.iesel=null;
295	EDITOR.NewEditor(
296						obj.id,
297						function(text)
298						{�							if(text.indexOf('][/')==-1)�								obj.carretHandler.SetSelectedText(text);
299							else
300							{�								var arr=text.split('][/');�								obj.carretHandler.SetSelectedText(arr[0]+']','[/'+arr[1]);�							}
301						},
302						function(text){obj.value=text},
303						function(){return obj.value}
304	);
305}
306
307function HotKeyHandler(ev)
308{
309	var evt, key;
310	if(!(evt=ev ? ev : window.event))
311		return;
312	key = evt.keyCode ? evt.keyCode : evt.charCode;
313	key=HotKeyHandler.convertIEKey[String(key)] ? HotKeyHandler.convertIEKey[String(key)] : key;
314	if (evt && evt.ctrlKey)
315	{�		key=evt.shiftKey ? String.fromCharCode(key).toUpperCase() : String.fromCharCode(key).toLowerCase();
316		if(typeof(HotKeyHandler.keys[key]) == "function")
317		{
318			HotKeyHandler.keys[key](evt);
319			evt.cancelBubble = true;
320			evt.returnValue = false;
321			if(evt.preventDefault)
322				evt.preventDefault();
323			if(evt.stopPropagation)
324				evt.stopPropagation();
325			return false;
326		}
327	}
328	return true;
329}
330
331HotKeyHandler.WindowInit=function()
332{�	if(document.addEventListener && (GetOperaVersion()>6||GetOperaVersion()==0))
333		document.addEventListener("keypress", HotKeyHandler, false);
334	else
335		document.onkeydown = HotKeyHandler;
336}
337HotKeyHandler.convertIEKey={"1":65,"2":66,"4":68,"12":76,"16":80,"19":83,"20":84,"21":85,"26":90};
338HotKeyHandler.keys = {
339	"b":function()
340	{
341		if (act_editor)
342			act_editor.Bold();
343	},
344	"i":function()
345	{
346		if (act_editor)
347			act_editor.Italic();
348	},
349	"u":function()
350	{
351		if (act_editor)
352			act_editor.UnderLine();
353	},
354	"t":function()
355	{
356		if (act_editor)
357			act_editor.Tab();
358	},
359	"l":function()
360	{
361		if (act_editor)
362			act_editor.Url();
363	},
364	"e":function()
365	{
366		if (act_editor)
367			act_editor.Mail();
368	},
369	"I":function()
370	{
371		if (act_editor)
372			act_editor.Img();
373	},
374	"S":function()
375	{
376		if (act_editor)
377			act_editor.Srike();
378	},
379	"L":function()
380	{
381		if (act_editor)
382			act_editor.Left();
383	},
384	"M":function()
385	{
386		if (act_editor)
387			act_editor.Center();
388	},
389	"R":function()
390	{
391		if (act_editor)
392			act_editor.Right();
393	},
394	"J":function()
395	{
396		if (act_editor)
397			act_editor.Justify();
398	},
399	"h":function()
400	{
401		if (act_editor)
402			act_editor.Hr();
403	}
404};
405HotKeyHandler.WindowInit();
406
407function IsEmail(C)
408{
409	var A=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"),B=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
410	return(!A.test(C) && B.test(C))
411};
412
413function GetOperaVersion()
414{
415	var opver=navigator.userAgent.match(/Opera\s*([0-9.]+)/i);
416	return (opver && opver.length>1) ? parseFloat(opver[1]) : 0;
417}

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.