<commit_before>{% load i18n %}
{% load url from future %}
<style type="text/css">
    #subsettingsoptions {
        min-height: 60%;
    }

    #floor svg, #floorOverlay svg {
        position: absolute;
        top: 15%;
        left: 20px;
        max-height: 60%;
        max-width: 60%;
    }
</style>
{{ selectfloor }}
<div id="floor">
</div>
<div id="floorOverlay">
</div>
<div id="dialog-save-room" title="">
    <form action="{% url 'room_plan' %}" method="post">{% csrf_token %}
        {{ form.as_p }}
        <input type="submit" name="save" value="{% trans "Save" %}"/>
    </form>
</div>
<script type="text/javascript">
    var x1, y1, x, y, first, svg;
    function get_floor() {
        var floor = $('#selectfloor').val();
        $('input[name="floor"]').val(floor);
        $('#floor').load('{% url 'common.views.floor' %}' + floor + '/');
        $('#floorOverlay').load('{% url 'common.views.overlay' %}', {'floor': floor, 'edit_rooms': true}, function () {

            var svgNamespace = 'http://www.w3.org/2000/svg';
            var $overlay = $('#floorOverlay svg');
            first = true;

            $overlay.on('click', function (e) {
                var pt = this.createSVGPoint();
                pt.x = e.clientX;
                pt.y = e.clientY;

                var loc = pt.matrixTransform(this.getScreenCTM().inverse());
                x = Math.round(loc.x);
                y = Math.round(loc.y);

                if (first) {
                    x1 = x;
                    y1 = y;
                    svg = e.target.ownerDocument.createElementNS(svgNamespace, 'rect');
                    svg.setAttributeNS(null, 'class', 'map');
                    svg.setAttributeNS(null, 'x', x1);
                    svg.setAttributeNS(null, 'y', y1);
                    svg.setAttributeNS(null, 'height', '0');
                    svg.setAttributeNS(null, 'width', '0');
                    svg.setAttributeNS(null, 'fill', 'rgba(100, 149, 237, 0.5)');
                    svg.setAttributeNS(null, 'pointer-events', 'none');
                    this.appendChild(svg);
                    first = false;
                } else {
                    if (x1 > x) {
                        $('input[name="width"]').val(x1 - x);
                        $('input[name="x"]').val(x);
                    } else {
                        $('input[name="width"]').val(x - x1);
                        $('input[name="x"]').val(x1);
                    }
                    if (y1 > y) {
                        $('input[name="height"]').val(y1 - y);
                        $('input[name="y"]').val(y);
                    } else {
                        $('input[name="height"]').val(y - y1);
                        $('input[name="y"]').val(y1);
                    }
                    $('#dialog-save-room').dialog('open');
                }

                e.preventDefault();
                e.stopPropagation();
                return false;
            });
            $overlay.on('mousemove', function (e) {
                var pt = this.createSVGPoint();
                pt.x = e.clientX;
                pt.y = e.clientY;

                var loc = pt.matrixTransform(this.getScreenCTM().inverse());
                x = Math.round(loc.x);
                y = Math.round(loc.y);

                if (!first) {
                    if (x1 > x) {
                        svg.setAttributeNS(null, 'width', x1 - x);
                        svg.setAttributeNS(null, 'x', x);
                    } else {
                        svg.setAttributeNS(null, 'width', x - x1);
                        svg.setAttributeNS(null, 'x', x1);
                    }
                    if (y1 > y) {
                        svg.setAttributeNS(null, 'height', y1 - y);
                        svg.setAttributeNS(null, 'y', y);
                    } else {
                        svg.setAttributeNS(null, 'height', y - y1);
                        svg.setAttributeNS(null, 'y', y1);
                    }
                }
            });
            $overlay.on('contextmenu', function (e) {
                if (!first) {
                    $('.map').remove();
                    first = true;
                }
                e.preventDefault();
                e.stopPropagation();
                return false;
            });
        });
    }
    $(function () {
        get_floor();
        $('#selectfloor').change(get_floor);
        $('#dialog-save-room').dialog({
            modal: true,
            autoOpen: false
        });
        $('#Roptions').height($('#options').height() * 0.8);
    });
    function delete_room(id) {
        $.post('{% url 'room_plan' %}', {'id': id}, function () {
            get_floor();
        });
    }
