1(function ($) { 2 $(function () { 3 4 var itemsChecked = new Array(); 5 6 function initSaveFavoriteButtonsPlugin() { 7 8 var updateSaveFavoriteButtons = function () { 9 10 $(".jq_save_favorite").each(function () { 11 12 var itemId = $(this).attr("jq_item_id"); 13 14 if (itemId !== null && itemId !== undefined && itemId !== "") { 15 16 if (itemsChecked.indexOf(itemId) > -1) { 17 18 // already checked 19 20 } else { 21 22 //console.info(itemId); 23 24 itemsChecked.push(itemId); 25 26 updateSingleItem(this); 27 } 28 } 29 }); 30 }; 31 32 updateSaveFavoriteButtons(); 33 34 35 //$(".jq_save_favorite").off("click"); 36 } 37 38 window.initSaveFavoriteButtonsPlugin = initSaveFavoriteButtonsPlugin; 39 40 //initSaveFavoriteButtonsPlugin(); 41 42 $(document).ajaxStop(function () { 43 checkContentFavorite(); 44 }); 45 46 $(document).on("click", ".jq_save_favorite", function (event) { 47 if($(".jq_save_favorite").attr("jq_oper_type") == 'ADD') 48 saveContentFavorite($(this).attr("jq_item_id"),$(this).attr("jq_item_typology")); 49 if($(".jq_save_favorite").attr("jq_oper_type") == 'REMOVE') 50 removeContentFavorite($(this).attr("jq_favorite_delete_guid")); 51 }); 52 53 $(document).on("click", ".jq_save_favorite_header", function (event) { 54 $(".cc-content-action-buttons .jq_save_favorite").trigger("click"); 55 /*var currentDOMElement = this; 56 var element = null; 57 $(".jq_save_favorite").each(function () { 58 if (this !== currentDOMElement && $(this).attr('jq_item_id') !== undefined) { 59 element = this; 60 return; 61 } 62 }); 63 64 if (element !== null && element !== undefined) { 65 clickOnSaveButton(element); 66 }*/ 67 }); 68 69 function clickOnSaveButton(element) { 70 var isLockedContent = $(element).parents('.cc-locked').length > 0; 71 if (!isLockedContent) { 72 event.preventDefault(); 73 event.stopPropagation(); 74 } 75 var item = $(element); 76 var itemId = $(element).attr("jq_item_id"); 77 var site = $(element).attr("jq_site"); 78 var operType = $(element).attr("jq_oper_type"); 79 80 if (operType === "LOGIN") { 81 window.location.href = $(".jq_login_url").val(); 82 return; 83 } 84 85 var formdata = new FormData(); 86 formdata.append('itemId', itemId); 87 88 var url = "/ManageFavoritesFedertennis/ManageFavorites/"; 89 90 if (site === "SUPERTENNIS") { 91 url = "/ManageFavoritesSupertennis/ManageFavorites/"; 92 } 93 94 if (operType === "ADD") { 95 96 url += "SaveFavorite"; 97 98 } else { 99 100 url += "RemoveFavorite"; 101 } 102 $.ajax({
103 type: "POST", 104 url: url, 105 processData: false, 106 contentType: false, 107 data: formdata, 108 success: function (result) { 109 if (result.toUpperCase() === "OK") { 110 updateSingleItem(item); 111 } 112 else if (result.toUpperCase() === "FORBIDDEN") { 113 window.location.href = $(".jq_login_url").val(); 114 } else { 115 MessageBox("Errore", "Impossibile salvare questo elemento. Per favore riprova."); 116 } 117 } 118 }); 119 } 120 121 function updateSingleItem(item) { 122 var itemOff = $(item); 123 var itemOn = $(item).next(); 124 var itemId = $(item).attr("jq_item_id"); 125 var itemIsWidget = $(item).attr("jq_item_is_widget") === "true"; 126 $(itemOn).hide(); 127 $(itemOff).hide(); 128 if (itemId === "" || itemId === null || itemId === undefined) { 129 return; 130 } 131 var clientFavorites = window.readCookie("FitFavoritesCookie"); 132 if (clientFavorites.toUpperCase().indexOf(itemId.toUpperCase()) >= 0) { 133 $(item).show(); 134 $(item).attr("jq_oper_type", "REMOVE"); 135 if (itemIsWidget) { 136 $(itemOn).css("opacity", "1"); 137 $(itemOn).show(); 138 } else { 139 $(item).html("\ 140 <div class=\"cc-svg cc-svg-bookmark-active\"><span>Salva</span></div>\ 141 <span class=\"cc-button-label\" > Rimuovi da my FIT</span >\ 142 "); 143 } 144 145 } else { 146 $(item).show(); 147 $(item).attr("jq_oper_type", "ADD"); 148 149 if (itemIsWidget) { 150 $(itemOff).show(); 151 $(item).addClass("cc-favorite-off"); 152 153 } else { 154 $(item).html("\ 155 <div class=\"cc-svg cc-svg-bookmark\"><span>Salva</span></div>\ 156 <span class=\"cc-button-label\" > Salva in my FIT</span >\ 157 "); 158 } 159 } 160 161 } 162 163 function showPopUpRegistrati() { 164 var onClick = ""; 165 onClick = "window.location.href = 'https://myfit.federtennis.it';"; 166 onClick = "jQueryV2(\'#loginRedirect\').trigger(\'click\');"; 167 var popuUp = '<div id="popup" class="cc-overlay cc-overlay-purchase cc-overlay-reserved" style="display: block;">' + 168 ' <div class="cc-overlay-main cc-overlay-main-small" style="background: white;">' + 169 ' <div class="cc-close-button">' + 170 ' <div class="cc-svg cc-svg-close-primary-color jq-popup-close"><span>Chiudi</span></div>' + 171 ' </div>' + 172 ' <section class="cc-purchase-contents">' + 173 ' <div class="cc-content-title cc-content-title-feedback">' + 174 ' <div class="cc-content-icon">' + 175 ' <div class="cc-svg cc-svg-purchase-ko"><span>Ok</span></div>' + 176 ' </div>' + 177 ' <h1 class="cc-purchase-main-title" style="color:#222225">LA FUNZIONALITA\' à RISERVATA AGLI UTENTI REGISTRATI<br></h1>' + 178 ' <p class="cc-purchase-subtitle">Registrarsi è semplice e gratuito</p>' + 179 ' </div>' + 180 ' <div class="cc-content-main-info cc-small-padding-top">' + 181 //' <p class="text-center">La visualizzazione del Canale, è riservata agli utenti registrati all\'area MyFit.<br />La registrazione è gratuita.<br />Pochi e semplici click per un mondo di contenuti Live!"<br /></p>' + 182 ' <div class="cc-content-button"><a href="#" class="cc-button cc-button-secondary jq-popup-close">Chiudi</a><a href="javascript:;" class="cc-button cc-button-primary" onclick="' + onClick + '">Accedi o registrati</a></div>' + 183 ' </div>' + 184 ' </section>' + 185 ' </div>' + 186 '</div>'; 187 188 if (jQueryV2('.cc-desktop').length > 0) { 189 jQueryV2('.cc-desktop').append(popuUp); 190 } else if (jQueryV2('.cc-mobile').length > 0) { 191 jQueryV2('.cc-mobile').append(popuUp); 192 } 193 194 jQueryV2(".jq-popup-close").on("click", function () { 195 jQueryV2("#popup").remove(); 196 }); 197 } 198 199 function showPopUpAlert(type,title,message) { 200 var typeText = '<div class="cc-svg cc-svg-purchase-ok"><span>Ok</span></div>'; 201 if(type = 'ko') 202 typeText = '<div class="cc-svg cc-svg-purchase-ko"><span>Ok</span></div>'; 203 var popuUp = '<div id="popup" class="cc-overlay cc-overlay-purchase" style="display: block;">
203' + 204 ' <div class="cc-overlay-main cc-overlay-main-small" style="background: white;" >' + 205 ' <div class="cc-close-button">' + 206 ' <div class="cc-svg cc-svg-close-primary-color jq-popup-close"><span>Chiudi</span></div>' + 207 ' </div>' + 208 ' <section class="cc-purchase-contents">' + 209 ' <div class="cc-content-title cc-content-title-feedback">' + 210 ' <div class="cc-content-icon">' + 211 typeText + 212 ' </div>' + 213 ' <h1 class="cc-purchase-main-title" style="color:#222225">' + title + '</h1>' + 214 ' <p class="cc-purchase-subtitle">' + message + '</p>' + 215 ' </div>' + 216 ' <div class="cc-content-main-info cc-small-padding-top">' + 217 ' <div class="cc-content-button"><a href="#" class="cc-button cc-button-primary jq-popup-close">Chiudi</a></div>' + 218 ' </div>' + 219 ' </section>' + 220 ' </div>' + 221 '</div>'; 222 223 if (jQueryV2('.cc-desktop').length > 0) { 224 jQueryV2('.cc-desktop').append(popuUp); 225 } else if (jQueryV2('.cc-mobile').length > 0) { 226 jQueryV2('.cc-mobile').append(popuUp); 227 } 228 229 jQueryV2(".jq-popup-close").on("click", function () { 230 jQueryV2("#popup").remove(); 231 }); 232 } 233 234 function loadContentFavorite() { 235 if(localStorage.getItem("Guid") == "" || localStorage.getItem("Guid") == undefined || localStorage.getItem("Guid") == null) { 236 return null; 237 } 238 else { 239 return jQueryV2.ajax({ 240 url: "https://dp-fit-prod-function.azurewebsites.net/api/v6/player/favourites/list", 241 type: "POST", 242 dataType: "json", 243 data: JSON.stringify({"guid" : String(localStorage.getItem("Guid"))}), 244 contentType: "application/json; charset=utf-8" 245 }); 246 } 247 } 248 249 function saveContentFavorite(itemId,typologyId) { 250 if(localStorage.getItem("Guid") == "" || localStorage.getItem("Guid") == undefined || localStorage.getItem("Guid") == null) { 251 showPopUpRegistrati(); 252 return false; 253 } 254 jQueryV2.ajax({ 255 url: "https://dp-fit-prod-function.azurewebsites.net/api/v6/player/favourites/add", 256 type: "POST", 257 dataType: "json", 258 data: JSON.stringify({"guid" : String(localStorage.getItem("Guid")),"member" : String(localStorage.getItem("Member")),"teacher" : String(localStorage.getItem("Teacher")),"udg" : String(localStorage.getItem("Udg")),"acceptProfilation" : String(localStorage.getItem("AcceptProfilation")),"hashKey" : String(localStorage.getItem("Hashkey")),"favouriteSite" : "1", "favouriteGuid" : itemId, "favouriteId" : null, "favouriteTipology": typologyId, "favouriteCategory": null}), 259 contentType: "application/json; charset=utf-8", 260 success: function (res) { 261 if (res.statusCode === 200) { 262 loadContentFavorite().then(function(res) { 263 localStorage.setItem("contentFavorites",JSON.stringify(res)); 264 activateContentFavorite(); 265 }); 266 } 267 else { 268 showPopUpAlert("ko","Errore","L'operazione non è andata a buon fine"); 269 } 270 }, 271 error: function (data) { 272 showPopUpAlert("ko","Errore","L'operazione non è andata a buon fine"); 273 } 274 }); 275 } 276 277 function removeContentFavorite(favoriteGuid) { 278 if(localStorage.getItem("Guid") == "" || localStorage.getItem("Guid") == undefined || localStorage.getItem("Guid") == null) { 279 showPopUpRegistrati(); 280 return false; 281 } 282 jQueryV2.ajax({ 283 url: "https://dp-fit-prod-function.azurewebsites.net/api/v6/player/favourites/del", 284 type: "POST", 285 dataType: "json", 286 data: JSON.stringify({"guid" : String(localStorage.getItem("Guid")),"member" : String(localStorage.getItem("Member")),"teacher" : String(localStorage.getItem("Teacher")),"udg" : String(localStorage.getItem("Udg")),"acceptProfilation" : String(localStorage.getItem("AcceptProfilation")),"hashKey" : String(localStorage.getItem("Hashkey")),"favouriteGuid" : favoriteGuid}), 287 contentType: "application/json; charset=utf-8", 288 success: function (res) { 289 if (res.statusCode === 200) { 290 loadContentFavorite().then(function(res) { 291 localStorage.setItem("contentFavorites",JSON.stringify(res)); 292 activateContentFavorite(); 293 });
294 } 295 else { 296 //showPopUpAlert("ko","Errore","L'operazione non è andata a buon fine"); 297 loadContentFavorite().then(function(res) { 298 localStorage.setItem("contentFavorites",JSON.stringify(res)); 299 activateContentFavorite(); 300 }); 301 } 302 }, 303 error: function (data) { 304 //showPopUpAlert("ko","Errore","L'operazione non è andata a buon fine"); 305 loadContentFavorite().then(function(res) { 306 localStorage.setItem("contentFavorites",JSON.stringify(res)); 307 activateContentFavorite(); 308 }); 309 } 310 }); 311 } 312 313 function checkContentFavorite() { 314 if(localStorage.getItem("Guid") == "" || localStorage.getItem("Guid") == undefined || localStorage.getItem("Guid") == null) { 315 activateContentFavorite() 316 return false; 317 } 318 var itemId = $(".jq_save_favorite").attr("jq_item_id"); 319 if(itemId == "" || itemId == undefined || itemId == null) 320 return false; 321 var obj = jQuery.parseJSON(localStorage.getItem("contentFavorites")); 322 if(obj == null) { 323 loadContentFavorite().then(function(res) { 324 localStorage.setItem("contentFavorites",JSON.stringify(res)); 325 activateContentFavorite(); 326 }); 327 } 328 else { 329 activateContentFavorite(); 330 } 331 } 332 333 function activateContentFavorite() { 334 $(".jq_save_favorite").attr("jq_oper_type","ADD"); 335 $(".jq_save_favorite").html("<div class=\"cc-svg cc-svg-bookmark\"><span>Salva</span></div><span class=\"cc-button-label\" > Salva in my FIT</span>"); 336 $(".jq_save_favorite_header").html("<div class=\"cc-svg cc-svg-bookmark\"><span>Salva</span></div>"); 337 var obj = jQuery.parseJSON(localStorage.getItem("contentFavorites")); 338 if(obj == "" || obj == undefined || obj == null) 339 return false; 340 var itemId = $(".jq_save_favorite").attr("jq_item_id"); 341 var typologyId = $(".jq_save_favorite").attr("jq_item_typology"); 342 if(itemId == "" || itemId == undefined || itemId == null || typologyId == "" || typologyId == undefined || typologyId == null) 343 return false; 344 $.each(obj.favourites, function(i, item) { 345 if(obj.favourites[i].favouriteGuid != null && obj.favourites[i].favouriteTipology != null) { 346 if(obj.favourites[i].favouriteGuid.toLowerCase() == itemId.toLowerCase() && obj.favourites[i].favouriteTipology == typologyId) { 347 $(".jq_save_favorite").attr("jq_oper_type","REMOVE"); 348 $(".jq_save_favorite").attr("jq_favorite_delete_guid",obj.favourites[i].favouriteDeleteGuid); 349 $(".jq_save_favorite").html("<div class=\"cc-svg cc-svg-bookmark-active\"><span>Salva</span></div><span class=\"cc-button-label\" > Rimuovi da my FIT</span>"); 350 $(".jq_save_favorite_header").html("<div class=\"cc-svg cc-svg-bookmark-active\"><span>Salva</span></div>"); 351 } 352 } 353 }); 354 } 355 356 }); 357 358})(jQueryV2);
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.