trying to fix redirect to home bug

This commit is contained in:
Bachir Soussi Chiadmi
2018-04-04 14:51:47 +02:00
parent 7b11b8b1f0
commit dc315a0e24
4 changed files with 20 additions and 12 deletions
@@ -1,3 +1,4 @@
console.log('history');
// https://plainjs.com/javascript/utilities/set-cookie-get-cookie-and-delete-cookie-5/
function setCookie(name, value, days) {
var d = new Date;
@@ -7,6 +8,7 @@ function setCookie(name, value, days) {
// var edlp is provided by edlp_ajax.module file
if(edlp.redirect){
console.log('history redirect');
document.body.style.visibility = 'hidden';
// record current (will be origin) sys_path in cookie
var cookiename = "edlp_origin_path";
@@ -15,5 +17,6 @@ if(edlp.redirect){
// redirect to home
window.location.replace(window.location.origin);
}else{
console.log('history do not redirect');
document.body.style.visibility = 'visible';
}
@@ -16,7 +16,7 @@
// | || ' \| | _|
// |___|_||_|_|\__|
function init(){
// console.log("EdlpTheme init()");
console.log("EdlpTheme init()");
initHistory();
@@ -78,7 +78,6 @@
// });
};
// _ _
// /_\ (_)__ ___ __
// / _ \ | / _` \ \ /
@@ -130,7 +129,7 @@
_$body.removeClass('ajax-loading');
};
function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
// console.log('ajax loaded : data', data);
console.log('ajax loaded url:'+url+' ajax_path:'+ajax_path+' sys_path:'+sys_path+' data', data);
// reset all style may been added by other pages (like masonry for productions)
// and replace all content with newly loaded
@@ -261,14 +260,16 @@
if(origin_path){
var path_elements = origin_path.split('~~');
console.log(path_elements);
var sys_path = path_elements[0];
var url = path_elements[1];
// create history state
var state = {
ajax_path: parseAjaxSysPath(path_elements[0]),
sys_path: path_elements[0],
ajax_path: parseAjaxSysPath(sys_path),
sys_path: sys_path,
};
console.log('state', state);
// record history state
history.replaceState(state, null, path_elements[1]);
history.replaceState(state, null, url);
// load content through ajax
ajaxLoadContent(null, state.sys_path, state.ajax_path);
// reset the cookie
@@ -1,3 +1,4 @@
console.log('history');
// https://plainjs.com/javascript/utilities/set-cookie-get-cookie-and-delete-cookie-5/
function setCookie(name, value, days) {
var d = new Date;
@@ -7,6 +8,7 @@ function setCookie(name, value, days) {
// var edlp is provided by edlp_ajax.module file
if(edlp.redirect){
console.log('history redirect');
document.body.style.visibility = 'hidden';
// record current (will be origin) sys_path in cookie
var cookiename = "edlp_origin_path";
@@ -15,5 +17,6 @@ if(edlp.redirect){
// redirect to home
window.location.replace(window.location.origin);
}else{
console.log('history do not redirect');
document.body.style.visibility = 'visible';
}
@@ -16,7 +16,7 @@
// | || ' \| | _|
// |___|_||_|_|\__|
function init(){
// console.log("EdlpTheme init()");
console.log("EdlpTheme init()");
initHistory();
@@ -78,7 +78,6 @@
// });
};
// _ _
// /_\ (_)__ ___ __
// / _ \ | / _` \ \ /
@@ -130,7 +129,7 @@
_$body.removeClass('ajax-loading');
};
function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
// console.log('ajax loaded : data', data);
console.log('ajax loaded url:'+url+' ajax_path:'+ajax_path+' sys_path:'+sys_path+' data', data);
// reset all style may been added by other pages (like masonry for productions)
// and replace all content with newly loaded
@@ -261,14 +260,16 @@
if(origin_path){
var path_elements = origin_path.split('~~');
console.log(path_elements);
var sys_path = path_elements[0];
var url = path_elements[1];
// create history state
var state = {
ajax_path: parseAjaxSysPath(path_elements[0]),
sys_path: path_elements[0],
ajax_path: parseAjaxSysPath(sys_path),
sys_path: sys_path,
};
console.log('state', state);
// record history state
history.replaceState(state, null, path_elements[1]);
history.replaceState(state, null, url);
// load content through ajax
ajaxLoadContent(null, state.sys_path, state.ajax_path);
// reset the cookie