"); } // only if button was added if($(".follow-button").length) { $(".follow-button").click(function(){ var promise = isFollowing(); promise.then(function(result) { if (result) { unfollow(); } else { follow(); } }); }); // initial load toggleFollowButton(); } function toggleFollowButton() { var button = $(".follow-text"), promise = isFollowing(); promise.then(function(result) { if (result) { button.text(followingLabel); button.css("color", "#6c6d6f"); $(".follow-button").css("border-color", "#6c6d6f"); } else { button.text(followLabel); button.css("color", "#007aff"); $(".follow-button").css("border-color", "#007aff"); } }); } function isFollowing() { var promise = getMyPreferences(); return promise.then(function(result) { let myPlayers = result.myPlayers; if (myPlayers.length > 0) { for (var i = 0;i < myPlayers.length; i++) { if (myPlayers[i].guid === guid) { return true; } } } return false; }); } function getMyPreferences() { return new Promise(function(resolve, reject) { jQuery.when(fanAPI.getAsP13n()).done(resolve).fail(reject); }); } function follow() { var promise = new Promise(function(resolve, reject) { fanAPI.createPreference({ preferenceTypeId: 3, entityId: guid }, { success: function(preference) { resolve((preference && preference.preference_id) !== undefined); }, error: reject }); }); promise.then(function(result) { toggleFollowButton(); }); } function unfollow() { var preferences = getMyPreferences(), pId = null; preferences.then(function(result) { let myPreferences = result.myPreferences; for (var i = 0; i < myPreferences.length; i++) { if (myPreferences[i].metaData.guid === guid) { pId = myPreferences[i].id; break; } } if (pId !== null) { var promise = new Promise(function(resolve, reject) { fanAPI.deletePreference({ preferenceTypeId: 3, preferenceId: pId, entityId: guid }, { success: function(result) { resolve(true); }, error: reject }); }); promise.then(function(result) { if (result) { toggleFollowButton(); } }); } }); } }); })(jQuery);
Ir a
DJ LeMahieu
Perfil de Jugador
Estadsticas
Splits
Resumen de Juegos
Bateo vs Lanzamiento
Zonas calientes
Vdeos
FTBOL 246zz
Resultados de Hoy
Norte/Centroamrica
Sudamrica
Europa
Clubes
Mundial
Euro 2016
MS FTBOL 4a4z5i
Espaa
Inglaterra
Italia
Champions League
Copa Libertadores
Argentina
Colombia
MS DEPORTES 1wf46
Bsquetbol
Bisbol
Boxeo
Ftbol Americano
Deporte Motor
Golf
Olmpicos
MS DEPORTES 1wf46
Rugby (Scrum.com)
ESPNtenis.com
MMA
ESPNPolo.com
ESPN Run
X Games
Otros Deportes
HERRAMIENTAS n494k
arnos
ar a ESPN TV
Mi ESPN
Servicios para
Publicidad
VIDEO 25731m
FANTASA p84b
TV 575y36
RADIO 2q333r
PODCENTER k5p1y
MOVIL 5o1i4d
PLAY 4u2w5y
REVISTA 1k5k4z
Menu
ESPN 5e5p4r
Resultados
Ftbol
Bsquetbol
MLB
F1
MMA
Boxeo
F. Americano
Ms Deportes
Tenis
Gaming
Lucha Libre
NHL
Serie del Caribe
NCAAF
Polo
NCAAM
NCAAW
Poker
Rugby
Golf
WNBA
Otros Deportes
Deporte Motor
Clsico Mundial
UFL
Olmpicos
Ediciones
Juegos
Watch
ESPN+
MLB
Portada
Resultados
Calendario
Posiciones
Estadsticas
Equipos