conCat func

by khemikal

JavaScript

//captures cells (a) until reaching cell with class (b) and returns concatenation of values
//only pushes unique values to array
function conCat(a, b) {
    var strArray = [];
    var uniques = [];
    $(a).each(function () {
        var tdTxt = ($(this).text());
        if ($(this).hasClass(b)) {
            $(this).text(uniques);
            strArray = [];
             uniques = []
        } else {
            strArray.push(tdTxt);
            $.each(strArray, function (i, el) {
                if ($.inArray(el, uniques) === -1) uniques.push(el);
            });
        }
    })
}