Created
May 3, 2019 10:48
-
-
Save jack2jm/33fd912979e66c9db543f06cffa30fdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('click', '.follow-action, .no-events-follow-action', function (ev) { | |
var fid="";var ftype="";var t= $(this); var btntext="Following"; | |
if(logged){ | |
try{ | |
var fid =$(this).attr('data-id'); | |
var ftype =$(this).attr('data-type'); | |
}catch(e){} | |
if(fid!="" && ftype!=""){ | |
if(ftype=="organizer"){ | |
}else if(ftype=="city"){ | |
btntext = "Subscribed"; | |
} | |
follow(ftype,fid,t,function(data,t){ | |
if(data.error==0){ | |
t.addClass('disabled'); | |
t.html(btntext); | |
window.location.reload(); | |
} | |
else{ | |
console.log(data.message); | |
} | |
}); | |
} | |
} | |
else{ | |
var cid = "fid-"+parseInt(Math.random()*100000); | |
$(this).addClass(cid); | |
window.cid=cid; | |
window.cb=function(){jQuery(".follow-action").click()}; | |
login_popup('function|cb()', "connect"); | |
} | |
try{ | |
var l=(logged)?1:0; ga('send', 'event', 'Followings', 'Follows', fid, l, { nonInteraction: true }); | |
}catch(e){console.log(e);} | |
return false; | |
}); | |
function follow(type, value,t,callback) { | |
var postData = { | |
"type": type, | |
"value": value | |
} | |
if(typeof(t)=="undefined"){t=0;} | |
if(typeof(callback)=="undefined"){callback =function(){};} | |
$.post(wsbase+'/users/web/follow', | |
JSON.stringify(postData), | |
function (data) { | |
callback(data,t); | |
}, | |
"json" | |
).fail(function () { | |
callback('false',t); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment