PageSourceSearch

http://neuro-online.ru/core/js/common.js

js neuro-online.ru collected 2026-09-24 23:05:25 UTC 12,581 bytes, 346 lines download raw bytes

1//
2// Core js class
3// @author [AM]
4//
5(function($) {
6  core = {
7    verticalOffset: -390,
8    horizontalOffset: 0,
9    repositionOnResize: true,
10    overlayOpacity: 0.2,
11    overlayColor: '#ffffff',
12    draggable: true,
13    send: 'Отправить',
14    ok: 'Продолжить',
15    close: 'Закрыть',
16    save: 'Сохранить',
17    cancel: 'Отмена',
18    dialogClass: null,
19    alert: function(message, title, callback) {
20      if( title == null ) title = 'Alert';
21      this._show_mess(title, message, null, 'alert', function(result) {
22        if(callback) callback(result);
23      });
24    },
25    confirm: function(message, title, callback) {
26      if(title == null) title = 'Подтверждение действия';
27        this._show_mess(title, message, null, 'confirm', function(result) {
28          if(result) callback(result);
29        });
30    },
31    prompt: function(message, value, title, callback) {
32      if( title == null ) title = 'Prompt';
33        this._show_mess(title, message, value, 'prompt', function(result) {
34        if( callback ) callback(result);
35      });
36    },
37    message: function(title){
38      if(title == null) title = '';
39      this._show_mess(title, '', '', 'message');
40    },
41    box_close: function() {
42      $('#popup_container').fadeOut(200, function(){
43        $('#popup_overlay, #popup_container').remove();
44      });
45    },
46    _show_mess: function(title, msg, value, type, callback) {
47      if ($('#popup_container').length > 0) {
48        $('#popup_overlay, #popup_container').remove();
49      }
50      var html = "<div id='popup_container'>" +
51        "<table>" +
52          "<tbody>" +
53          "<tr>" +
54            "<td class='tl'/><td class='b'/><td class='tr'/>" +
55          "</tr>" +
56          "<tr>" +
57            "<td class='b'/>" +
58            "<td class='body'>" +
59              "<div class='popup_title_wrap'><div class='popup_x_button'/><div id='popup_title'/></div>" +
60              "<div id='popup_progress'><img src='/images/progress.gif' alt='Загрузка...' /></div>" +
61              "<div id='popup_content'/>" +
62              "<div id='popup_message'/>" +
63              "<div id='popup_panel'>" +
64                "<span class='ajax-loader'>&nbsp;</span>" +
65                "<div id='popup_info'/>" +
66                "<input id='popup_ok' type='button' class='button_yes' value='" + this.ok + "'/>" +
67                "<input id='popup_cancel' type='button' class='button_no' value='" + this.cancel + "'/>" +
68                "<input id='popup_close' type='button' class='button_no' value='" + this.close + "'/>" +
69              "</div>" +
70            "</td>" +
71            "<td class='b'/>" +
72          "</tr>" +
73          "<tr>" +
74            "<td class='bl'/><td class='b'/><td class='br'/>" +
75          "</tr>" +
76          "</tbody>" +
77        "</table>" +
78      "</div>";
79
80      this._overlay('show');
81      $('body').append(html);
82      $('#popup_panel input').hide();
83      if(this.dialogClass) {
84        $('#popup_container').addClass(this.dialogClass);
85      }
86      var pos = (($.browser.msie && parseInt($.browser.version) <= 6 )||(($(window).height()<480)||($(window).width()<700))) ? 'absolute' : 'fixed';
87      $('#popup_container').css({
88        position: pos,
89        zIndex: 999,
90        padding: 0,
91        margin: 0
92      });
93
94      $('#popup_title').text(title);
95      $('#popup_content').addClass(type);
96      $('#popup_message').text('<span class="box_message_content">' + msg + '</span>');
97      $('#popup_message').html($('#popup_message').text().replace(/\n/g, '<br />'));
98      $('#popup_container').css({
99        minWidth: $('#popup_container').outerWidth(),
100        maxWidth: $('#popup_container').outerWidth()
101      });
102      this._reposition();
103      this._maintainPosition(true);
104
105      switch(type) {
106        case 'alert':
107          $('#popup_close').show();
108          $('#popup_close, .popup_x_button').click(function() {
109            core.box_close();
110            callback(true);
111          });
112          $('#popup_close').keypress(function(e) {
113            if(e.keyCode == 27 || e.keyCode == 13) {
114              $('#popup_close').trigger('click');
115            }
116          });
117          $('#popup_close').focus().select();
118        break;
119        case 'confirm':
120          $('#popup_ok, #popup_cancel').show();
121          $('#popup_ok').click(function() {
122            if( callback ) callback(true);
123          });
124          $('#popup_cancel ,#popup_close, .popup_x_button').click(function() {
125            core.box_close();
126            callback(false);
127          });
128          $('#popup_ok').click(function() {
129            core.box_close();
130          });
131          $('#popup_cancel').focus().select();
132        break;
133        case 'prompt':
134          $('#popup_message').append('<input id="popup_prompt" name="popup_prompt" value="' + value + '"/>');
135          $('#popup_prompt').width($('#popup_message').width());
136          $('#popup_ok').attr('value', this.send);
137          $('#popup_ok, #popup_cancel').show();
138          $('#popup_ok').click(function() {
139            var val = $('#popup_prompt').val();
140            if (val){
141              if(callback) callback(val);
142            }
143          });
144          $('#popup_cancel, .popup_x_button').click(function() {
145            core.box_close();
146            if(callback) callback(null);
147          });
148          $('#popup_prompt, #popup_ok, #popup_close').keypress(function(e) {
149            if(e.keyCode == 27) $('#popup_cancel').trigger('click');
150          });
151          $('#popup_prompt').focus().select();
152        break;
153        case 'message':
154          $('#popup_cancel, #popup_progress').show();
155          $('#popup_cancel ,#popup_close, .popup_x_button').focus().select().click(function(){
156            core.box_close();
157          });
158        break;
159       }
160    },
161    _overlay: function(status) {
162      switch(status) {
163        case 'show':
164          this._overlay('hide');
165          $('body').append('<div id="popup_overlay"></div>');
166          $('#popup_overlay').css({
167            position: 'absolute',
168            zIndex: 998,
169            top: 0,
170            left: 0,
171            width: '100%',
172            height: $(document).height(),
173            background: this.overlayColor,
174            opacity: this.overlayOpacity
175          });
176        break;
177        case 'hide':
178          $('#popup_overlay').remove();
179        break;
180      }
181    },
182    _reposition: function() {
183      var top = ((window.screen.availHeight / 2)) + this.verticalOffset;
184      var left = (($(window).width() / 2) - ($('#popup_container').outerWidth() / 2)) + this.horizontalOffset;
185      if(top < 0) top = 0;
186      if(left < 0) left = 0;
187
188      $('#popup_container').css({
189        top: top,
190        left: left
191      });
192
193      // IE6 fix
194      if(($.browser.msie && parseInt($.browser.version) <= 6 )||(($(window).height()<480)||($(window).width()<700))) top = top + $(window).scrollTop();
195      $('#popup_overlay').height($(document).height());
196    },
197    _maintainPosition: function(status) {
198      if(this.repositionOnResize) {
199        switch(status) {
200          case true:
201            $(window).bind('resize', this._reposition);
202          break;
203          case false:
204            $(window).unbind('resize', this._reposition);
205          break;
206        }
207      }
208    },
209    show_popup_info: function(text, type) {
210      this._popup_info(type);
211      $('#popup_info').text(text).show();
212    },
213    hide_popup_info: function() {
214      this.show_popup_info('');
215      $('#popup_info').text('').hide();
216    },
217    _popup_info: function(type) {
218      $('#popup_info').hide();
219      $('#popup_info').attr('class', type);
220    },
221    show_error_field: function(obj) {
222      obj.animate({backgroundColor:"#e6a4a4"}, {duration:200});
223      obj.animate({backgroundColor:"#ffffff"}, {duration:200});
224      obj.css({border:'1px solid red'});
225    },
226    hide_error_field: function(obj) {
227      obj.css({border:'1px solid #aaa'});
228    }
229  };
230
231	jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
232		jQuery.fx.step[attr] = function(fx){
233			if ( fx.state == 0 ) {
234				fx.start = getColor( fx.elem, attr );
235				fx.end = getRGB( fx.end );
236			}
237
238			fx.elem.style[attr] = "rgb(" + [
239				Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0
239),
240				Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
241				Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
242			].join(",") + ")";
243		}
244	});
245	function getRGB(color) {
246		var result;
247		if ( color && color.constructor == Array && color.length == 3 )
248			return color;
249
250		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
251			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
252
253		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
254			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
255
256		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
257			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
258
259		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
260			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
261
262		return colors[jQuery.trim(color).toLowerCase()];
263	}
264	function getColor(elem, attr) {
265		var color;
266		do {
267			color = jQuery.curCSS(elem, attr);
268			if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
269				break;
270			attr = "backgroundColor";
271		} while ( elem = elem.parentNode );
272		return getRGB(color);
273	};
274})(jQuery);
275
276function reloadCaptcha(img_id) {
277  $('img#' + img_id).attr('src', '/includes/codegen/cms_codegen.php?' + Math.random());
278}
279function centerLink(href){
280	$('div.component').css({opacity:0.4, filter:'alpha(opacity=40)'});
281	$.post(href, {'of_ajax': 1}, function(data){
282		$('div.component').html(data);
283		$('div.component').css({opacity:1.0, filter:'alpha(opacity=100)'});
284	});
285}
286function deleteWallRecord(component, target_id, record_id, csrf_token){
287    core.confirm('Вы действительно хотите удалить эту запись со стены?', null, function(){
288        $('#wall_entry_'+record_id).css('background', '#FFAEAE').fadeOut();
289        $.post('/core/ajax/wall.php', {target_id: target_id, component: component, do_wall: 'delete', csrf_token: csrf_token, record_id: record_id}, function(result){
290            if(result){
291                wallPage(1);
292            }
293        });
294    });
295}
296function addWall(component, target_id){
297
298	core.message('Новая запись на стене');
299	$.post('/core/ajax/wall.php', {target_id: target_id, component: component, do_wall: 'add'}, function(data){
300		if(data.error == false){
301			$('#popup_message').html(data.html);
302			$('#popup_progress').hide();
303			$('#popup_ok').val('Добавить').show();
304			$('#popup_ok').click(function(){
305				$('#popup_ok').attr('disabled', 'disabled');
306				$('.ajax-loader').show();
307				var options = {
308					success: doaddWall
309				};
310				$('#add_wall_form').ajaxSubmit(options);
311			});
312		} else {
313			core.alert(data.text, 'Ошибка');
314		}
315	}, 'json');
316
317}
318
319function doaddWall(result, statusText, xhr, $form){
320	$('.ajax-loader').hide();
321	$('.sess_messages').fadeOut();
322	if(statusText == 'success'){
323		if(result.error == false){
324			core.box_close();
325			wallPage(1);
326		} else {
327			$('#error_mess').html(result.text);
328			$('.sess_messages').fadeIn();
329			$('#popup_ok').attr('disabled', '');
330		}
331	} else {
332		core.alert(statusText, 'Ошибка');
333	}
334}
335function wallPage(page){
336
337	var target_id = $('div.wall_body input[name=target_id]').val();
338	var component = $('div.wall_body input[name=component]').val();
339
340	$('div.wall_body').css({opacity:0.5, filter:'alpha(opacity=50)'});
341	$.post('/core/ajax/wall.php', {'target_id': target_id, 'component': component, 'page':page}, function(data){
342		$('div.wall_body').html(data);
343		$('div.wall_body').css({opacity:1.0, filter:'alpha(opacity=100)'});
344	});
345
346}

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.