table_obj.js
来自「proe5.0野火版下载(中文版免费下载)」· JavaScript 代码 · 共 1,808 行 · 第 1/4 页
JS
1,808 行
| Output: | Return: \*--------------------------------------------------------------------------*/function addShowRowCB ( cb_func , data1 , data2 ){ var index = getTableIndexByID ( current_table_id ) ; if ( index >= 0 && cb_func != null ) { var cbs = tables[index].showRowsCBs ; var cb = new CBDefinition ( cb_func , "IsShowRow" , data1 , data2 ) ; appendToArray ( cbs , cb ) ; }}/*--------------------------------------------------------------------------*\| Function: appendCellsToTableRow| Purpose: appends info to table row| Input: function gets undefined number of arguments| argument[0..] - table data| Output: | Return: \*--------------------------------------------------------------------------*/function appendCellsToTableRow (row_data_array){ var index = getTableIndexByID (current_table_id) ; if ( index >= 0 ) { var args = appendCellsToTableRow.arguments ; var num = args.length ; var table = tables[index] ; var rows = table.tableRowsData ; if ( rows.length > 0 ) { var row = rows[rows.length - 1] ; if ( num >= 1 ) { var col_len = row.col.length ; if ( num + col_len <= table.tableHeadersData.length ) { for ( var i = 0 ; i < num ; i ++ ) row.col[col_len + i] = new TableCell ( args[i] ) ; } else debug_error_crash ("Error: too many parameters passed to appendCellsToTableRow" , "appendCellsToTableRow" ) ; } else debug_error_crash ("Error: 0 parameters passed to appendCellsToTableRow" , "appendCellsToTableRow" ) ; } else debug_error_crash ("Error: no row to append too in appendCellsToTableRow" , "appendCellsToTableRow" ) ; }}/*--------------------------------------------------------------------------*\| Function: getTableIndexByID| Purpose: function returns the table index in the tables array| Input: table_id - table string identifier| Output: | Return: -1 if not found , otherwise the index\*--------------------------------------------------------------------------*/function getTableIndexByID ( table_id ){ var result = -1 ; for ( var i = 0 ; i < tables.length ; i++ ) { if ( tables[i].table_id == table_id ) { result = i ; break ; } } return result ;}/*--------------------------------------------------------------------------*\| Function: getEscapedTableIndexByID| Purpose: function returns the table index in the tables array| Input: escaped_table_id - escaped table string identifier| Output: | Return: -1 if not found , otherwise the index\*--------------------------------------------------------------------------*/function getEscapedTableIndexByID ( escaped_table_id ){ var result = -1 ; for ( var i = 0 ; i < tables.length ; i++ ) { if ( tables[i].escaped_table_id == escaped_table_id ) { result = i ; break ; } } return result ;}/*--------------------------------------------------------------------------*\| Function: getProperArrow| Purpose: returns the image of the arrow depending on the sort type| Input: header - header object to inquire| Output: | Return: \*--------------------------------------------------------------------------*/function getProperArrow ( header ){ var result = '' ; var order = header.sort_order ; if ( order == SORT_NOT_SORTED ) result = HorzArrowGif ; else if ( order == SORT_ACENDING || order == SORT_ACENDING_REVERSE ) result = DownArrowGif ; else if ( order == SORT_DECENDING ) result = UpArrowGif ; return result}/*--------------------------------------------------------------------------*\| Function: | Purpose: | Input: | Output: | Return: \*--------------------------------------------------------------------------*/function isTextFormat ( format ){ return ( format == TEXT_FORMAT_TABS || format == TEXT_FORMAT_COMMA ) ;}/*--------------------------------------------------------------------------*\| Function: getProperDelimiter| Purpose: returns the delimiter for the export based on the format| Input: format - TEXT_FORMAT_COMMA/TEXT_FORMAT_TABS//HTML_FORMAT| Output: | Return: ',' , '\t' , '' .\*--------------------------------------------------------------------------*/function getProperDelimiter ( format ){ if ( format == TEXT_FORMAT_COMMA ) return ','; else if ( format == TEXT_FORMAT_TABS ) return '\t'; else return '';}/*--------------------------------------------------------------------------*\| Function: | Purpose: | Input: | Output: | Return: \*--------------------------------------------------------------------------*/function genericSortFunction ( row1 , row2 ){ var header_index = row1.table.sortIndex ; if ( header_index >= 0 ) { var result; var header = row1.table.tableHeadersData[header_index] ; if ( header.sortByColumnIndex >= 0 ) header_index = header.sortByColumnIndex ; header = row1.table.tableHeadersData[header_index] ; if ( row1.col.length <= header_index || row2.col.length <= header_index || header.headerCmpFunc == null ) { result = 0 ; } else { var a = row1.col[header_index].text ; var b = row2.col[header_index].text ; result = header.headerCmpFunc( a , b ) ; } if ( result == 0 ) result = ( row1.insert_order - row2.insert_order ) ; return result ; } else return 0}/*--------------------------------------------------------------------------*\| Function: sortRows| Purpose: function sorts the rows of a table| Input: table - table object to sort| Output: | Return: \*--------------------------------------------------------------------------*/function sortRows ( table ){ if ( table.sortIndex >= 0 ) { var header = table.tableHeadersData[table.sortIndex] ; if ( header != null ) { if (header.sort_order == SORT_DECENDING || header.sort_order == SORT_ACENDING_REVERSE ) table.tableRowsData.reverse () ; else table.tableRowsData.sort ( genericSortFunction ) ; } }}/*--------------------------------------------------------------------------*\| Function: columnClicked| Purpose: function is the action callback of the onmouseclick event| Input: table_index - index in tables array| header_index - index in tableHeadersData array| Output: | Return: \*--------------------------------------------------------------------------*/function columnClicked ( table_index , header_index ){ var table = tables[table_index] ; var header = table.tableHeadersData[header_index] ; if ( header.headerCmpFunc != null ) { var order = header.sort_order ; table.sortIndex = header_index ; if ( order == SORT_NOT_SORTED ) order = SORT_ACENDING ; else if ( order == SORT_ACENDING_REVERSE || order == SORT_ACENDING ) order = SORT_DECENDING ; else if ( order == SORT_DECENDING ) order = SORT_ACENDING_REVERSE ; header.sort_order = order ; var headers = table.tableHeadersData ; for ( var i = 0 ; i < headers.length ; i++ ) if ( headers[i] != header ) headers[i].sort_order = SORT_NOT_SORTED ; generateTable ( table , 0 , HTML_FORMAT , true ) ; }}/*--------------------------------------------------------------------------*\| Function: generateOneRow| Purpose: function creates html output for one table row| Input: headers - heades data array| row - row object| color - bg color of row| format - text format , or html format| Output: | Return: resulting html/text of a table row\*--------------------------------------------------------------------------*/function generateOneRow ( headers , row , color , format ){ var result = '' ; if ( format == HTML_FORMAT ) { result += '<tr class="' ; result += color ; result += '">' ; } var cols = row.col ; for ( i = 0 ; i < cols.length ; i ++ ) { var cell = cols[i] ; if ( headers[i].visible == SHOW && ( format == HTML_FORMAT || headers[i].textFormatVisibility == SHOW ) ) { if ( format == HTML_FORMAT ) { result += '<td NOWRAP="TRUE" class="'; if ( cell.font != null ) result += cell.font + '" '; else result += headers[i].colClass + '" '; if ( cell.colSpan != -1 ) result += 'colspan="' + cell.colSpan + '" '; if ( cell.rowSpan != -1 ) result += 'rowspan="' + cell.rowSpan + '" '; if ( cell.valign != null ) result += 'valign="' + cell.valign + '" ' ; else result += 'valign="' + headers[i].colVAlign + '" ' ; if ( cell.align != null ) result += 'align="' + cell.align + '" ' ; else result += 'align="' + headers[i].colAlign + '" ' ; result += '>' ; if ( cell.bold == true ) result += '<B>' ; } if ( isTextFormat ( format ) && headers[i].cellToTextCB != null ) result += headers[i].cellToTextCB ( cell.text ) ; else result += cell.text ; if ( format == HTML_FORMAT ) { if ( cell.bold == true ) result += '</B>' ; result += '</td>' ; } else result += getProperDelimiter ( format ) ; } } if ( format == HTML_FORMAT ) result += '</tr>' ; else result += '\n' ; return result ;}/*--------------------------------------------------------------------------*\| Function: generateEmptyMsgRows| Purpose: function creates html output for empty table messages| Input: msgs - messages to display| format - text format , or html format| Output: | Return: resulting html of a table row\*--------------------------------------------------------------------------*/function generateEmptyMsgRows ( msgs , format ){ var result = '' ; var i ; for ( i = 0 ; i < msgs.length ; i ++ ) { if ( format == HTML_FORMAT ) result += '<tr><td NOWRAP="TRUE" class="tabledatafont">' + msgs[i] + '</td></tr>' ; else result += msgs[i] + '\n' ; } return result ;}/*--------------------------------------------------------------------------*\| Function: getTableCellInfo| Purpose: function returns the cell value pointed by row and header| Input: table_id - table unique id| header - header unique name| row - row index| Output: | Return: the value of the cell or null\*--------------------------------------------------------------------------*/function getTableCellInfo ( table_id , header , row ){ var result = null ; var table_index = getTableIndexByID ( table_id ) ; if ( table_index >= 0 ) { var table = tables[table_index] ; var header_index = getHeaderIndexByID ( table.tableHeadersData , header ) ; var rows = table.tableRowsData ; if ( header_index >= 0 && row >= 0 && row < rows.length ) { result = rows[row].col[header_index].text ; } } return result ;}/*--------------------------------------------------------------------------*\| Function: setTableCellInfo| Purpose: function sets the cell value pointed by row and header| Input: table_id - table unique id| header - header unique name| row - row index| value - the new text value of the cell| Output: | Return: the old value of the cell or null\*--------------------------------------------------------------------------*/function setTableCellInfo ( table_id , header , row , value ){ var old_value = null ; var table_index = getTableIndexByID ( table_id ) ; if ( table_index >= 0 ) { var table = tables[table_index] ; var header_index = getHeaderIndexByID ( table.tableHeadersData , header ) ; var rows = table.tableRowsData ; if ( header_index >= 0 && row >= 0 && row < rows.length ) { old_value = rows[row].col[header_index].text ; rows[row].col[header_index].text = value ; } } return old_value ;}/*--------------------------------------------------------------------------*\| Function: generateAllRows| Purpose: function creates html output for all table rows| Input: table - table object| call_show_cbs - should we call the show row cbs.| format - text format , or html format| Output: | Return: resulting html/text of a table rows\*--------------------------------------------------------------------------*/function generateAllRows ( table , format ){ var result = '' ; var skipped_num = 0 ; var color ; for ( var i = 0 ; i < table.tableRowsData.length ; i++ ) { if ( isRowVisible ( table , i ) ) { var row = table.tableRowsData[i] ; if ( row.color != null ) color = row.color ; else if ( table.defaultColor != null ) color = table.defaultColor ; else if ( ( i - skipped_num ) % 2 == 0 ) color = 'tableoddrowbg' ; else color = 'tableevenrowbg' ;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?