2018-01-18 05:53:00 +00:00
|
|
|
/**
|
|
|
|
* Comments interface with the server
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
ComunicWeb.components.comments.interface = {
|
|
|
|
|
2018-01-30 05:49:50 +00:00
|
|
|
/**
|
|
|
|
* Create a new comment
|
|
|
|
*
|
|
|
|
* @param {number} postID The ID of the target post
|
|
|
|
* @param {FormData} data The data of the new comment
|
|
|
|
* @param {function} callback
|
|
|
|
*/
|
|
|
|
create: function(postID, data, callback){
|
|
|
|
|
|
|
|
//Prepare the request
|
|
|
|
var apiURI = "comments/create";
|
|
|
|
data.append("postID", postID);
|
|
|
|
|
|
|
|
//Make it
|
|
|
|
ComunicWeb.common.api.makeFormDatarequest(apiURI, data, true, callback);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-01-27 17:30:27 +00:00
|
|
|
/**
|
|
|
|
* Get informations about a single comment
|
|
|
|
*
|
|
|
|
* @param {number} commentID The ID of the comment to get
|
|
|
|
* @param {function} callback
|
|
|
|
*/
|
|
|
|
get_single: function(commentID, callback) {
|
|
|
|
|
|
|
|
//Perform a request on the API
|
|
|
|
var apiURI = "comments/get_single";
|
|
|
|
var params = {
|
|
|
|
commentID: commentID
|
|
|
|
};
|
|
|
|
|
|
|
|
//Make the request
|
|
|
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-01-27 17:00:59 +00:00
|
|
|
/**
|
|
|
|
* Update a comment content
|
|
|
|
*
|
|
|
|
* @param {number} commentID The ID of the comment to update
|
|
|
|
* @param {string} content The new content of the comment
|
|
|
|
* @param {function} callback
|
|
|
|
*/
|
|
|
|
edit: function(commentID, content, callback){
|
|
|
|
|
|
|
|
//Perform a request on the API
|
|
|
|
var apiURI = "comments/edit";
|
|
|
|
var params = {
|
|
|
|
commentID: commentID,
|
|
|
|
content: content
|
|
|
|
};
|
|
|
|
|
|
|
|
//Make the request
|
|
|
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2018-01-23 05:49:19 +00:00
|
|
|
/**
|
|
|
|
* Delete a comment
|
|
|
|
*
|
|
|
|
* @param {number} commentID The ID of the comment to delete
|
|
|
|
* @param {function} callback What to do once the comment has been delete
|
|
|
|
*/
|
|
|
|
delete: function(commentID, callback){
|
|
|
|
|
|
|
|
//Perform a request on the API
|
|
|
|
var apiURI = "comments/delete";
|
|
|
|
var params = {
|
|
|
|
commentID: commentID
|
|
|
|
};
|
|
|
|
|
|
|
|
//Make the request
|
|
|
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-18 05:53:00 +00:00
|
|
|
};
|