<commit_before>/**
 * Refreshes the table data every 2 seconds
 * @param updateTableUrl
 *          url to update complete table (method updateTableMethod within BatchActivityController)
 * @param checkUrl
 *          url to check if active BatchActivities exist (method checkForUpdate within BatchActivityController)
 * @param rowUpdateUrl
 *          url to update all rows (method getUpdate within BatchActivityController)
 */

function init(updateTableUrl, checkUrl, rowUpdateUrl,batchActivityCount) {
    curr = 0;
    max = $('#batchElementsPerPage').val();
    lastFilter = $('#batchNameFilter').val();
    offset = 0;

    $('#batchElementsPerPage').on("keyup input",function (element) {
        var max_temp = $('#batchElementsPerPage').val();
        if(max_temp > 0) {
            max = max_temp;
            curr = 0;
            offset = 0;
            updateBatchActivityTable(updateTableUrl);
        }
    });
    $('#batchNameFilter').on("keyup input",function (element) {
        lastFilter = $('#batchNameFilter').val();
        curr = 0;
        offset = 0;
        updateBatchActivityTable(updateTableUrl);
    });
    updateIfNecessary(updateTableUrl, checkUrl, rowUpdateUrl);
    createPagination(batchActivityCount,updateTableUrl);
}

// Based on http://stackoverflow.com/questions/17390179/using-bootstrap-to-paginate-a-set-number-of-p-elements-on-a-webpage
function createPagination(size,updateTableUrl){
    var perPage = max;
    var numItems = size;
    var numPages = Math.ceil(numItems/perPage);


    var myNode = document.getElementById("batchActivityPager");
    myNode.innerHTML = '';
    var i = 0;
    if (numPages < 10) {
        while (numPages > i) {
            if(i == curr) {
                $('<li><a style="background-color: rgb(219,219,219);" href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }else{
                $('<li><a href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }
            i++;
        }
    }else{
        var max_i = 8-curr;
        if(curr >6 ) {
            $('<li><a href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            i = curr - 3;
            max_i = 3
        }
        while (curr+max_i > i && numPages> i) {
            if(i == curr) {
                $('<li><a style="background-color: rgb(219,219,219);" href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }else{
                $('<li><a href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }
            i++;
        }
        if(i!= numPages) {
            $('<li><a href="#" class="page_link">' + (numPages) + '</a></li>').appendTo('#batchActivityPager');
        }
    }

    $('#batchActivityPager .page_link:first').addClass('active');


    $('#batchActivityPager li a').click(function(){
        var clickedPage = $(this).html() - 1;
        goTo(clickedPage,perPage);
    });
    $('<li><a href="#" class="prevLink">'+'Previous'+'</a></li>').click(function () {
        previous();
    }).prependTo('#batchActivityPager');
    $('<li><a href="#" class="nextLink">'+'Next'+'</a></li>').click(function(){
        next();
    }).appendTo('#batchActivityPager');

    function previous(){
        var goToPage = curr - 1;
        if(goToPage >= 0)
        goTo(goToPage);
    }

    function next(){<commit_msg>added spacer item in batchActivityPagination<commit_after>/**
 * Refreshes the table data every 2 seconds
 * @param updateTableUrl
 *          url to update complete table (method updateTableMethod within BatchActivityController)
 * @param checkUrl
 *          url to check if active BatchActivities exist (method checkForUpdate within BatchActivityController)
 * @param rowUpdateUrl
 *          url to update all rows (method getUpdate within BatchActivityController)
 */

function init(updateTableUrl, checkUrl, rowUpdateUrl,batchActivityCount) {
    curr = 0;
    max = $('#batchElementsPerPage').val();
    lastFilter = $('#batchNameFilter').val();
    offset = 0;

    $('#batchElementsPerPage').on("keyup input",function (element) {
        var max_temp = $('#batchElementsPerPage').val();
        if(max_temp > 0) {
            max = max_temp;
            curr = 0;
            offset = 0;
            updateBatchActivityTable(updateTableUrl);
        }
    });
    $('#batchNameFilter').on("keyup input",function (element) {
        lastFilter = $('#batchNameFilter').val();
        curr = 0;
        offset = 0;
        updateBatchActivityTable(updateTableUrl);
    });
    updateIfNecessary(updateTableUrl, checkUrl, rowUpdateUrl);
    createPagination(batchActivityCount,updateTableUrl);
}

// Based on http://stackoverflow.com/questions/17390179/using-bootstrap-to-paginate-a-set-number-of-p-elements-on-a-webpage
function createPagination(size,updateTableUrl){
    var perPage = max;
    var numItems = size;
    var numPages = Math.ceil(numItems/perPage);


    var myNode = document.getElementById("batchActivityPager");
    myNode.innerHTML = '';
    var i = 0;
    if (numPages < 10) {
        while (numPages > i) {
            if(i == curr) {
                $('<li><a style="background-color: rgb(219,219,219);" href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }else{
                $('<li><a href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }
            i++;
        }
    }else{
        var max_i = 8-curr;
        if(curr >=5 ) {
            $('<li><a href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            if( curr >= 5 ) $('<li><a href="#" class="page_link">' + "..." + '</a></li>').appendTo('#batchActivityPager');
            i = curr - 3;
            max_i = 4
        }
        if(i + 7 >=numPages) i= numPages -7;
        while (curr+max_i > i && numPages> i) {
            if(i == curr) {
                $('<li><a style="background-color: rgb(219,219,219);" href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }else{
                $('<li><a href="#" class="page_link">' + (i + 1) + '</a></li>').appendTo('#batchActivityPager');
            }
            i++;
        }
        if(i!= numPages) {
            if(i+1 != numPages)$('<li><a href="#" class="page_link">' + "..." + '</a></li>').appendTo('#batchActivityPager');
            $('<li><a href="#" class="page_link">' + (numPages) + '</a></li>').appendTo('#batchActivityPager');
        }
    }

    $('#batchActivityPager .page_link:first').addClass('active');


    $('#batchActivityPager li a').click(function(){
        if($.isNumeric( $(this).html())) {
            var clickedPage = $(this).html() - 1;
            goTo(clickedPage, perPage);
        }
    });
    $('<li><a href="#" class="prevLink">'+'Previous'+'</a></li>').click(function () {
        previous();
    }).prependTo('#batchActivityPager');
    $('<li><a href="#" class="nextLink">'+'Next'+'</a></li>').click(function(){
        next();
    }).appendTo('#batchActivityPager');

    function previous(){
        var goToPage = curr - 1;
        if(goToPage >= 0)
        goTo(goToPage);
    }

    function next(){
{'fraction_non_alphanumeric': 0.18780620577027762, 'fraction_numerical': 0.013881328252585737, 'mean_word_length': 2.6148548942449583, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2142532', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2251, 'n_words': 438}