Parse URL arguments

This commit is contained in:
Pierre 2017-12-24 16:24:31 +01:00
parent bb3703bf1e
commit 2bdcf71809

View File

@ -100,9 +100,14 @@ ComunicWeb.common.page = {
* @return {Boolean} True for a success * @return {Boolean} True for a success
*/ */
openPage: function(pageURI, additionnalData){ openPage: function(pageURI, additionnalData){
//Log message //Log message
ComunicWeb.debug.logMessage("Open the following page: " + pageURI); ComunicWeb.debug.logMessage("Open the following page: " + pageURI);
//Check if some additionnal data was specified
if(!additionnalData)
additionnalData = {};
//Extract the first part of the URL //Extract the first part of the URL
var firstPartURI = pageURI.toString(); var firstPartURI = pageURI.toString();
@ -112,8 +117,33 @@ ComunicWeb.common.page = {
} }
//Check if there are $_GET parametres included with the URL //Check if there are $_GET parametres included with the URL
if(firstPartURI.includes("?") != -1){ if(firstPartURI.includes("?")){
firstPartURI = firstPartURI.split("?")[0]; var split = firstPartURI.split("?");
firstPartURI = split[0];
additionnalData.urlArgs = {};
//Process the arguments
var list = split[1].split("&");
for(i in list){
//Check if it is a real argument
if(list[i].length > 0){
if(!list[i].includes("=")){
additionnalData.urlArgs[list[i]] = null;
} else {
//Add the argument to the list
var argument = list[i].split("=");
additionnalData.urlArgs[argument[0]] = argument[1];
}
}
}
} }
//Check if pageURI is empty //Check if pageURI is empty
@ -210,10 +240,6 @@ ComunicWeb.common.page = {
} }
} }
//Check if some additionnal data was specified
if(!additionnalData)
additionnalData = {};
//Add the subfolder URI (if any) //Add the subfolder URI (if any)
if(subfoldersURI){ if(subfoldersURI){
additionnalData.subfolder = subfoldersURI; additionnalData.subfolder = subfoldersURI;