<commit_before>/*
    index.js
    Dependent:  jQuery
*/
define(function( require, exports, module ){
    
    var $           = require('jquery'),
        settings    = require('./settings'),
        site        = require('./site'),
        header      = require('./header');
    
    var main = $('#main');

    $(function(){
        
        home();

        $('#home').on('click',function(e){
            e.preventDefault();
            home();
        });

        main.on('click','.post-name',function(e){
            e.preventDefault();
            var target = $(e.target),
                href = target.attr('href');
            if( href ){
                window.location.hash = href;
            }
        });

        $(window).on('hashchange',function(e){
            var hash = window.location.hash;
            single( hash.slice(1,hash.length) );
            console.log(hash.slice(1,hash.length));
        });

        
        function home(){
            $.get(
                settings.url + ':' + settings.port
                ,function(data){
                    main.html(data);
                }
            );
        }

        function single( name ){
            $.get(
                settings.url + ':' + settings.port + '?post='+name
                ,function(data){
                    main.html(data);
                }
            );
        }

    });

});<commit_msg>many modifications<commit_after>/*
    index.js
    Dependent:  jQuery
*/
define(function( require, exports, module ){
    
    var $           = require('jquery'),
        settings    = require('./settings'),
        site        = require('./site'),
        header      = require('./header'),
        history     = window.history;
    
    var main = $('#main');

    $(function(){
        
        hasQuery();

        $('#home').on('click',function(e){
            e.preventDefault();
            if(history.state){
                history.back(1);
            }
        });

        main.on('click','.post-name',function(e){
            e.preventDefault();
            var href = $(e.target).attr('href'),
                post = href.slice(0,href.length-3);
            history.pushState({
                state:  1
                ,post:  post
            },post,'?post='+post);
            hasQuery()
        });

        $(window).on('popstate',function(){
            console.log(history.state)
            hasQuery()
        })

        function home(){
            $.get(
                settings.url + ':' + settings.port
                ,function(data){
                    main.html(data);
                }
            );
        }

        function single( post ){
            $.get(
                settings.url + ':' + settings.port + '?post='+post+'.md'
                ,function(data){
                    main.html(data);
                }
            );
        }

        function queryObject(){
            var query   = window.location.search.substring(1),
                vars    = query.split('&'),
                obj     = {};
            for( var i=0,len=vars.length; i<len; i++){
                var pair = vars[i].split('=');
                obj[ pair[0] ] = pair[1];
            }
            return obj;
        }

        function hasQuery(){
            var post = queryObject().post;
            post ? single(post) : home();
        }

   });

});
{'fraction_non_alphanumeric': 0.15707115441393563, 'fraction_numerical': 0.002952465308532625, 'mean_word_length': 1.1524777636594663, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '5466232', 'n_tokens_mistral': 903, 'n_tokens_neox': 866, 'n_words': 148}