diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 98714513..2cfb42e9 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -901,6 +901,22 @@ var ComunicWeb = { }, + /** + * Post page + */ + postPage: { + + /** + * Post page main script + */ + main: { + + //TODO: implement + + }, + + }, + /** * Login controller */ diff --git a/assets/js/pages/postPage/main.js b/assets/js/pages/postPage/main.js new file mode 100644 index 00000000..db8fd04b --- /dev/null +++ b/assets/js/pages/postPage/main.js @@ -0,0 +1,74 @@ +/** + * Post page main script + * + * @author Pierre HUBERT + */ + +ComunicWeb.pages.postPage.main = { + + /** + * Open post page + * + * @param {Object} params Parametres required to open the page + * @param {HTMLElement} target The target for the user page + */ + open: function(params, target){ + + //Check for subfolder + if(!params.subfolder){ + + //The page is considered as not found + ComunicWeb.common.error.pageNotFound(params, target); + return; + + } + + //Get the ID of the post + var postID = Math.floor((params.subfolder)*1); + + //Check for error + if(postID < 1 || isNaN(postID)){ + var errorMsg = ComunicWeb.common.messages.createCalloutElem("Error", "The specified post ID is invalid!", "danger"); + target.appendChild(errorMsg); + return; + } + + //Now the post can be displayed + this.display(postID, target); + }, + + /** + * Display the post page + * + * @param {numbert} postID The ID of the post to display + * @param {HTMLElement} target The target for the post + */ + display: function(postID, target){ + + //Get informations about the post + ComunicWeb.components.posts.interface.get_single(postID, function(response){ + + //Check for errors + if(response.error){ + + //Post considered as not found + ComunicWeb.common.error.pageNotFound({}, target); + return; + + } + + //Create post contener + var postContener = createElem2({ + appendTo: target, + type: "div" + }); + + //Display the post + ComunicWeb.components.posts.ui.display_post(response, postContener); + + }); + + } + + +} \ No newline at end of file diff --git a/assets/js/pagesList.js b/assets/js/pagesList.js index ce57a18b..3237280a 100644 --- a/assets/js/pagesList.js +++ b/assets/js/pagesList.js @@ -23,6 +23,15 @@ ComunicWeb.pagesList = { disableMenus: false, }, + /** + * Single post page + */ + post: { + pageTitle: "Post", + methodHandler: "ComunicWeb.pages.postPage.main.open", + disableMenus: false + }, + /** * Login page */ diff --git a/system/config/dev.config.php b/system/config/dev.config.php index f71140a8..10732df4 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -267,6 +267,9 @@ class Dev { "js/pages/userPage/profileInfos.js", "js/pages/userPage/posts.js", + //Post page + "js/pages/postPage/main.js", + //Login page "js/pages/login.js",