1(function(jQuery){ 2 // ФÑнкÑии без ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ ÐºÐ¾Ð»Ð»ÐµÐºÑии 3 jQuery.extend({ 4 addIntoCart: function(path, shop_item_id, count){ 5 $.clientRequest({path: path + '?add=' + shop_item_id + '&count=' + count, 'callBack': $.addIntoCartCallback, context: $('#little_cart')}); 6 return false; 7 }, 8 addIntoCartCallback: function(data, status, jqXHR) 9 { 10 $.loadingScreen('hide'); 11 jQuery(this).html(data); 12 }, 13 addCompare: function(path, shop_item_id, object){ 14 $(object).toggleClass('current'); 15 $.clientRequest({path: path + '?compare=' + shop_item_id, 'callBack': function(){ 16 $.loadingScreen('hide'); 17 }, context: $(object)}); 18 $('#compareButton').show(); 19 return false; 20 }, 21 addFavorite: function(path, shop_item_id, object){ 22 $(object).toggleClass('favorite_current'); 23 $.clientRequest({path: path + '?favorite=' + shop_item_id, 'callBack': function(){ 24 $.loadingScreen('hide'); 25 }, context: $(object)}); 26 $('#favoriteButton').show(); 27 return false; 28 }, 29 30 sendVote: function(id, vote, entity_type){ 31 $.clientRequest({path: '?id=' + id + '&vote=' + vote + '&entity_type=' + entity_type , 'callBack': $.sendVoteCallback}); 32 return false; 33 }, 34 sendVoteCallback: function(data, status) 35 { 36 $.loadingScreen('hide'); 37 $('#' + data.entity_type + '_id_' + data.item).removeClass("up down"); 38 if (!data.delete_vote) 39 { 40 data.value == 1 41 ? $('#' + data.entity_type + '_id_' + data.item).addClass("up") 42 : $('#' + data.entity_type + '_id_' + data.item).addClass("down"); 43 } 44 45 $('#' + data.entity_type + '_rate_' + data.item).text(data.rate); 46 $('#' + data.entity_type + '_likes_' + data.item).text(data.likes); 47 $('#' + data.entity_type + '_dislikes_' + data.item).text(data.dislikes); 48 } 49 }); 50})(jQuery); 51 52/** 53* Склонение поÑле ÑиÑлиÑелÑнÑÑ 54* int number ÑиÑлиÑелÑное 55* int nominative ÐмениÑелÑнÑй падеж 56* int genitive_singular РодиÑелÑнÑй падеж, единÑÑвенное ÑиÑло 57* int genitive_plural РодиÑелÑнÑй падеж, множеÑÑвенное ÑиÑло 58*/ 59function declension(number, nominative, genitive_singular, genitive_plural) 60{ 61 var last_digit = number % 10, last_two_digits = number % 100, result; 62 63 if (last_digit == 1 && last_two_digits != 11) 64 { 65 result = nominative; 66 } 67 else 68 { 69 if ((last_digit == 2 && last_two_digits != 12) || (last_digit == 3 && last_two_digits != 13) || (last_digit == 4 && last_two_digits != 14)) 70 { 71 result = genitive_singular; 72 } 73 else 74 { 75 result = genitive_plural; 76 } 77 } 78 79 return result; 80} 81 82/* 83 * jQuery ÐиÑнÑе ÑообÑÐµÐ½Ð¸Ñ 84 */ 85// ÐиÑнÑе ÑообÑÐµÐ½Ð¸Ñ 86(function($) { 87 $.fn.messageTopicsHostCMS = function(settings) { 88 // ÐаÑÑÑойки 89 settings = $.extend({ 90 timeout : 10000, // ТаймаÑÑ Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ð¹ 91 data : '#messages_data', // блок Ñ Ð´Ð°Ð½Ð½Ñми пеÑепиÑки Ð´Ð»Ñ Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ 92 url : '#url', // знаÑение URL 93 page : '#page', // знаÑение total 94 message_field : 'textarea', // поле ввода ÑообÑÐµÐ½Ð¸Ñ 95 page_link : '.page_link', // ÑÑÑлки на ÑÑÑаниÑÑ 96 keyToSend : 13 // ÐÑпÑавка ÑообÑÐµÐ½Ð¸Ñ 97 }, settings); 98 99 var Obj = $.extend({ 100 _url : this.find(settings.url).text(), 101 _page : parseInt(this.find(settings.page).text()) + 1, 102 oData : this.find(settings.data), 103 oForm : this.find('form'), 104 oField : this.find(settings.message_field), // поле ввода ÑообÑÐµÐ½Ð¸Ñ 105 oPage : this.find(settings.page_link), // ÑÑÑлки на ÑÑÑаниÑÑ 106 oTemp : {} // блок вÑеменнÑÑ Ð´Ð°Ð½Ð½ÑÑ 107 }, this); 108 109 function _start() { 110 if (Obj.length == 1) { 111 // обновление даннÑÑ Ð¿Ð¾ ÑаймаÑÑÑ 112 setInterval(_ajaxLoad, settings.timeout); 113 114 Obj.oField.keydown(function(e) { 115 if (e.ctrlKey && e.keyCode == settings.keyToSend) Obj.oForm.submit(); 116 }); 117 118 // оÑпÑавка ÑоÑÐ¼Ñ Ð¿Ð¾ Ctrl+Enter 119 Obj.oField.keydown(function(e) { 120 if (e.ctrlKey && e.keyCode == settings.keyToSend) Obj.oForm.submit(); 121 }); 122 123 // оÑпÑавка ÑообÑÐµÐ½Ð¸Ñ Ð¸Ð· ÑоÑÐ¼Ñ 124 Obj.oForm.submit(function() { 125 if (Obj.oField.val().trim().length) { 126 _ajaxLoad({form : Obj.oForm.serialize()}); 127 Obj.oForm.find(':input:not([type=submit],[type=button])').each(function(){$(this).val('')}); 128 } 129 return false;
130 }); 131 } 132 return false; 133 } 134 135 // Ajax запÑÐ¾Ñ 136 function _ajaxLoad(data) { 137 if (!data) data = {}; 138 form = data.form ? '&' + data.form : ''; 139 140 return $.ajax({ 141 url : Obj._url + 'page-' + Obj._page + '/', 142 type : 'POST', 143 data : 'ajaxLoad=1' + form, 144 dataType : 'json', 145 success : function (ajaxData) { 146 Obj.oData.html($(ajaxData.content).find(settings.data).html()); 147 }, 148 error : function (){return false} 149 }); 150 } 151 return this.ready(_start); 152 }; 153})(jQuery); 154 155// ÐиÑнÑе ÑообÑÐµÐ½Ð¸Ñ 156(function($) { 157 $.fn.messagesHostCMS = function(settings) { 158 //jQuery.extend({ 159 //messagesHostCMS: function(settings){ 160 // ÐаÑÑÑойки 161 settings = $.extend({ 162 chat_height : 465, // ÐÑÑоÑа ÑаÑа пеÑепиÑки 163 timeout : 10000, // ТаймаÑÑ Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ð¹ 164 load_messages : '#load_messages', // кнопка подгÑÑзки ÑÑаÑÑÑ ÑообÑений 165 chat_window : '#chat_window', // окно ÑаÑа пеÑепиÑки 166 messages : '#messages', // ÑпиÑок ÑообÑений ÑаÑа 167 prefix_message_id : 'msg_', // пÑеÑÐ¸ÐºÑ Ð¸Ð´ÐµÐ½ÑиÑикаÑоÑа ÑообÑÐµÐ½Ð¸Ñ Ð² DOM 168 message_field : 'textarea', // поле ввода ÑообÑÐµÐ½Ð¸Ñ 169 url : '#url', // знаÑение URL
170 limit : '#limit', // знаÑение limit 171 total : '#total', // знаÑение total 172 topic_id : '#topic_id', // знаÑение message_topic id 173 keyToSend : 13 // ÐÑпÑавка ÑообÑÐµÐ½Ð¸Ñ 174 }, settings); 175 176 var Obj = $.extend({ 177 _activity : 1, 178 _autoscroll : 1, 179 _url : this.find(settings.url).text(), 180 _limit : this.find(settings.limit).text(), 181 _total : this.find(settings.total).text(), 182 _topic_id : this.find(settings.topic_id).text(), 183 _count_msg : 0, // колиÑеÑÑво ÑообÑений в ÑаÑе 184 oLoad : this.find(settings.load_messages), // кнопка подгÑÑзки ÑÑаÑÑÑ ÑообÑений 185 oWindow : this.find(settings.chat_window), // окно ÑаÑа пеÑепиÑки 186 oMessages : this.find(settings.messages), // ÑпиÑок ÑообÑений ÑаÑа 187 oField : this.find(settings.message_field), // поле ввода ÑообÑÐµÐ½Ð¸Ñ 188 oForm : this.find('form'), 189 oTemp : {} // блок вÑеменнÑÑ Ð´Ð°Ð½Ð½ÑÑ 190 }, this); 191 192 function _start() { 193 if (Obj.length == 1) { 194 _recountChat(); 195 196 // обновление даннÑÑ Ð¿Ð¾ ÑаймаÑÑÑ 197 setInterval(_ajaxLoad, settings.timeout); 198 199 // пÑовеÑка акÑивноÑÑи полÑзоваÑÐµÐ»Ñ 200 $("body").mousemove(function(){ 201 Obj._activity = Obj._autoscroll == 1 ? 1 : 0; 202 }); 203 204 // оÑпÑавка ÑоÑÐ¼Ñ Ð¿Ð¾ Ctrl+Enter 205 Obj.oField.keydown(function(e) { 206 if (e.ctrlKey && e.keyCode == settings.keyToSend) Obj.oForm.submit(); 207 }); 208 209 Obj.oWindow.scroll(function(){ 210 Obj._autoscroll = Obj.oMessages.height() == Obj.oWindow.scrollTop() + settings.chat_height ? 1 : 0; 211 }); 212 213 // оÑпÑавка ÑообÑÐµÐ½Ð¸Ñ Ð¸Ð· ÑоÑÐ¼Ñ 214 Obj.oForm.submit(function() { 215 if (Obj.oField.val().trim().length) { 216 Obj._autoscroll = 1; 217 Obj._activity = 1; 218 _ajaxLoad({form : Obj.oForm.serialize()}); 219 Obj.oField.val(''); 220 } 221 return false; 222 }); 223 224 Obj.oLoad.click(function(){ 225 _ajaxLoad({ 226 preload : true, 227 page : 'page-' + parseInt(Obj._count_msg / Obj._limit + 1) 228 }) 229 }); 230 } 231 return false; 232 } 233 234 // Ajax запÑÐ¾Ñ 235 function _ajaxLoad(data) { 236 if (!data) data = {}; 237 page = data.page ? data.page + '/' : ''; 238 form = data.form ? '&' + data.form : ''; 239 return $.ajax({ 240 url : Obj._url + Obj._topic_id + '/' + page, 241 type : 'POST', 242 data : 'ajaxLoad=1&activity=' + Obj._activity + form, 243 dataType : 'json', 244 success : function (ajaxData) { 245 Obj.oTemp = $(ajaxData.content); 246 247 if (!data.preload && Obj._count_msg > Obj._limit) 248 { 249 Obj.oTemp.find(settings.messages + ' > :first[id^='+settings.prefix_message_id+']').remove(); 250 } 251 252 // замена ÑообÑений ÑаÑа 253 Obj.oTemp.find(settings.messages + ' > [id^='+settings.prefix_message_id+']').each(function(){ 254 oMsg = Obj.oMessages.find('[id="' + $(this).attr('id') +'"]'); 255 if (oMsg.length == 1) oMsg.replaceWith($(this)); 256 }); 257 258 newMessages = Obj.oTemp.find(settings.messages + ' > [id^='+settings.prefix_message_id+']'); 259 if (newMessages.length) { 260 if (data.preload){ 261 Obj.oMessages.prepend(newMessages); 262 Obj._autoscroll = 0; 263 Obj.oWindow.scrollTop(0); 264 } 265 else { 266 Obj.oMessages.append(newMessages); 267 } 268 _recountChat(); 269 } 270 }, 271 error : function (){return false} 272 }); 273 } 274 275 function _recountChat() { 276 if (Obj.oWindow.height() > settings.chat_height) Obj.oWindow.height(settings.chat_height + 'px'); 277 if (Obj._autoscroll == 1) Obj.oWindow.scrollTop(Obj.oMessages.height() - settings.chat_height); 278 if (Obj.oTemp.length) Obj._total = Obj.oTemp.find(settings.total).text(); 279 Obj._count_msg = Obj.oMessages.find('> *[id^='+settings.prefix_message_id+']').length; 280 if (Obj._count_msg >= Obj._total && Obj.oLoad.is(':visible')) Obj.oLoad.toggle(); 281 Obj._activity = 0; 282 } 283 284 return this.ready(_start); 285 }; 286})(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.