mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
26 lines
827 B
JavaScript
26 lines
827 B
JavaScript
const fav = {};
|
|
|
|
fav.checkFav = (id, type, divId, iconId) => {
|
|
$.ajax({
|
|
type: 'get',
|
|
url: '/favs/check_favorites/'+ id+"/" +type,
|
|
success: function (response) {
|
|
if(response.length == 0) {
|
|
$(divId).attr("href", "/favs/add_fav/" + id+ "/"+type);
|
|
$(iconId).attr("class", "fa fa-heart-o");
|
|
} else {
|
|
$(divId).attr("href", "/favs/delete_fav/" + id + "/" + "adv");
|
|
$(iconId).attr("class", "fa fa-heart");
|
|
}
|
|
},
|
|
error:function (err) {
|
|
// reject(Error("It broke"));
|
|
}
|
|
});
|
|
};
|
|
|
|
var id = $('#adv_id').val();
|
|
var owner = $('#owner').data('content');
|
|
|
|
fav.checkFav(id,'adv', '.favorites', '#heart-icon-adv');
|
|
fav.checkFav(owner,'seller', '#owner-fav', '#heart-icon-seller'); |