Subversion Repositories DevTools

Rev

Rev 6651 | Rev 6695 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6651 Rev 6683
Line 11... Line 11...
11
*/
11
*/
12
/*
12
/*
13
**  Vix: Minor modifications to:
13
**  Vix: Minor modifications to:
14
**      Fill popup with entire TextArea
14
**      Fill popup with entire TextArea
15
**      Only select td in the current table - prevent picking up bits from nested tables
15
**      Only select td in the current table - prevent picking up bits from nested tables
-
 
16
**      'th' with a class of 'noCsv' will exclude the entire column from the output
16
*/
17
*/
17
jQuery.fn.TableCSVExport = function (options) {
18
jQuery.fn.TableCSVExport = function (options) {
18
    var options = jQuery.extend({
19
    var options = jQuery.extend({
19
        separator: ',',
20
        separator: ',',
20
        header: [],
21
        header: [],
Line 38... Line 39...
38
    var columnCounter = 0;
39
    var columnCounter = 0;
39
    var insertBeforeNum = null;
40
    var insertBeforeNum = null;
40
    //header
41
    //header
41
    var numCols = options.header.length;
42
    var numCols = options.header.length;
42
    var tmpRow = []; // construct header avalible array
43
    var tmpRow = []; // construct header avalible array
-
 
44
    var incCol = [];
43
 
45
 
44
    if (numCols > 0) {
46
    if (numCols > 0) {
45
        if (basic) {
47
        if (basic) {
46
            for (var i = 0; i < numCols; i++) {
48
            for (var i = 0; i < numCols; i++) {
47
                if (options.header[i] == options.insertBefore) {
49
                if (options.header[i] == options.insertBefore) {
Line 64... Line 66...
64
                    }
66
                    }
65
                }
67
                }
66
            }
68
            }
67
        }
69
        }
68
    } else {
70
    } else {
69
        getAvailableElements(el).find('th').each(function () {
71
        getAvailableElements(el).find('th').each(function (idx) {
-
 
72
            incCol[idx] = !jQuery(this).hasClass('noCsv');
-
 
73
            if ( incCol[idx] ) {
70
            if (jQuery(this).css('display') != 'none' || options.showHiddenRows) tmpRow[tmpRow.length] = formatData(jQuery(this).html());
74
                if ( jQuery(this).css('display') != 'none' || options.showHiddenRows ) tmpRow[tmpRow.length] = formatData(jQuery(this).html());
-
 
75
            }
71
        });
76
        });
72
    }
77
    }
73
 
78
 
74
    row2CSV(tmpRow);
79
    row2CSV(tmpRow);
75
 
80
 
Line 77... Line 82...
77
    if (basic) {
82
    if (basic) {
78
        var trCounter = 0;
83
        var trCounter = 0;
79
        getAvailableRows(el).each(function () {
84
        getAvailableRows(el).each(function () {
80
            var tmpRow = [];
85
            var tmpRow = [];
81
            var extraDataCounter = 0;
86
            var extraDataCounter = 0;
82
            getAvailableElements(this).find('td').each(function () {
87
            getAvailableElements(this).find('td').each(function (idx) {
-
 
88
                if ( incCol[idx] ) {
83
                if (extraDataCounter == insertBeforeNum) {
89
                    if ( extraDataCounter == insertBeforeNum )
-
 
90
                    {
84
                    tmpRow[tmpRow.length] = jQuery.trim(options.extraData[trCounter - 1]);
91
                        tmpRow[tmpRow.length] = jQuery.trim(options.extraData[trCounter - 1]);
85
                }
92
                    }
86
                if (jQuery(this).css('display') != 'none' || options.showHiddenRows) {
93
                    if (jQuery(this).css('display') != 'none' || options.showHiddenRows) {
87
                    if (jQuery.trim(jQuery(this).html()) == "") {
94
                        if (jQuery.trim(jQuery(this).html()) == "") {
88
                        tmpRow[tmpRow.length] = formatData(options.emptyValue);
95
                            tmpRow[tmpRow.length] = formatData(options.emptyValue);
89
                    } else {
96
                        } else {
90
                        tmpRow[tmpRow.length] = jQuery.trim(formatData(jQuery(this).html()));
97
                            tmpRow[tmpRow.length] = jQuery.trim(formatData(jQuery(this).html()));
-
 
98
                        }
91
                    }
99
                    }
-
 
100
                    extraDataCounter++;
92
                }
101
                }
93
                extraDataCounter++;
-
 
94
            });
102
            });
95
            row2CSV(tmpRow);
103
            row2CSV(tmpRow);
96
            trCounter++;
104
            trCounter++;
97
        });
105
        });
98
    } else {
106
    } else {