คัดลอกรหัสรหัสดังนี้:
<div id = "html"> </div>
<script>
var listInfos = new Array ();
listinfos [0] = new Array ();
listinfos [0] [0] = {'ชื่อ': 'หน้าแนะนำ 1', 'dayCount': 666, 'avgtime': 29872, 'errcount': 180663, 'errorraate': '2873%', : 0.
listinfos [0] [1] = {'ชื่อ': 'หน้าแนะนำหน้า 2', 'dayCount': 593896, 'avgtime': 24946, 'errcount': 222, 'errorraate': '2%', 'daysystemerrorcou nt' : 0.
listinfos [0] [2] = {'ชื่อ': 'หน้าแนะนำหน้า 3', 'daycount': 956, 'avgtime': 27957, 'errcount': 111, 'errorraate': '10%' 0.
listinfos [1] = new Array ();
listinfos [1] [0] = {'ชื่อ': 'หน้าแนะนำ 4', 'daycount': 666, 'avgtime': 116, 'errcount': 180663, 'errorraate': '2873%', 'daysystemerrorcou nt' : 0.
listinfos [1] [1] = {'ชื่อ': 'หน้าแนะนำหน้า 5', 'dayCount': 11, 'avgtime': 222, 'errcount': 222, 'errorrate': '2%', 'DaysystemerrorCount': 0.
listinfos [1] [2] = {'ชื่อ': 'หน้าแนะนำ 6', 'dayCount': 956, 'avgtime': 956, 'errcount': 111, 'errorrate': '10%',' daysystemerrorCount ': 0.
ฟังก์ชั่น datedesc (listinfos, ฟิลด์) {{
สำหรับ (var i = 0; i <chistinfos.length; i ++) {
สำหรับ (var j = i+1; j <listinfos.length; j ++) {
ถ้า (isCommapercent (listinfos [i] [ฟิลด์]) <isCommapercent (listinfos [j] [ฟิลด์])) {) {)
var arrayTemp = new Array ();
arrayTemp = liStInfos [i];
listinfos [i] = listinfos [j];
listinfos [j] = arraytemp;
-
-
-
return listinfos;
-
ฟังก์ชั่น DataAsc (listinfos, ฟิลด์) {
สำหรับ (var i = 0; i <chistinfos.length; i ++) {
สำหรับ (var j = i+1; j <listinfos.length; j ++) {
ถ้า (isCommapercent (listinfos [i] [ฟิลด์])> iscommapercent (listinfos [j] [ฟิลด์])) {) {)
var arrayTemp = new Array ();
arrayTemp = liStInfos [i];
listinfos [i] = listinfos [j];
listinfos [j] = arraytemp;
-
-
-
return listinfos;
-
ฟังก์ชั่น iScommapercent (ค่า) {
var valuefloat;
value = value.tolocalestring ();
ValueFloat = (value.indexof (',')> 0)?
ValueFloat = (valuefloat.indexof ('%')> 0)?
คืนค่า Float;
-
ฟังก์ชั่นการเรียงลำดับ (sortinfos, ฟิลด์, เรียงลำดับ) {{
var listInfos = new Array ();
if (sort == 'desc') {{
สำหรับ (var i = 0; i <sortinfos.length; i ++) {
listinfos [i] = datedesc (sortinfos [i], ฟิลด์);
-
} อื่นถ้า (sort == 'asc') {
สำหรับ (var i = 0; i <sortinfos.length; i ++) {
listinfos [i] = dataasc (sortinfos [i], ฟิลด์);
-
} อื่น {
การแจ้งเตือน ('ข้อผิดพลาดในการดำเนินการ ... ');
กลับเท็จ;
-
var tableStrist = '';
สำหรับ (var i = 0; i <chistinfos.length; i ++) {
var tableSt = '<H1> โปรแกรม </h1>';
tableSt+= '<table cellspacing = "0" cellpadding = "0"> <tbody> <ter>';
tableSt += '<td> ชื่อโปรแกรม </td> <td> การเยี่ยมชมของวัน (ครั้ง) </td> <td> เวลาตอบสนองเฉลี่ย (US) </td> <td> หมายเลขข้อผิดพลาด (ครั้ง) </ td> ';
tableSt += '<td> อัตราข้อผิดพลาด (%) </td> <td> ข้อผิดพลาดของระบบ (ครั้ง) </td> <td> อัตราข้อผิดพลาดของระบบ (%) </td> </tr>';
สำหรับ (var j = 0; j <listinfos [i] .length; j ++) {
tableSt += '<ter>';
tableSt+= '<td> <a href = "detail.php? type = programs & pid = 1">'+listinfos [i] [j] ['name']+'</a> </td>';
tableSt+= '<td>'+listinfos [i] [j] ['daycount']+'</td>';
tableSt+= '<td>'+listinfos [i] [j] ['avgtime']+'</td>';
tableSt+= '<td>'+listinfos [i] [j] ['errcount']+'</td>';
tableSt+= '<td>'+listinfos [i] [j] ['errorraate']+'</td>';
tableSt+= '<td>'+listinfos [i] [j] ['daysystemerRerCount']+'</td>';
tableSt+= '<td>'+listinfos [i] [j] ['daysystemerrrrate']+'</td>';
tableSt += '</tr>';
-
tableSt += '</tbody> </table>';
tableStrist += tableSt
-
document.getElementById ("HTML")
-
Sortoperation (listinfos, 'daycount', 'asc')
</script>