2017-01-08 15:17:22 +00:00
|
|
|
/**
|
|
|
|
* URL functions
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
2017-01-21 18:30:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
ComunicWeb.common.url = {
|
|
|
|
/**
|
|
|
|
* Return current URL opened on the website
|
|
|
|
*
|
|
|
|
* @return {String} The URL opened on the website
|
|
|
|
*/
|
|
|
|
getCurrentWebsiteURL: function(){
|
|
|
|
//Retrieve website URL
|
|
|
|
var websiteURL = location.href;
|
|
|
|
|
|
|
|
//Extract the URI part for the app
|
|
|
|
var uripage = websiteURL.replace(ComunicWeb.__config.siteURL, "");
|
|
|
|
|
|
|
|
//Return result
|
|
|
|
return uripage;
|
|
|
|
},
|
2017-02-24 08:57:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the current website URI
|
|
|
|
*
|
|
|
|
* @param {String} newTitle New title for the page
|
|
|
|
* @param {String} newURI The new URI
|
|
|
|
* @return {Boolean} False if it fails
|
|
|
|
*/
|
|
|
|
changeURI: function(newTitle, newURI){
|
|
|
|
|
|
|
|
//Determine the new URL
|
|
|
|
var newURL = ComunicWeb.__config.siteURL + newURI;
|
2017-03-01 14:37:55 +00:00
|
|
|
|
2017-02-24 08:57:27 +00:00
|
|
|
//Apply it
|
2017-03-01 14:37:55 +00:00
|
|
|
window.history.pushState("object or string", newTitle, newURL);
|
2017-02-24 08:57:27 +00:00
|
|
|
|
2020-04-01 13:10:03 +00:00
|
|
|
SendEvent("changeURI");
|
|
|
|
|
2017-02-24 08:57:27 +00:00
|
|
|
//Everything is OK
|
|
|
|
return true;
|
|
|
|
},
|
2017-01-21 18:30:27 +00:00
|
|
|
};
|