Update like status on the database

This commit is contained in:
Pierre 2017-12-29 09:58:40 +01:00
parent e834b06b16
commit 1147ab787e
4 changed files with 38 additions and 0 deletions

View File

@ -625,6 +625,13 @@ var ComunicWeb = {
//TODO : implement
},
/**
* Likes API interface
*/
interface: {
//TODO : implement
}
},
/**

View File

@ -88,6 +88,7 @@ ComunicWeb.components.like.button = {
count = newliking ? count + 1 : count - 1;
//Update liking status on the API
ComunicWeb.components.like.interface.update(kind, id, newliking);
//Display liking element again
ComunicWeb.components.like.button.display(kind, id, count, newliking, target);

View File

@ -0,0 +1,29 @@
/**
* Likes API interface
*
* @author Pierre HUBERT
*/
ComunicWeb.components.like.interface = {
/**
* Update like status
*
* @param {String} type The type of component
* @param {Integer} id The ID of the element
* @param {Boolean} like New like status
*/
update: function(type, id, like){
//Perform an API request
var apiURI = "likes/update";
var params = {
type: type,
id: id,
like: like
};
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true);
}
}

View File

@ -160,6 +160,7 @@ $config['JSfiles'] = array(
//Like button
"%PATH_ASSETS%js/components/like/button.js",
"%PATH_ASSETS%js/components/like/interface.js",
//Modern textarea handler
"%PATH_ASSETS%js/components/textarea.js",