const inputSortOrder = $('#p3x-gitlist-index-list-sort-order')
const inputSortSelect = $('#p3x-gitlist-index-list-sort-select')
const cookieNameSortSelect = 'p3x-gitlist-repo-sort-select';
const cookieNameSortOrder = 'p3x-gitlist-repo-sort-order';
let settingSortSelect = Cookies.get(cookieNameSortSelect)
let settingSortOrder = Cookies.get(cookieNameSortOrder)
if (settingSortSelect === undefined) {
settingSortSelect = 'p3x-gitlist-index-repo-last-commit-timestamp'
}
if (settingSortOrder === undefined) {
settingSortOrder = 'desc'
}
const sort = () => {
list.sort(settingSortSelect, {
order: settingSortOrder
})
Cookies.set(cookieNameSortSelect, settingSortSelect, window.gitlist.cookieSettings)
Cookies.set(cookieNameSortOrder, settingSortOrder, window.gitlist.cookieSettings)
}
const setInputSortOrder = () => {
if (settingSortOrder === 'desc') {
inputSortOrder.append(`<i class="fas fa-sort-amount-up"></i>`)
} else {
inputSortOrder.append(`<i class="fas fa-sort-amount-down"></i>`)
}
}
inputSortSelect.val(settingSortSelect)
inputSortSelect.on('change', () => {
settingSortSelect = inputSortSelect.val()
sort()
})
inputSortOrder.on('click', () => {
inputSortOrder.empty()
settingSortOrder = settingSortOrder === 'asc' ? 'desc' : 'asc'
setInputSortOrder()
sort()
})
// p3x-gitlist-index-name
inputClear.on('click', () => {