mirror of
https://github.com/neocities/neocities.git
synced 2025-07-25 11:58:28 +02:00
following button on site
This commit is contained in:
parent
51a85a0b03
commit
0a29a496d7
5 changed files with 62 additions and 18 deletions
16
public/assets/scripts/news/site.js
Normal file
16
public/assets/scripts/news/site.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
var Site = {
|
||||
toggleFollow: function(siteId, csrfToken) {
|
||||
var link = $('a#followLink')
|
||||
var span = $('a#followLink span')
|
||||
$.post('/site/'+siteId+'/toggle_follow', {csrf_token: csrfToken}, function(res) {
|
||||
console.log(res)
|
||||
if(res.result == "followed") {
|
||||
span.text('Unfollow')
|
||||
link.removeClass('follow')
|
||||
} else if(res.result == 'unfollowed') {
|
||||
span.text('Follow')
|
||||
link.addClass('follow')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue