1if (!Array.prototype.indexOf) 2{ 3 Array.prototype.indexOf = function(obj, start) 4 { 5 for (var i = (start || 0), j = this.length; i < j; i++) 6 { 7 if (this[i] === obj) { return i; } 8 } 9 return -1; 10 } 11} 12 13 14 15function toggleFCFavCookie(id, type) 16{ 17 var fcfavs = fc_getCookie('fcfavs'); 18 19 try { 20 fcfavs = JSON.parse(fcfavs); 21 } catch(e) { 22 fcfavs = {}; 23 } 24 25 if (!fcfavs.hasOwnProperty(type)) 26 { 27 fcfavs[type] = []; 28 } 29 30 var index = fcfavs[type].indexOf(id); 31 index === -1 32 ? fcfavs[type].push(id) 33 : fcfavs[type].splice(index, 1); 34 35 fcfavs = JSON.stringify(fcfavs); 36 fc_setCookie('fcfavs', fcfavs, 365); 37} 38 39 40 41function FCFav(id, type, add_counter) 42{ 43 type = (typeof type === "undefined" || type === null ) ? 'item' : type; 44 add_counter = (typeof add_counter === "undefined" || add_counter === null ) ? false : add_counter; 45 46 // We will no do a client side updating of favourites cookie, the updated 47 // cookie will be received via the HTTP response of the AJAX server call 48 //toggleFCFavCookie(id, type); 49 50 // Joomla Root and Base URL 51 window.root_url = !!jroot_url_fc ? jroot_url_fc : ''; 52 window.base_url = !!jbase_url_fc ? jbase_url_fc : ''; 53 54 var favurl = root_url + 'index.php?option=com_flexicontent&format=raw&task=ajaxfav&id=' + id + '&type=' + type; 55 56 var onote_msg_box_start = '<div class="fc-mssg fc-note fc-iblock fc-nobgimage fcfavs-result-mssg" style="position: relative;">'; 57 var osucc_msg_box_start = '<div class="fc-mssg fc-success fc-iblock fc-nobgimage fcfavs-result-mssg" style="z-index:1000; position: relative;">'; 58 var _box_start = '<div class="fc-mssg fc-info fc-iblock fc-nobgimage'; 59 60 var divs = jQuery('.fcfavs-responce_'+type+'_'+id); 61 if (divs.length) 62 { 63 //divs.html(_box_start + ' fcfavs-loading">' + '<img src="'+base_url+'components/com_flexicontent/assets/images/ajax-loader.gif" border="0" align="absmiddle" /> ' + Joomla.JText._('FLEXI_LOADING') + '</div>'); 64 divs.html('<span class="fcfavs-loading">' + '<img src="'+base_url+'components/com_flexicontent/assets/images/ajax-loader.gif" border="0" align="absmiddle" /> </span>'); 65 } 66 67 jQuery.ajax({ 68 cache: false, 69 url: favurl, 70 dataType: "text", 71 data: { 72 lang: (typeof fc_sef_lang != 'undefined' ? fc_sef_lang : '') 73 }, 74 success: function( response ) { 75 var links = jQuery('.favlink_' + type + '_' + id + '.fcfavs-toggle-btn'); 76 if (!divs) return; 77 78 response = response.trim(); 79 80 var div_toggle_info, div_status_info, div_user_counter, link; 81 82 if (fcfav_toggle_info) 83 { 84 if (response=='login') div_toggle_info = onote_msg_box_start + Joomla.JText._('FLEXI_YOU_NEED_TO_LOGIN') + '</div>'; 85 else if (response > 0 || response == 'added') div_toggle_info = osucc_msg_box_start + Joomla.JText._('FLEXI_ADDED_TO_YOUR_FAVOURITES') + '</div>'; 86 else if (response < 0 || response == 'removed') div_toggle_info = osucc_msg_box_start + Joomla.JText._('FLEXI_REMOVED_FROM_YOUR_FAVOURITES') + '</div>'; 87 else if (isNaN(parseFloat(response))) div_toggle_info = onote_msg_box_start + response + '</div>'; // some custom text 88 89 jQuery.each( divs, function( i, box) 90 { 91 jQuery(box).html(div_toggle_info); 92 }); 93 } 94 95 div_status_info = ''; 96 div_user_counter = ''; 97 98 if (response == 'added') 99 { 100 if (!!!fcfav_toggle_style) // Bootstrap Toggle 101 { 102 link = '<input data-on="<i class=\'icon-heart fcfavs-icon_on\'></i>" data-off="<i class=\'icon-heart fcfavs-icon_off\'></i>" data-toggle="toggle" type="checkbox" value="1" checked="checked" />'; 103 } 104 else if (fcfav_toggle_style == 1) // Icon Image 105 { 106 link = '<img alt="'+Joomla.JText._('FLEXI_REMOVE_FAVOURITE')+'" src="'+base_url+'components/com_flexicontent/assets/images/heart_full.png" border="0" class="fcfavs-img_icon" />'; 107 } 108 else // Icon CSS 109 { 110 link = '<span class="fcfavs-btn"><span class="fcfavs-btn-inner fcfavs-heart-fill"></span>'; 111 } 112 113 div_status_info = _box_start + ' fcfavs-is-subscriber">' + Joomla.JText._('FLEXI_FAVS_YOU_HAVE_SUBSCRIBED') + '</div>'; 114 } 115 else if (response == 'removed') 116 { 117 if (!!!fcfav_toggle_style) // Bootstrap Toggle 118 { 119 link = '<input data-on="<i class=\'icon-heart fcfavs-icon_on\'></i>" data-off="<i class=\'icon-heart fcfavs-icon_off\'></i>" data-toggle="toggle" type="checkbox" value="1" />'; 120 } 121 else if (fcfav_toggle_style == 1) // Icon Image 122 { 123 link='<img alt="'+Joomla.JText._('FLEXI_FAVOURE')+'" src="'+base_url+'components/com_flexicontent/assets/images/heart_empty.png" border="0" class="fcfavs-img_icon" />'; 124 } 125 else // Icon CSS 126 { 127 link = '<span class="fcfavs-btn"><span class="fcfavs-btn-inner fcfavs-heart-border"></span>'; 128 } 129 130 div_status_info = _box_start + ' fcfavs-isnot-subscriber">' + Joomla.JText._('FLEXI_FAVS_CLICK_TO_SUBSCRIBE') + '</div>'; 131 } 132 else if (response > 0) 133 { 134 var newtotal = Math.abs(response); 135 var newfavs = newtotal; //+' '+Joomla.JText._('FLEXI_USERS'); 136 137 if (!!!fcfav_toggle_style) // Bootstrap Toggle 138 { 139 link = '<input data-on="<i class=\'icon-heart fcfavs-icon_on\'></i>" data-off="<i class=\'icon-heart fcfavs-icon_off\'></i>" data-toggle="toggle" type="checkbox" value="1" checked="checked" />'; 140 } 141 else if (fcfav_toggle_style == 1) // Icon Image 142 { 143 link = '<img alt="'+Joomla.JText._('FLEXI_REMOVE_FAVOURITE')+'" src="'+base_url+'components/com_flexicontent/assets/images/heart_full.png" border="0" class="fcfavs-img_icon" />'; 144 } 145 else // Icon CSS 146 { 147 link = '<span class="fcfavs-btn"><span class="fcfavs-btn-inner fcfavs-heart-fill"></span>'; 148 } 149 150 div_status_info = _box_start + ' fcfavs-is-subscriber">' + Joomla.JText._('FLEXI_FAVS_YOU_HAVE_SUBSCRIBED') + '</div>'; 151 //div_user_counter = (add_counter ? ' '+ _box_start + ' fcfavs-subscribers-count">' + Joomla.JText._('FLEXI_TOTAL') + ': ' + newfavs + '</div>' : ''); 152 div_user_counter = (add_counter ? newfavs : ''); 153 } 154 else if (response < 0) 155 { 156 var newtotal = Math.abs(response); 157 var newfavs = newtotal; //+' '+Joomla.JText._('FLEXI_USERS'); 158 159 if (!!!fcfav_toggle_style) // Bootstrap Toggle 160 { 161 link = '<input data-on="<i class=\'icon-heart fcfavs-icon_on\'></i>" data-off="<i class=\'icon-heart fcfavs-icon_off\'></i>" data-toggle="toggle" type="checkbox" value="1" />'; 162 } 163 else if (fcfav_toggle_style == 1) // Icon Image 164 { 165 link = '<img alt="'+Joomla.JText._('FLEXI_FAVOURE')+'" src="'+base_url+'components/com_flexicontent/assets/images/heart_empty.png" border="0" class="fcfavs-img_icon" />'; 166 } 167 else // Icon CSS 168 { 169 link = '<span class="fcfavs-btn"><span class="fcfavs-btn-inner fcfavs-heart-border"></span>'; 170 } 171 172 div_status_info = _box_start + ' fcfavs-isnot-subscriber">' + Joomla.JText._('FLEXI_FAVS_CLICK_TO_SUBSCRIBE') + '</div>'; 173 div_user_counter = (add_counter ? newfavs : ''); 174 } 175 176 jQuery.each( links, function( i, box ) 177 { 178 jQuery(box).html(link); 179 jQuery(box).find('input[type=checkbox][data-toggle^=toggle], input.fc_checkboxtoggle').bootstrapToggle(); 180 }); 181 182 // Update text with some delay 183 setTimeout(function() 184 { 185 jQuery.each( divs, function( i, box ) 186 { 187 jQuery(box).fadeOut( fcfav_status_info ? 1800 : 1, function() { 188 jQuery(box).html((fcfav_status_info ? div_status_info : '')).css('display', ''); 189 if (add_counter && newfavs) 190 jQuery(box).parent().find('.fcfavs-subscribers-count').css('display', '').find('.fcfavs-counter-num').html(div_user_counter); 191 else 192 jQuery(box).parent().find('.fcfavs-subscribers-count').css('display', 'none'); 193 }); 194 }); 195 }, fcfav_status_info ? 200 : 1); 196 }, 197 error: function (xhr, ajaxOptions, thrownError) { 198 alert('Error status: ' + xhr.status + ' , Error text: ' + thrownError); 199 } 200 }); 201}
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.