2018-07-02 06:07:59 +00:00
|
|
|
/**
|
|
|
|
* Groups main script
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
ComunicWeb.pages.groups.main = {
|
|
|
|
|
2018-07-02 06:42:55 +00:00
|
|
|
/**
|
2018-07-29 15:17:54 +00:00
|
|
|
* Open groups page
|
2018-07-02 06:07:59 +00:00
|
|
|
*
|
|
|
|
* @param {object} args Optionnal arguments
|
|
|
|
* @param {HTMLElement} target The target for the page
|
|
|
|
*/
|
|
|
|
open: function(args, target){
|
|
|
|
|
2018-07-02 06:42:55 +00:00
|
|
|
//Determine which page / group should be opened
|
|
|
|
if(!args.subfolder)
|
|
|
|
var page = "main";
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
//Extract the name of the page from the URL
|
|
|
|
if(!args.subfolder.includes("/"))
|
|
|
|
var page = args.subfolder;
|
|
|
|
else {
|
|
|
|
var page = args.subfolder.split("/")[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check if the main page has to be opened
|
2018-07-05 11:17:33 +00:00
|
|
|
if(page == "main"){
|
|
|
|
if(!signed_in()) openPage("login");
|
2018-07-03 09:45:57 +00:00
|
|
|
return ComunicWeb.pages.groups.pages.main.open(target);
|
2018-07-02 06:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Check if the page to create a group has to be opened
|
2018-07-05 11:17:33 +00:00
|
|
|
else if (page == "create"){
|
|
|
|
if(!signed_in()) openPage("login");
|
2018-07-03 09:45:57 +00:00
|
|
|
return ComunicWeb.pages.groups.pages.create.open(target);
|
2018-07-02 06:42:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 09:45:57 +00:00
|
|
|
//Else determine which group page to open (specified after the ID of the group)
|
|
|
|
var groupID = page;
|
|
|
|
if(args.subfolder.split("/").length < 2){
|
|
|
|
page = "group";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//Extract the page to open from the URL
|
|
|
|
page = args.subfolder.split("/")[1];
|
|
|
|
|
|
|
|
//Check if there is nothing after "/"
|
|
|
|
if(page.length < 2)
|
|
|
|
page = "group";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check which page to open
|
2018-07-04 04:05:14 +00:00
|
|
|
if(page == "group")
|
2018-07-03 09:45:57 +00:00
|
|
|
ComunicWeb.pages.groups.pages.group.open(groupID, target);
|
2018-07-04 04:05:14 +00:00
|
|
|
|
|
|
|
else if(page == "settings")
|
|
|
|
ComunicWeb.pages.groups.pages.settings.open(groupID, target);
|
2018-07-07 13:27:27 +00:00
|
|
|
|
|
|
|
else if(page == "members")
|
|
|
|
ComunicWeb.pages.groups.pages.members.open(groupID, target);
|
2018-07-04 04:05:14 +00:00
|
|
|
|
2018-07-03 09:45:57 +00:00
|
|
|
|
|
|
|
//Unrecognized page
|
2018-07-02 06:42:55 +00:00
|
|
|
else
|
|
|
|
ComunicWeb.common.error.pageNotFound(args, target);
|
|
|
|
}
|
|
|
|
|
2018-07-02 06:07:59 +00:00
|
|
|
};
|