<commit_before>APP.use(['jquery-2.0.3', 'jquery-1.8.2', 'jtemplates' ,'jquery.ui', 'jquery.ui.touch.punch', 'jquery.htmlClean', 'highcharts', 'Tipsy'], function () {
    $.getScript('src/plugins/bootstrap.min.js');
    var templatePath = 'src/scripts/modules/',
        rapPath = 'http://rap.alibaba-inc.com/mock/52';
    $( function () {
        $('div[data-modulename]').each( function (i, n) {
            console.warn(n, i);
            var m = $(n),
                name = m.data('modulename');
            m.setTemplateURL([templatePath, '/', name, '/view/', name, '.tpl'].join(''), null, {runnable_functions: true, disallow_functions: false}).processTemplate({});
        });
    })
    function supportstorage() {
        if (typeof window.localStorage=='object')
            return true;
        else
            return false;		
    }

    function handleSaveLayout() {
        var e = $(".demo").html();
        if (!stopsave && e != window.demoHtml) {
            stopsave++;
            window.demoHtml = e;
            saveLayout();
            stopsave--;
        }
    }

    var layouthistory; 
    function saveLayout(){
        var data = layouthistory;
        if (!data) {
            data={};
            data.count = 0;
            data.list = [];
        }
        if (data.list.length>data.count) {
            for (i=data.count;i<data.list.length;i++)
                data.list[i]=null;
        }
        data.list[data.count] = window.demoHtml;
        data.count++;
        if (supportstorage()) {
            localStorage.setItem("layoutdata",JSON.stringify(data));
        }
        layouthistory = data;
        //console.log(data);
        /*$.ajax({  
            type: "POST",  
            url: "/build/saveLayout",  
            data: { layout: $('.demo').html() },  
            success: function(data) {
                //updateButtonsVisibility();
            }
        });*/
    }

    function downloadLayout(){
        
        $.ajax({  
            type: "POST",  
            url: "/build/downloadLayout",  
            data: { layout: $('#download-layout').html() },  <commit_msg>bugfix for: when the localStorage item "layoutdata" is full throw Exception<commit_after>APP.use(['jquery-2.0.3', 'jquery-1.8.2', 'jtemplates' ,'jquery.ui', 'jquery.ui.touch.punch', 'jquery.htmlClean', 'highcharts', 'Tipsy'], function () {
    $.getScript('src/plugins/bootstrap.min.js');
    var templatePath = 'src/scripts/modules/',
        rapPath = 'http://rap.alibaba-inc.com/mock/52';
    $( function () {
        $('div[data-modulename]').each( function (i, n) {
            console.warn(n, i);
            var m = $(n),
                name = m.data('modulename');
            m.setTemplateURL([templatePath, '/', name, '/view/', name, '.tpl'].join(''), null, {runnable_functions: true, disallow_functions: false}).processTemplate({});
        });
    })
    function supportstorage() {
        if (typeof window.localStorage=='object')
            return true;
        else
            return false;		
    }

    function handleSaveLayout() {
        var e = $(".demo").html();
        if (!stopsave && e != window.demoHtml) {
            stopsave++;
            window.demoHtml = e;
            saveLayout();
            stopsave--;
        }
    }

    var layouthistory; 
    function saveLayout(){
        var data = layouthistory;
        if (!data) {
            data={};
            data.count = 0;
            data.list = [];
        }
        if (data.list.length>data.count) {
            for (i=data.count;i<data.list.length;i++)
                data.list[i]=null;
        }
        data.list[data.count] = window.demoHtml;
        data.count++;
        if (supportstorage()) {
            try {
                localStorage.setItem("layoutdata",JSON.stringify(data));
            } catch (e) {
                console.warn('localstorage maybe full or throw a error of ', e);
            }
        }
        layouthistory = data;
        //console.log(data);
        /*$.ajax({  
            type: "POST",  
            url: "/build/saveLayout",  
            data: { layout: $('.demo').html() },  
            success: function(data) {
                //updateButtonsVisibility();
            }
        });*/
    }

    function downloadLayout(){
        
        $.ajax({  
            type: "POST",  
            url: "/build/downloadLayout",  
            data: { layout: $('#download-layout').html() },  
{'fraction_non_alphanumeric': 0.16700336700336701, 'fraction_numerical': 0.00404040404040404, 'mean_word_length': 1.6602985074626866, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1529383', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1283, 'n_words': 240}