<commit_before>{% extends "admin/base_site.html" %}
{% load adminmedia admin_list i18n easytree_tags %}

{% block extrahead %}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
<script type="text/javascript">

    function find_depth(item) {
        var lvl = 0
        for (var i=10;i>=1;i--) {
            lvl = i
            if (item.hasClass('level_' + i)) break;
        }
        return lvl
    }
    
    function alter_depth(item, diffdepth) {
        var fromdepth = find_depth(item)
        var todepth = fromdepth + diffdepth
        item.removeClass('level_' + fromdepth)
        item.addClass('level_' + todepth)
        var depthstr = ''
        for (var i=1; i < todepth; i++) depthstr += '&gt;&gt;&gt; '
        $('.display_indent', item).html(depthstr)
    }

    function get_child_nodes(item) {
        var nodes = []
        var belowdepth = find_depth($(item))
        var curitem = item.next()
        while(curitem.get(0) && find_depth(curitem)>belowdepth) {
            nodes.push(curitem)
            curitem=curitem.next()
        }
        return nodes
    }

    function make_proxy(item) {
        
        var proxytbl = $('<table cellspacing="0"></table>')
        proxytbl.width(item.closest('table').width())
        
        var firstrow = item.clone()
        var old_tds = $('td, th', item)
        var new_tds = $('td, th', firstrow)
        for (var i=0;i<old_tds.length;i++) {
            $(new_tds.get(i)).width($(old_tds.get(i)).width())
        }
        
        firstrow.appendTo(proxytbl)
        
        var nodes = get_child_nodes(item)
        $(nodes).each(function(){
            $(this).droppable('disable') // disable drop on dragged nodes
            $(this).clone().removeAttr("id").appendTo(proxytbl)
        })

        return proxytbl
    }

    $(document).ready(function() {
        
        $('tr.result_item').each(function() {
            
            function helper() {
                return make_proxy($(this))
            }
            
            $(this).draggable({'helper': helper, opacity: 0.6})
            
            var drp = $(this) // store this node for use in deactivate

            var deactivate = function(event, ui) {
                var nodes = get_child_nodes(drp) // enable drop on dragged nodes
                $(nodes).each(function(){
                    $(this).droppable('enable')
                })
            }
            
            var drop = function(event, ui) {
                $('#position-menu').css("top", event.pageY-15).css("left", event.pageX-60).css("z-index", 2).show()
            }
            
            $(this).droppable({hoverClass: 'marked', tolerance: 'pointer', deactivate: deactivate, drop: drop })
            
            $('#position-menu').bind('mouseleave', function() { $(this).hide() })

        })
    })
</script>
<style type="text/css">
    .marked { background: #ffcccc; }
    #position-menu { position: absolute; display: none; }
    #position-menu { background: #e8ffe8; padding: 3px; width: 10em; }
    #position-menu li { list-style-type: none; display: block; margin: 0; padding: 3px; }
    #position-menu li.heading { font-weight: bold; }
    #position-menu li.position:hover { background: #ffffff; margin: 0; }

</style>

</head>
{% endblock %}<commit_msg>javascript working, next add some ajax views<commit_after>{% extends "admin/base_site.html" %}
{% load adminmedia admin_list i18n easytree_tags %}

{% block extrahead %}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
<script type="text/javascript">

    function find_depth(item) {
        var lvl = 0
        for (var i=10;i>=1;i--) {
            lvl = i
            if (item.hasClass('level_' + i)) break;
        }
        return lvl
    }
    
    function alter_depth(item, diffdepth) {
        var fromdepth = find_depth(item)
        var todepth = fromdepth + diffdepth
        item.removeClass('level_' + fromdepth)
        item.addClass('level_' + todepth)
        var depthstr = ''
        for (var i=1; i < todepth; i++) depthstr += '&gt;&gt;&gt; '
        $('.display_indent', item).html(depthstr)
    }

    function get_child_nodes(item) {
        var nodes = []
        var belowdepth = find_depth($(item))
        var curitem = item.next()
        while(curitem.get(0) && find_depth(curitem)>belowdepth) {
            nodes.push(curitem)
            curitem=curitem.next()
        }
        return nodes
    }

    function make_proxy(item) {
        
        var proxytbl = $('<table cellspacing="0"></table>')
        proxytbl.width(item.closest('table').width())
        
        var firstrow = item.clone()
        var old_tds = $('td, th', item)
        var new_tds = $('td, th', firstrow)
        for (var i=0;i<old_tds.length;i++) {
            $(new_tds.get(i)).width($(old_tds.get(i)).width())
        }
        
        firstrow.appendTo(proxytbl)
        
        var nodes = get_child_nodes(item)
        $(nodes).each(function(){
            $(this).droppable('disable') // disable drop on dragged nodes
            $(this).clone().removeAttr("id").appendTo(proxytbl)
        })

        return proxytbl
    }

    $(document).ready(function() {
        
        $('tr.result_item').each(function() {
            
            function helper() {
                return make_proxy($(this))
            }
            
            $(this).draggable({'helper': helper, opacity: 0.6})
            
            var drp = $(this) // store this node for use in deactivate

            var deactivate = function(event, ui) {
                var nodes = get_child_nodes(drp) // enable drop on dragged nodes
                $(nodes).each(function(){
                    $(this).droppable('enable')
                })
            }
            
            var drop = function(event, ui) {
                
                var dropped_on = $(this)
                
                $('#position-menu')
                    .css("top", event.pageY-15)
                    .css("left", event.pageX-60)
                    .show()
                    .bind('click', function(e){
                        $(this).unbind('click')
                        $(this).hide()
                        alert($(e.target).closest('.position').attr('id') + ' ' + ui.draggable.attr('id') + ' ' + dropped_on.attr('id') )
                    })

            }
            
            $(this).droppable({hoverClass: 'marked', tolerance: 'pointer', deactivate: deactivate, drop: drop })
            
            $('#position-menu').bind('mouseleave', function() { $(this).unbind('click'); $(this).hide() })

        })
    })
</script>
<style type="text/css">
    .marked { background: #ffcccc; }
    #position-menu { position: absolute; display: none; z-index: 2; }
    #position-menu { background: #e8ffe8; padding: 3px; width: 10em; }
    #position-menu li { list-style-type: none; display: block; margin: 0; padding: 3px; }
    #position-menu li.heading { font-weight: bold; }
    #position-menu li.position:hover { background: #ffffff; margin: 0; }

</style>

</head>
{% endblock %}
{'fraction_non_alphanumeric': 0.15736381977135172, 'fraction_numerical': 0.008338937457969065, 'mean_word_length': 1.916078431372549, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '529033', 'n_tokens_mistral': 2310, 'n_tokens_neox': 2234, 'n_words': 437}