mirror of https://github.com/Aidaho12/haproxy-wi
Merge pull request #418 from themetronome/breadcrumbs-refactor
rework breadcrumbs logicpull/403/merge
commit
d268fc4f40
|
@ -854,44 +854,62 @@ async function ban() {
|
||||||
// var text_val = str.substring(0, beg) + str.substring(end, len);
|
// var text_val = str.substring(0, beg) + str.substring(end, len);
|
||||||
// $(id_textarea).text(text_val);
|
// $(id_textarea).text(text_val);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
function initializeHistory() {
|
||||||
|
if (!localStorage.getItem('history')) {
|
||||||
|
localStorage.setItem('history', JSON.stringify(['/login', '/login', '/login']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createHistory() {
|
function createHistory() {
|
||||||
if(localStorage.getItem('history') === null) {
|
const history = JSON.parse(localStorage.getItem('history'));
|
||||||
let get_history_array = ['login', 'login','login'];
|
const currentPath = window.location.pathname.replace(/\/$/, "");
|
||||||
localStorage.setItem('history', JSON.stringify(get_history_array));
|
const historyContainer = $('#browse_history');
|
||||||
}
|
|
||||||
|
const removeDuplicates = (arr) => {
|
||||||
|
const seen = {};
|
||||||
|
return arr.filter(item => {
|
||||||
|
const normalized = item.replace(/\/$/, "");
|
||||||
|
return seen.hasOwnProperty(normalized) ? false : (seen[normalized] = true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!history.some(path => path.replace(/\/$/, "") === currentPath)) {
|
||||||
|
let updatedHistory = [...history, currentPath];
|
||||||
|
updatedHistory = removeDuplicates(updatedHistory);
|
||||||
|
|
||||||
|
updatedHistory = updatedHistory.slice(-3);
|
||||||
|
|
||||||
|
localStorage.setItem('history', JSON.stringify(updatedHistory));
|
||||||
|
}
|
||||||
|
|
||||||
|
historyContainer.empty();
|
||||||
|
|
||||||
|
const menuLinks = {};
|
||||||
|
|
||||||
|
$('.menu li ul li a').each(function() {
|
||||||
|
const path = $(this).attr('href').replace(/\/$/, "");
|
||||||
|
menuLinks[path] = {
|
||||||
|
title: $(this).attr('title'),
|
||||||
|
text: $(this).text()
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
JSON.parse(localStorage.getItem('history')).forEach(path => {
|
||||||
|
const cleanPath = path.replace(/\/$/, "");
|
||||||
|
if (menuLinks[cleanPath]) {
|
||||||
|
const link = menuLinks[cleanPath];
|
||||||
|
historyContainer.append(
|
||||||
|
`<li><a href="${cleanPath}" title="${link.title}">${link.text}</a></li>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function listHistory() {
|
|
||||||
let browse_history = JSON.parse(localStorage.getItem('history'));
|
$(document).ready(function() {
|
||||||
let history_link = '';
|
initializeHistory();
|
||||||
let title = []
|
createHistory();
|
||||||
let link_text = []
|
});
|
||||||
let cur_path = window.location.pathname;
|
|
||||||
for(let i = 0; i < browse_history.length; i++){
|
|
||||||
if (i === 0) {
|
|
||||||
browse_history[0] = browse_history[1];
|
|
||||||
}
|
|
||||||
if (i === 1) {
|
|
||||||
browse_history[1] = browse_history[2]
|
|
||||||
}
|
|
||||||
if (i === 2) {
|
|
||||||
browse_history[2] = cur_path
|
|
||||||
}
|
|
||||||
$( function() {
|
|
||||||
$('.menu li ul li').each(function () {
|
|
||||||
let link1 = $(this).find('a').attr('href');
|
|
||||||
if (browse_history[i].replace(/\/$/, "") === link1) {
|
|
||||||
title[i] = $(this).find('a').attr('title');
|
|
||||||
link_text[i] = $(this).find('a').text();
|
|
||||||
history_link = '<li><a href="'+browse_history[i]+'" title="'+title[i]+'">'+link_text[i]+'</a></li>'
|
|
||||||
$('#browse_history').append(history_link);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
localStorage.setItem('history', JSON.stringify(browse_history));
|
|
||||||
}
|
|
||||||
createHistory();
|
|
||||||
listHistory();
|
|
||||||
|
|
||||||
function changeCurrentGroupF(user_id) {
|
function changeCurrentGroupF(user_id) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
Loading…
Reference in New Issue