PHP file Management, you can click by time, size, name sort
jquery is not used in this example
Demonstrate
PHP Code
- $rootdir = "./";
- $spacenum = 0;
- $filenum = 0;
- $allfilesize = 0;
- echo "
File Management Freejs.net Test
";
- echo "Reset";
- Readlogdir ($rootdir);
- echo " ";
- echo Total Files Count: $filenum.
";
- echo "Total disk space used: $allfilesize
";
- $freespace =diskfreespace ("/");
- echo "Residue disk space: $freespace
";
- function Readlogdir ($subdir) {
- Global $rootdir, $spacenum, $filenum, $allfilesize;
- @chdir ($subdir) or Die ("Error:could not on" to this directory!);
- $dirobject =dir ($subdir);
- echo "
- $i = 0;
- $allfilesize +=filesize ($file);
- while ($file = $dirobject->read ()) {
- if ($file = = "." $file = = ") {
- Continue
- }
- $i = $i +1;
- echo "
- $filenum + +;
- }
- echo "
";
";
Creation time |
". $i." ";- echo $file. "
|
". Number_format (FileSize ($file)/1024), 2, ".", "" "." Kb |
". Date ("Y-m-d h:i:s", Filemtime ($file)). " |
";
- Return
- }
- ?>
- <script src= "Table_sort.js" ></script>JavaScript Code
- /**
- * Table Sort
- * Anthor Liueh
- */
- function Jm_powerlist (colnum)
- {
- headeventobject=event.srcelement;//to get the object that raised the event
- while (headeventobject.tagname!= "tr")//is not a TR line, the following TD bubbles up to find the appropriate line
- {
- Headeventobject=headeventobject.parentelement;
- }
- for (i=0;i
- {
- if (headeventobject.children[i]!=event.srcelement)//Find the TD cell where the event occurred
- {
- Headeventobject.children[i].classname= "Listtablehead"//To set the ClassName property of the clicked column to Listtablehead
- }
- }
- var tablerows=0;
- Trobject=clearstart.children[0].children; Get the table row object, it's called a DataTable, maybe you wrote wrong??
- for (i=0;i{
- object=clearstart.children[0].children[i];//gets the object of each row
- Tablerows= (trobject[i].id== "Ignore")? tablerows:tablerows+1;//if the row is not ignored, the number of rows plus one
- }
- var trinnerhtml=new Array (tablerows);
- var tdinnerhtml=new Array (tablerows);
- var tdnumber=new Array (tablerows)
- var i0=0
- var i1=0
- for (i=0;i{
- if (trobject[i].id!= "Ignore")
- {
- trinnerhtml[i0]=trobject[i].innerhtml;//put the line in the array.
- tdinnerhtml[i0]=trobject[i].children[colnum].innerhtml;//the contents of TD in the row to be sorted into an array
- tdnumber[i0]=i;//line number
- i0++;//plus one, next cycle.
- }
- }
- sourcehtml=clearstart.children[0].outerhtml;//gets the HTML code for all TR in the table
- Sorting the strings in all TD is not a bubble sort???
- for (Bi=0;bi
- for (i=0;i
{
- if (tdinnerhtml[i]>tdinnerhtml[i+1])
- {
- T_S=TDNUMBER[I+1];
- T_b=tdnumber[i];
- Tdnumber[i+1]=t_b;
- tdnumber[i]=t_s;
- TEMP_SMALL=TDINNERHTML[I+1];
- Temp_big=tdinnerhtml[i];
- Tdinnerhtml[i+1]=temp_big;
- Tdinnerhtml[i]=temp_small;
- }
- }
- }
- var showshow= "";
- var numshow= "";
- for (i=0;i
{
- showshow=showshow+tdinnerhtml[i]+ "\ n";//to place the contents of the sorted TD in a Showshow string
- Numshow=numshow+tdnumber[i]+ ""; The corresponding line number of the order is also in Numshow
- }
- Sourcehtml_head=sourcehtml.split ("");/from truncation, I tried, and the front string was empty
- Numshow=numshow.split ("");
- var trrebuildhtml= "";
- if (event.srcelement.classname== "listheadclicked")
- {//clicked column, then inverted
- for (i=0;i
{
- trrebuildhtml=trrebuildhtml+trobject[numshow[tablerows-1-i]].outerhtml;//take out the contents of the sorted TR and connect them
- }
- Event.srcelement.classname= "ListHeadClicked0";
- }
- Else
- {//default shun row, new click Shun Pai
- for (i=0;i
{
- trrebuildhtml=trrebuildhtml+trobject[numshow[i]].outerhtml;
- }
- Event.srcelement.classname= "listheadclicked";
- }
- Gets the sorted TR collection result string
- var datarebuildtable= "";
- Connect the old table header with the new TR-sorted elements (modified)
- Datarebuildtable = "
{
- "
"+ trobject[0].outerhtml + trrebuildhtml +" "+
";
- clearstart.outerhtml=datarebuildtable;//table with new string write again
- }
Original address: http://www.freejs.net/article_jquerywenzi_147.html