enable sorting of columns of db_backup by name, modified or size by clicking on columnheader (done via javascript) provided by Chr.Fueller

This commit is contained in:
Klaus Leithoff 2010-05-19 09:47:32 +00:00
parent 8cb71dfc84
commit 52edbbd092

View File

@ -1,7 +1,76 @@
<!-- begin db_backup.tpl --> <!-- begin db_backup.tpl -->
<p align="center"><font color="red">{error_msg}</font></p> <p align="center"><font color="red">{error_msg}</font></p>
<form method="post" action="{self}" enctype="multipart/form-data"> <script language="JavaScript1.2">
Array.prototype.contains = function(value)
{
for(var i = 0;i < this.length;i++)
if(this[i] == value)
return(true);
return(false);
}
function Numsort(a,b)
{
return a-b;
}
function sort_table(id)
{
var sortedby = document.getElementById('sortedby').value;
var table = document.getElementById('files_table');
var rows = table.rows;
var l = rows.length;
if(l < 2) return;
var sort_columns = Array();
var rows_content = Array();
for(var i = 1;i < l;i++)
{
var value = rows[i].cells[id].innerHTML.toUpperCase();
if (id == 2)
{
start = value.search(/\(/)+1;
stop = value.search(/\)/);
value = value.substring(start,stop);
}
var index = 0;
while(sort_columns.contains(value + (index != 0 ? '_' + index : '')))
index++;
value = value + (index != 0 ? '_' + index : '');
sort_columns[i - 1] = value;
rows_content[value] = rows[i].innerHTML;
}
if (id == 2)
{
sort_columns.sort(Numsort);
}
else
{
sort_columns.sort();
}
if (sortedby == id)
{
sort_columns.reverse();
document.getElementById('sortedby').value = -1;
}
else
{
document.getElementById('sortedby').value = id;
}
for(var i = 1;i < l;i++)
table.deleteRow(-1);
for(var i = 1;i < l;i++)
{
var new_row = table.insertRow(-1);
new_row.align = 'center';
new_row.innerHTML = rows_content[sort_columns[i - 1]];
}
}
</script>
<form method="post" name="backup_form" action="{self}" enctype="multipart/form-data">
<input name="sortedby" id="sortedby" type="hidden" />
<table border="0" align="center" width="98%" cellpadding="5"> <table border="0" align="center" width="98%" cellpadding="5">
<!-- BEGIN setup_header --> <!-- BEGIN setup_header -->
<tr bgcolor="#486591"> <tr bgcolor="#486591">
@ -82,11 +151,11 @@
</tr> </tr>
<tr bgcolor="#e6e6e6"> <tr bgcolor="#e6e6e6">
<td colspan="2"> <td colspan="2">
<table style="border: 1px solid black; border-collapse: collapse;" border="1" width="100%"> <table id="files_table" style="border: 1px solid black; border-collapse: collapse;" border="1" width="100%">
<tr align="center"> <tr align="center">
<td>{lang_filename}</td> <td><a href="#" onClick="sort_table(0);">{lang_filename}</a></td>
<td>{lang_mod}</td> <td><a href="#" onClick="sort_table(1);">{lang_mod}</a></td>
<td>{lang_size}</td> <td><a href="#" onClick="sort_table(2);">{lang_size}</a></td>
<td>{lang_actions}</td> <td>{lang_actions}</td>
</tr> </tr>
<!-- BEGIN set_row --> <!-- BEGIN set_row -->