<commit_before>/*
 Description: The script updates a list of recently added assets of a given asset type.This logic will periodically refresh
 the list of assets that are pending indexing.If the indexing completes this script will trigger a refresh.
 Filename:recent-assets.js
 Created Date: 22/10/2013
 */
$(function () {

    var RECENT_ASSET_CONTAINER = '#recent-assets-container';
    var REFRESH_TIMER = 4000;
    var CACHE_URL = caramel.context +'/api/cache/';

    //Get the details of the page
    var context = obtainMetaInformation();

    //Perform a fetch as soon as the page loads
    retrieve(context);

    //Periodically update the pending assets
    setInterval(function () {

       retrieve(context);

    }, REFRESH_TIMER);
    var recentTmpl = '{{#each cachedAssets}}';
        recentTmpl += '		<div class="row-fluid">';
        recentTmpl += '			<div class="span10"><i class="icon-refresh icon-spin load-seperator"></i><i class="icon-ok-circle"></i> <span><strong>{{attributes.overview_name}}</strong> is being added</span></div>';
        recentTmpl += '     </div>';
        recentTmpl += '{{/each}}';

    /*
    The function is used to fetch pending assets.A pending asset is one which has been added but not indexed
    @context: The context of the current page
     */
    function retrieve(context){
        $.ajax({
            url: context.url,
            type: 'GET',
            success: function (response) {
                if (response.cachedAssets.length) {
                    var recentTmplComp = Handlebars.compile(recentTmpl);
                    $('.asset-being-added').html(recentTmplComp(response)).slideDown();
                }
				
                if(response.cachedAssetsBefore!=response.cachedAssetsAfter){

                    window.location=caramel.context +'/assets/'+context.type+'/';
                }
            },
            error: function (e) {
                showMessage('Unable to retrieve new assets');
            }
        });
    }

    /*
    The function renders the assets recently added assets
    @assets: An array of assets
     */
    function renderAssets(assets) {
        $(RECENT_ASSET_CONTAINER).html(assets);
    }

    /*
    The function displays a message in the recent asset container
     */
    function showMessage(message) {
        $(RECENT_ASSET_CONTAINER).html(message);
    }

    /*
    The function obtains details of  page
    @return: An object containing the type of asset and the url used to retrieve the recentkt
     */
    function obtainMetaInformation() {<commit_msg>missed formatting corrections in commit 5fe5f85267ccc394f6b8fb0bee71b4c078d0f57f<commit_after>/*
 Description: The script updates a list of recently added assets of a given asset type.This logic will periodically refresh
 the list of assets that are pending indexing.If the indexing completes this script will trigger a refresh.
 Filename:recent-assets.js
 Created Date: 22/10/2013
 */
$(function () {

    var RECENT_ASSET_CONTAINER = '#recent-assets-container';
    var REFRESH_TIMER = 4000;
    var CACHE_URL = caramel.context +'/api/cache/';

    //Get the details of the page
    var context = obtainMetaInformation();

    //Perform a fetch as soon as the page loads
    retrieve(context);

    //Periodically update the pending assets
    setInterval(function () {

       retrieve(context);

    }, REFRESH_TIMER);
    var recentTmpl = '{{#each cachedAssets}}';
        recentTmpl += '		<div class="row-fluid">';
        recentTmpl += '			<div class="span10"><i class="icon-refresh icon-spin load-seperator"></i><i class="icon-ok-circle"></i> <span><strong>{{attributes.overview_name}}</strong> is being added</span></div>';
        recentTmpl += '     </div>';
        recentTmpl += '{{/each}}';

    /*
    The function is used to fetch pending assets.A pending asset is one which has been added but not indexed
    @context: The context of the current page
     */
    function retrieve(context){
        $.ajax({
            url: context.url,
            type: 'GET',
            success: function (response) {
                if (response.cachedAssets.length) {
                    var recentTmplComp = Handlebars.compile(recentTmpl);
                    $('.asset-being-added').html(recentTmplComp(response)).slideDown();
                }
                if (response.cachedAssetsBefore != response.cachedAssetsAfter) {
                    window.location=caramel.context +'/assets/'+context.type+'/';
                }
            },
            error: function (e) {
                showMessage('Unable to retrieve new assets');
            }
        });
    }

    /*
    The function renders the assets recently added assets
    @assets: An array of assets
     */
    function renderAssets(assets) {
        $(RECENT_ASSET_CONTAINER).html(assets);
    }

    /*
    The function displays a message in the recent asset container
     */
    function showMessage(message) {
        $(RECENT_ASSET_CONTAINER).html(message);
    }

    /*
    The function obtains details of  page
    @return: An object containing the type of asset and the url used to retrieve the recentkt
     */
    function obtainMetaInformation() {
{'fraction_non_alphanumeric': 0.10904204261854483, 'fraction_numerical': 0.00959877135726627, 'mean_word_length': 2.4231274638633375, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '1701199', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1378, 'n_words': 421}