mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
memory list sort by column
This commit is contained in:
parent
ddfccb338c
commit
b2751ca444
@ -4359,6 +4359,53 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort the memory list by the given column offset
|
||||
*
|
||||
* @name Memory.sort
|
||||
* @private
|
||||
* @function
|
||||
* @param {int} column
|
||||
*/
|
||||
function sort(column)
|
||||
{
|
||||
let i, x, y, shouldSwitch, dir, switchcount = 0;
|
||||
let table = $('#sidebar-wrapper table')[0];
|
||||
let header = $('#sidebar-wrapper table thead tr th')[column];
|
||||
let switching = true;
|
||||
if (header.dataset.direction == 'asc') {
|
||||
header.dataset.direction = 'desc';
|
||||
} else {
|
||||
header.dataset.direction = 'asc';
|
||||
}
|
||||
while (switching) {
|
||||
switching = false;
|
||||
let rows = table.rows;
|
||||
// skip first row, containing headers
|
||||
for (i = 1; i < (rows.length - 1); i++) {
|
||||
shouldSwitch = false;
|
||||
x = rows[i].getElementsByTagName("td")[column];
|
||||
y = rows[i + 1].getElementsByTagName("td")[column];
|
||||
if (header.dataset.direction == 'asc') {
|
||||
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
|
||||
shouldSwitch = true;
|
||||
break;
|
||||
}
|
||||
} else if (header.dataset.direction == 'desc') {
|
||||
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
|
||||
shouldSwitch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldSwitch) {
|
||||
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
||||
switching = true;
|
||||
switchcount ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* called after successfully connecting to the indexedDB
|
||||
*
|
||||
@ -4577,6 +4624,12 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
if (me.add(window.location.href))
|
||||
$('#menu-toggle').click();
|
||||
});
|
||||
const headers = $('#sidebar-wrapper table thead tr th');
|
||||
for (let i = 1; i < headers.length; i++) {
|
||||
headers[i].addEventListener('click', function(e) {
|
||||
sort(i);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return me;
|
||||
|
@ -72,7 +72,7 @@ endif;
|
||||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.14.js" integrity="sha512-kbLhjIj/m/AW++o2eErCfqPueoX2btJo7VznhEC2YQRbVR/+Eup3w7thwDZwoCZ/gLrPxTX3W4H2KzupLg2PKA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-nQ7uXojx+snSWAOLTI/kLNlNUL7w14Dm7Uy3hsgF5KQDUFjBb0Sbppg6RbsbjBtTvUnpkiNkK8YOFBTIPpxXZg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-HHR606wkEJVvf3XzEq81itazhXqfj3z54F2Hp2HfBPpUpXjvsI3DAxohlhOR669XLLS/k4v9+QCsQLNWegEA7A==" crossorigin="anonymous"></script>
|
||||
<!-- icon -->
|
||||
<link rel="apple-touch-icon" href="<?php echo I18n::encode($BASEPATH); ?>img/apple-touch-icon.png" sizes="180x180" />
|
||||
<link rel="icon" type="image/png" href="img/favicon-32x32.png" sizes="32x32" />
|
||||
|
@ -50,7 +50,7 @@ endif;
|
||||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.14.js" integrity="sha512-kbLhjIj/m/AW++o2eErCfqPueoX2btJo7VznhEC2YQRbVR/+Eup3w7thwDZwoCZ/gLrPxTX3W4H2KzupLg2PKA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-nQ7uXojx+snSWAOLTI/kLNlNUL7w14Dm7Uy3hsgF5KQDUFjBb0Sbppg6RbsbjBtTvUnpkiNkK8YOFBTIPpxXZg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-HHR606wkEJVvf3XzEq81itazhXqfj3z54F2Hp2HfBPpUpXjvsI3DAxohlhOR669XLLS/k4v9+QCsQLNWegEA7A==" crossorigin="anonymous"></script>
|
||||
<!-- icon -->
|
||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
||||
<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
|
||||
|
Loading…
Reference in New Issue
Block a user