</script><commit_msg>In settings>room>plan don't start drawing a new room when deleting a old one.<commit_after>{% load i18n %}
{% load url from future %}
<style type="text/css">
    #subsettingsoptions {
        min-height: 60%;
    }

    #floor svg, #floorOverlay svg {
        position: absolute;
        top: 15%;
        left: 20px;
        max-height: 60%;
        max-width: 60%;
    }
</style>
{{ selectfloor }}
<div id="floor">
</div>
<div id="floorOverlay">
</div>
<div id="dialog-save-room" title="">
    <form action="{% url 'room_plan' %}" method="post">{% csrf_token %}
        {{ form.as_p }}
        <input type="submit" name="save" value="{% trans "Save" %}"/>
    </form>
</div>
<script type="text/javascript">
    var x1, y1, x, y, first, svg;
    function get_floor() {
        var floor = $('#selectfloor').val();
        $('input[name="floor"]').val(floor);
        $('#floor').load('{% url 'common.views.floor' %}' + floor + '/');
        $('#floorOverlay').load('{% url 'common.views.overlay' %}', {'floor': floor, 'edit_rooms': true}, function () {

            var svgNamespace = 'http://www.w3.org/2000/svg';
            var $overlay = $('#floorOverlay svg');
            first = true;

            $overlay.on('click', function (e) {
                var pt = this.createSVGPoint();
                pt.x = e.clientX;
                pt.y = e.clientY;

                var loc = pt.matrixTransform(this.getScreenCTM().inverse());
                x = Math.round(loc.x);
                y = Math.round(loc.y);

                if (first) {
                    x1 = x;
                    y1 = y;
                    svg = e.target.ownerDocument.createElementNS(svgNamespace, 'rect');
                    svg.setAttributeNS(null, 'class', 'map');
                    svg.setAttributeNS(null, 'x', x1);
                    svg.setAttributeNS(null, 'y', y1);
                    svg.setAttributeNS(null, 'height', '0');
                    svg.setAttributeNS(null, 'width', '0');
                    svg.setAttributeNS(null, 'fill', 'rgba(100, 149, 237, 0.5)');
                    svg.setAttributeNS(null, 'pointer-events', 'none');
                    this.appendChild(svg);
                    first = false;
                } else {
                    if (x1 > x) {
                        $('input[name="width"]').val(x1 - x);
                        $('input[name="x"]').val(x);
                    } else {
                        $('input[name="width"]').val(x - x1);
                        $('input[name="x"]').val(x1);
                    }
                    if (y1 > y) {
                        $('input[name="height"]').val(y1 - y);
                        $('input[name="y"]').val(y);
                    } else {
                        $('input[name="height"]').val(y - y1);
                        $('input[name="y"]').val(y1);
                    }
                    $('#dialog-save-room').dialog('open');
                }

                e.preventDefault();
                e.stopPropagation();
                return false;
            });
            $overlay.on('mousemove', function (e) {
                var pt = this.createSVGPoint();
                pt.x = e.clientX;
                pt.y = e.clientY;

                var loc = pt.matrixTransform(this.getScreenCTM().inverse());
                x = Math.round(loc.x);
                y = Math.round(loc.y);

                if (!first) {
                    if (x1 > x) {
                        svg.setAttributeNS(null, 'width', x1 - x);
                        svg.setAttributeNS(null, 'x', x);
                    } else {
                        svg.setAttributeNS(null, 'width', x - x1);
                        svg.setAttributeNS(null, 'x', x1);
                    }
                    if (y1 > y) {
                        svg.setAttributeNS(null, 'height', y1 - y);
                        svg.setAttributeNS(null, 'y', y);
                    } else {
                        svg.setAttributeNS(null, 'height', y - y1);
                        svg.setAttributeNS(null, 'y', y1);
                    }
                }
            });
            $overlay.on('contextmenu', function (e) {
                if (!first) {
                    $('.map').remove();
                    first = true;
                }
                e.preventDefault();
                e.stopPropagation();
                return false;
            });
        });
    }
    $(function () {
        get_floor();
        $('#selectfloor').change(get_floor);
        $('#dialog-save-room').dialog({
            modal: true,
            autoOpen: false
        });
        $('#Roptions').height($('#options').height() * 0.8);
    });
    function delete_room(id) {
        $.post('{% url 'room_plan' %}', {'id': id}, function () {
            get_floor();
        });
        return false;
    }
</script>
{'fraction_non_alphanumeric': 0.16873577488102628, 'fraction_numerical': 0.0111731843575419, 'mean_word_length': 1.2356614246068456, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3394509', 'n_tokens_mistral': 2876, 'n_tokens_neox': 2675, 'n_words': 521}