1(function( $ ) { 2 $.fn.ecomment = function(options) { 3 4 return this.each(function(){ 5 6 var $this = $(this), 7 data = $this.data('ecomment'), 8 settings = $.extend({ 9 'ref' : location.href, 10 'http_ref' : location.href, 11 'path' : '/ecomment.php' 12 }, options), 13 query = parseQuery(); 14 15 16 17 if(!data){ 18 19 $this.data('ecomment', { 20 21 'settings' : settings, 22 'query' : query 23 24 }); 25 26 if(!$this.find('.ecomment_list').length){ $this.append('<div class="ecomment_list" />'); } 27 if(!$this.find('.ecomment_info').length){ $this.append('<div class="ecomment_info" />'); } 28 if(!$this.find('.ecomment_desktop').length){ $this.append('<div class="ecomment_desktop" />'); } 29 30 } 31 32 // пеÑвиÑное заполнение конÑейнеÑов комменÑами, инÑ.ÑообÑениÑми и ÑоÑмой оÑвеÑа 33 $.ajax({ 34 url: settings.path, 35 type: 'post', 36 dataType: 'json', 37 data:{ 38 op: query.op !== undefined ? query.op : 'init', //пÑокидÑваем возможнÑÑ Ð¾Ð¿ÐµÑаÑÐ¸Ñ Ð¸Ð· адÑеÑной ÑÑÑоки 39 email: query.email, //опÑионалÑно, Ð´Ð»Ñ Ð¾ÑпиÑки 40 ref: query.ref !== undefined ? query.ref : settings.ref, 41 http_ref: settings.http_ref, 42 ecomment_page: query.ecomment_page || undefined 43 }, 44 success: function(data){ 45 htmlReturn(data); 46 } 47 }); 48 49 // Ð¾Ð±Ð²ÐµÑ ÑодеÑжимого конÑейнеÑа обÑабоÑÑиками 50 $this 51 //Ð¾Ð±Ð²ÐµÑ ÑабмиÑа ÑоÑÐ¼Ñ 52 .on('submit', '.ecomment_form', function(e){ 53 e.preventDefault(); 54 var request = $(this).serializeArray(); 55 // добавлÑем заголовок ÑÑÑаниÑÑ, ÑÑÐ¾Ð±Ñ ÐºÑаÑиво вÑводиÑÑ ÐµÐ³Ð¾ в ÑведомлениÑÑ 56 request.push({ 57 name: 'page_title', 58 value: $('title').text() 59 }); 60 61 $.ajax({ 62 type: 'POST', 63 url: settings.path, 64 data: request, 65 success: htmlReturn, 66 dataType: 'JSON' 67 }); 68 }) 69 //Ð¾Ð±Ð²ÐµÑ ÑпÑавлÑÑÑÐ¸Ñ ÐºÐ½Ð¾Ð¿Ð¾Ðº 70 .on('click', 'a.ecomment_op, .pagination a', function(e){ 71 e.preventDefault(); 72 var href = parseQuery( $(this).attr('href') ); 73 href.page_title = $('title').text(); 74 75 if(href.op == 'login'){ 76 href.password = prompt('ÐведиÑе паÑÐ¾Ð»Ñ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑÑÑаÑоÑа:'); 77 if(!href.password) return false; 78 } 79 if(href.op == 'get_list'){ // ÑÑÐ¾Ð±Ñ Ð¿Ñи ÑабмиÑе Ð¼Ñ Ð²ÐµÑнÑлиÑÑ Ð½Ð° ÑÑ Ð¶Ðµ ÑÑÑаниÑÑ, кÑда пеÑÐµÑ Ð¾Ð´Ð¸Ð»Ð¸ по пагинаÑии 80 $('input[name=ecomment_page]').val(href.ecomment_page); 81 } 82 href = $.extend(href, settings); 83 84 $.ajax({ 85 type: 'POST', 86 url: settings.path, 87 data: href, 88 success: htmlReturn, 89 dataType: 'JSON' 90 }); 91 }) 92 //Ð¾Ð±Ð²ÐµÑ ÐºÐ»Ð¸ÐºÐ° по ÑÑÑлке "оÑвеÑиÑÑ" 93 .on('click', 'a.ecomment_answer_link', function(e){ 94 e.preventDefault(); 95 var href = parseQuery( $(this).attr('href') ); 96 var input = $this.find('.ecomment_form input[name=parent]'); 97 $this.find('.ecomment').removeClass('ecomment_selected_for_answer'); 98 99 100 if(input.val() && input.val() == href.id){ 101 input.val(''); 102 $this.find('.ecomment_answer_caption').html(''); 103 } else { 104 var name = $(this).parents('.ecomment').addClass('ecomment_selected_for_answer').find('.ecomment_name').text(); 105 $this.find('.ecomment_answer_caption').html('оÑÐ²ÐµÑ Ð´Ð»Ñ <b>'+ name +'</b>'); 106 input.val(href.id); 107 } 108 }) 109 //Ð¾Ð±Ð²ÐµÑ ÑедакÑиÑÑемÑÑ Ð¿Ð¾Ð»ÐµÐ¹ 110 //делаем поле ÑедакÑиÑÑемÑм 111 .on('click', '.ecomment_editable', function(e){ 112 e.preventDefault(); 113 $(this).attr('contenteditable', true).focus(); 114 }) 115 //Ñ ÑедакÑиÑÑемÑÑ Ð¿Ð¾Ð»ÐµÐ¹ внедÑÑем обÑабоÑÑик поÑеÑи ÑокÑÑа 116 .on('blur', '[contenteditable]', function(e){ 117 var $field = $(this); 118 var name = $field.attr('rel'); 119 var key = $field.parents('.ecomment').attr('rel'); 120 121 var data = $.extend({ 122 op: 'update_comment', 123 id: key, 124 http_ref: settings.href 125 }, settings); 126 data[name] = $field.html(); 127 128 $.ajax({ 129 url: settings.path, 130 dataType: 'json', 131 type: 'post', 132 data: data, 133 success: function(data){ 134 htmlReturn(data); 135 $field.off('blur').removeAttr('contenteditable'); 136 } 137 }); 138 }) 139 //и добавлÑем обÑабоÑÐºÑ Ð½Ð°Ð¶Ð°ÑÐ¸Ñ enter (в ÑÐµÐ¼Ñ Ð¾Ð±ÑабоÑки пеÑеноÑов ÑÑÑок и ÑÐ¾Ñ ÑÐ°Ð½ÐµÐ½Ð¸Ñ Ð¸Ð·Ð¼ÐµÐ½Ð½Ð¸Ð¹)
140 .on('keyup, keydown', '[contenteditable]', function(e){ 141 if(e.keyCode == 13){ 142 e.preventDefault(); 143 if(e.ctrlKey){ //CTRL+ENTER - поÑеÑÑ ÑокÑÑа и ÑÐ¾Ñ Ñанение 144 $(this).trigger('blur'); 145 } else { //пÑоÑÑо добавлÑем br в ÑазмеÑÐºÑ 146 document.execCommand('insertHTML', false, '<br>'); 147 } 148 } 149 150 }) 151 //Ð¾Ð±Ð²ÐµÑ ÐºÐ»Ð¸ÐºÐ° по ÑекбокÑÑ 152 .on('click', '.ecomment_form_not_robot', function(e){ 153 var d = new Date(); 154 $(this).val( d.getTime() ); 155 }) 156 //Ð¾Ð±Ð²ÐµÑ ÑÑеÑÑика Ñимволов 157 .on('keyup', '.ecomment_form_message', function(e){ 158 var length = $(this).val().length; 159 $this.find('.ecomment_counter').val( $this.data('ecomment').counter - length ); 160 }); 161 162 // оÑновной обÑабоÑÑик оÑвеÑа ÑеÑвеÑа 163 function htmlReturn(answer){ 164 data = $this.data('ecomment'); 165 166 if(answer.desktop !== undefined){ 167 $this.find('.ecomment_desktop').html(answer.desktop); 168 } 169 if(answer.info) { 170 htmlReturnInfo(answer.info); 171 } 172 if(answer.list) { 173 $this.find('.ecomment_list').html(answer.list); 174 } 175 data.counter = $this.find('input[name=counter]').val(); 176 $this.data('ecomment', data); 177 } 178 179 // оÑобÑажение инÑоÑмаÑионнÑÑ ÑообÑений 180 function htmlReturnInfo(info){ 181 $this.find('.ecomment_info').html(info); 182 } 183 184 // ÑÐ°Ð·Ð±Ð¾Ñ Ð°Ð´ÑеÑной ÑÑÑоки на паÑамеÑÑÑ 185 function parseQuery(qs,options) { 186 var q = (typeof qs === 'string' ? qs : window.location.search), 187 o = { 188 'f':function(v){ 189 return unescape(v).replace(/\+/g,' '); 190 } 191 }, 192 options = (typeof qs === 'object' && typeof options === 'undefined') ? qs : options, 193 o = jQuery.extend({}, o, options), 194 params = {}; 195 196 jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){ 197 p = p.split('='); 198 p[1] = o.f(p[1]); 199 params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1]; 200 }); 201 return params; 202 } 203 204 205 }) 206 207 } 208})(jQuery);
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.