Add Follow Button to Mini-Profile [Updated 7 Sept 2022]
Sept 1, 2022 1:59:26 GMT -8
tek and peekabooicu like this
Post by Chris on Sept 1, 2022 1:59:26 GMT -8
Inspiration:
How to add Follow Button in Mini-profile by tekPreview:
Location:
Global Footer(or Board footer if want only operating in specific board(s) )
Code:
<script>
$(function(){
const profileFollowIcon = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAKj0lEQVR4nO3de4wWVxnH8e/usoTLAkrBtjQqlBarxADaUFJNi2iLjVFqbOq9WomKJpqoMWlj0tRrjPEPE02Ml6oFtVprrLHxUvHSQNJIGxCwFduiFOTSFtpd1rLAXvCPBxIKvPPO7HvOeeby+yTPXyzvPHPe87wzc+bMGRARERERERERERERERERERERERERERERERERERERERERERERERERkVLr8k5AXmAasBR4JXDZybgQmH7y3/qAEeAwMAgMADuBHSdjG/AIMJY6cZEYuoArgNuBjcAwcKLDeBq4C1gNvCTdroiEMwe4BfvV77QgsmIYuBdYBfQm2TORDiwA1mKnSTEL41yxF/gEMCn6XooUdDHwY2CU9IVxZuzDCkVHFHHXC9wKDOFfGGfGVuz6R8TF5cB2/AshK8aAbwFTIrWByFm6gDXAMfwLoMjR5JIYjSFyuinYRbh3hx9PDADXh28SETMDu5fh3dE7iTHgY6EbRmQ2sBn/Dh4qbgnbPNJks4BH8e/UoeO2kI0kzTQFeBD/zhwrVodrKmmaHuBX+HfimDECXBeqwaRZvoh/B04Rg2gIWApajo34eHfeVLEJmBik5SqmxzuBCjoP+CP2jEZTXIQVyHrvRKT81uH/i+4RY9jDXCItvQ7/juoZfwO6O25FqaUe6nUzcLxxc6cNKfX0Afw7ZxniADC5w7asDF2k59ONPec9yzuREujDnk582DsRKY9V+P9ylyl2AhM6alGplarP0o0R7+yoRaU2FuDfGcsYv++kUatCQ3btvdc7gZK6BjjfO4nYVCDZulCBtNIN3OidRGwqkGyLgPneSZTYDd4JxKYCybbcO4GSW0bN74moQLKpQLJNxIqktlIVS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PO9g7z+iz0Hvx5bIT7k+8enYqewK4A3AVcQ9hHbKnoOW73lySL/KXWBrKfGQ3EdOoj9eOzAHgneA+zFbtT1Y6ekw9hpWi/2IzMDuBA7bZqPTZFfeDIacV+goPUUPJKkLJC3YHeeRTxdj10T5pKyQDYAr0+4PZFzeQh72jKXVAWyADttECmDJdhN3bZSDTu+LdF2RPLI/f6TVAWiUyspkxV5/zBVgWjlcCmTReS8vEhVIHMSbUckjynABXn+MFWBxFp8TWS8zsvzR6kKpAmPpkq15JpZUIbJcyKlpQIRyaACEcmgAhHJoAIRyaACEcmgAhHJoAIRyaACEcmgAhHJoAIRyaACEcmgAhHJoAKRphrL80epCmQg0XZE8urP80epCiTXChIiiRzCFuZrK1WB/DzRdkTyuAdbs7etVE/6TQYeRW8oFX9DwKuwhcTbSnUEGQLeg70oR8TTGnIWh4ergQP4L4evaF4cAW6ioNQrgD8J3IG9o2Iueg2CxHcIWAe8G3ig6H/2Xm3kAmA2WqpfwhvDhnL3YEcQERERERERERERERERERERERERERERERERERERERERERERERERkcr6P92BuuzvC7ttAAAAAElFTkSuQmCC`;
const user = pb.data('user');
if(user.id < 1) return;
const page = pb.data('page');
const friends = Object.keys(user.friends);
const storageID = `following-${user.id}`;
let following = loadStorage()||[];
if(!following.length || following.length < friends.length){
//use friends (those also following you) as starting point to build list
following = [...new Set(following.concat(friends.map(o=>+o)))];
}
user.id && pb.data('proboards.post') && (function addProfileImages($button,follow_html,unfollow_html){
const content = proboards.listManagers[pb.data('lm_id')].content;
const posts = pb.data('proboards.post')
//debugger;
pb.events.on('afterSearch', (function addFollow(){
user.id && $.each(posts,function(i,e){
if(e.created_by && e.created_by !== +user.id){
const post = $('#post-'+e.id,content).filter(':not([data-author])').attr('data-author',e.created_by);
const miniProfile = $('.mini-profile',post).css('position','relative').addClass('follow-user');
let placement = $('.follow-button',post);
placement[0] || (placement = miniProfile);
let button = $button.clone().appendTo(placement).addClass('follow follow-'+e.created_by)
.each((j,k)=>{
let $k = $(k), tx = $k.html(follow_html).html();
if(following.indexOf(+e.created_by) !== -1){
$k.html(tx.replace(follow_html,unfollow_html));
miniProfile.addClass('following');
}else{
$k.html(follow_html);
}
})
.on('click', /*':not(.ui-state-disabled)',*/ function(ev) {
const t = this;
const buttons = $('.follow-'+e.created_by,content);
return ev.preventDefault(),
proboards.ajax({
url: proboards.route("follow_user"),
data: {
user_id: e.created_by
},
success: function(d) {
if(d.new_button_text === 'Unfollow'){
$(buttons).html(unfollow_html)
following = [...new Set(following.concat([e.created_by]))];
miniProfile.addClass('following');
}else{
$(buttons).html(follow_html);
const i = following.indexOf(e.created_by); i>-1 && following.splice(i,1);
miniProfile.removeClass('following');
}
},
complete: function() {
saveStorage(following)
}
}),
!1
})
}
})
return addFollow
})())
})(
$('<div style="position:absolute;top:4px;right:4px;width:2em;max-width:26px;cursor:pointer;">Follow</div>'),
`<div title="Follow this user" style="width:100%;height:100%;border-radius:100%;background:transparent;position:absolute;"> </div><img style="z-index:-1;width:100%;" src="${profileFollowIcon}">`,
`<div title="Unfollow this user" style="width:100%;height:100%;border-radius:9999px;position:absolute;background:transparent;"><img style="position:absolute;top:.1em;left:0;width:1em;" src="//storage.proboards.com/1/images/oxXTrXQCO_VQNXbmUIiS.png"></div><img style="z-index:-1;width:100%;" src="${profileFollowIcon}">`
)
/* Harvest follows from user profiles and member page listings */
if(pb.data('proboards.user') && pb.data('following') && pb.data('current_user_id') == user.id){
//members listing page
following = [...new Set(following.concat(Object.keys(pb.data('following')).map(o=>+o)))]
saveStorage(following);
} else {
//profile pages
page && page.member && $(function(){
//monitor follow button on profile page for changes
$('.follow_button').each((i,follow_button)=>{
let $follow_button = $(follow_button);
$follow_button.text() == 'Unfollow' && following.indexOf(+page.member.id) == -1
&& following.push(+page.member.id), saveStorage(following);
const followObserver = new MutationObserver(function(mutationList, observer){ //debugger;
mutationList.forEach((mutation)=>{
switch (mutation.type){
/*case "characterData":
if(muatation.characterDataOldValue == "Unfollow"){
const i = following.indexOf(+page.member.id); i>-1 && following.splice(i,1);
}else{
following = [...new Set(following.concat([+page.member.id]))];
}
saveStorage(following);
break;*/
case "childList":
if(mutation.addedNodes[0] && mutation.addedNodes[0].nodeType === 3 && /follow/i.test(mutation.addedNodes[0].data)){
if(mutation.addedNodes[0].nodeValue == "Unfollow"){
const i = following.indexOf(+page.member.id); i>-1 && following.splice(i,1);
}else{
following = [...new Set(following.concat([+page.member.id]))];
}
saveStorage(following);
}
break;
}
})
})
followObserver.observe($follow_button[0].parentNode, {characterDataOldValue:true, subtree:true, childList:true})
})
//scrub shortened following list on current user profile page for user ids not already saved
//note: jQuery map allowed to mutate array via callback return value
user.id == page.member.id && $('#following .mini-avatar .avatar-wrapper').map((i,e)=>{
const uid = +$(e).idFromClass('avatar');
if(following.indexOf(uid) === -1 ){ return following.push(uid);}
return null;
}).length && saveStorage(following);
//scrub shortened followers list on other user profile pages for current user id and add if not already in list
//note: jQuery map allowed to mutate array via callback return value
user.id != page.member.id && $('#followers .mini-avatar .avatar-wrapper').map((i,e)=>{
const uid = +$(e).idFromClass('avatar');
if(uid === user.id ){ return following.push(+page.member.id);}
return null;
}).length && saveStorage(following)
})
}
function loadStorage(id=storageID){
const v = localStorage[id];
return v ? JSON.parse(v) : v;
}
function saveStorage(v=following,id=storageID){
v = v.map(p=>+p).filter(p=>p>0)
localStorage[id] = JSON.stringify([...new Set(v)]); //ensure no duplicate values in array when saving
}
});
</script>
OLD CODE (retired 7 Sept 2022)
<script>
$(function(){
const profileFollowIcon = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAKj0lEQVR4nO3de4wWVxnH8e/usoTLAkrBtjQqlBarxADaUFJNi2iLjVFqbOq9WomKJpqoMWlj0tRrjPEPE02Ml6oFtVprrLHxUvHSQNJIGxCwFduiFOTSFtpd1rLAXvCPBxIKvPPO7HvOeeby+yTPXyzvPHPe87wzc+bMGRARERERERERERERERERERERERERERERERERERERERERERERERERkVLr8k5AXmAasBR4JXD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8TTGnIWh4ergQP4L4evaF4cAW6ioNQrgD8J3IG9o2Iueg2CxHcIWAe8G3ig6H/2Xm3kAmA2WqpfwhvDhnL3YEcQERERERERERERERERERERERERERERERERERERERERERERERERkcr6P92BuuzvC7ttAAAAAElFTkSuQmCC`;
const user = pb.data('user');
user.id && pb.data('proboards.post') && (function addProfileImages($button,follow_html,unfollow_html){
const content = proboards.listManagers[pb.data('lm_id')].content;
const posts = pb.data('proboards.post'), friends = Object.keys(user.friends);
let following = loadStorage()||[]; debugger;
if(!following.length || following.length < friends.length){
//use friends (those also following you) as starting point to build list
following = [...new Set(following.concat(friends.map(o=>+o)))];
}
pb.events.on('afterSearch', (function addFollow(){
user.id && $.each(posts,function(i,e){
if(e.created_by && e.created_by !== +user.id){
const post = $('#post-'+e.id,content).filter(':not([data-author])').attr('data-author',e.created_by);
const miniProfile = $('.mini-profile',post).css('position','relative').addClass('follow-user');
let placement = $('.follow-button',post);
placement[0] || (placement = miniProfile);
let button = $button.clone().appendTo(placement).addClass('follow follow-'+e.created_by)
.each((j,k)=>{
let $k = $(k), tx = $k.html(follow_html).html();
if(following.indexOf(+e.created_by) !== -1){
$k.html(tx.replace(follow_html,unfollow_html));
miniProfile.addClass('following');
}else{
$k.html(follow_html);
}
})
.on('click', /*':not(.ui-state-disabled)',*/ function(ev) {
const t = this;
const buttons = $('.follow-'+e.created_by,content);
return ev.preventDefault(),
proboards.ajax({
url: proboards.route("follow_user"),
data: {
user_id: e.created_by
},
success: function(d) {
if(d.new_button_text === 'Unfollow'){
$(buttons).html(unfollow_html)
following = [...new Set(following.concat([e.created_by]))];
miniProfile.addClass('following');
}else{
$(buttons).html(follow_html);
const i = following.indexOf(e.created_by); i>-1 && following.splice(i,1);
miniProfile.removeClass('following');
}
},
complete: function() {
saveStorage(following)
}
}),
!1
})
}
})
return addFollow
})())
function loadStorage(){
const v = localStorage['following-'+user.id];
return v ? JSON.parse(v) : v;
}
function saveStorage(v){
localStorage['following-'+user.id] = JSON.stringify(v)
}
})(
$('<div style="position:absolute;top:4px;right:2px;width:2em;cursor:pointer;">Follow</div>'),
`<div title="Follow this user" style="width:100%;height:100%;border-radius:9999px;background:transparent;position:absolute;"> </div><img style="z-index:-1;width:100%;" src="${profileFollowIcon}">`,
`<div title="Unfollow this user" style="width:100%;height:100%;border-radius:9999px;position:absolute;background:transparent;"><img style="position:absolute;top:.1em;left:0;width:1em;" src="//storage.proboards.com/1/images/oxXTrXQCO_VQNXbmUIiS.png"></div><img style="z-index:-1;width:100%;" src="${profileFollowIcon}">`
)
})//()
</script>
Notes:
- Code only knows who you are already following if they are in your friends list (you follow them, and they follow you) but builds its own list over time with that as the starting point
- Code does not modify your mini-profile only the mini-profile of others since following yourself is a dog chasing its tail
- Added eager harvesting techniques (7 Sept 2022) so code can know a lot more quickly the full list of who you are following; head to the members page of your forum to have the entire list of members you are following recorded by the code to be used going forward. If localStorage is cleared, this can also be used to restore the list.