ComunicWeb/assets/js/pages/groups/main.js

74 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-07-02 06:07:59 +00:00
/**
* Groups main script
*
* @author Pierre HUBERT
*/
ComunicWeb.pages.groups.main = {
/**
2018-07-02 06:07:59 +00:00
* Open settings page
*
* @param {object} args Optionnal arguments
* @param {HTMLElement} target The target for the page
*/
open: function(args, target){
//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);
}
//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-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
else
ComunicWeb.common.error.pageNotFound(args, target);
}
2018-07-02 06:07:59 +00:00
};