<commit_before>{% load staticfiles %}

<!DOCTYPE html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    {% load bootstrap3 %}

    {% bootstrap_css %}

    <script type="text/javascript" src="{% bootstrap_jquery_url %}">

    {% bootstrap_javascript %}

    {% bootstrap_messages %}

    <link rel="stylesheet" type="text/css" href="{% static 'surl/css/main.css' %}" />

    <script type="text/javascript">
        $(function() {
            $('#url').focus();
            $('input[type=submit]').click(function(e) {
                e.preventDefault();
                var data = {
                    url: $('#url').val(),
                    name: $('#name').val(),
                    reuse: $('#reuse').attr('checked') ? '1': '',
                    csrfmiddlewaretoken: '{{ csrf_token }}'
                }
                $.ajax({
                    url: '{% url "root" %}',
                    type: 'POST',
                    data: data,
                    error: function(xhr, textStatus, errorThrown) {
                        $('#error').remove();
                        $('#result').remove();
                        $('<div class="col-md-4 col-xs-9 col-centered"><div id="error"></div></div>').appendTo($('form'));
                        var msg = 'error';
                        switch(xhr.responseText) {
                            case 'invalid request':
                                msg = 'Invalid url';
                                break;
                            case 'name already used':
                                msg = 'Duplicate code';
                                break;
                        }
                        $('#error').text('error: ' + msg);
                    },
                    success: function(data, textStatus, xhr) {
                        $('#error').remove();
                        $('#result').remove();
                        $('<div class="col-md-4 col-xs-9 col-centered"><a id="result" href="#"><div id="result"></div></a></div>').appendTo($('form'));
                        $('#result div').text(data);
                        $('#result').attr('href', data);
                    }
                });
            })
        });
    </script>
</head>
<body>
    <div class="col-md-12 col-xs-12" style="text-align: center;display: table-cell;vertical-align: middle;">
        <img src="{% static 'surl/images/logo.png' %}" style="margin:10px"/>
        <form action="{% url 'root' %}" method="post" role="form">
            {% csrf_token %}
            <div id="row-url" class="form-group">
                <input type="text" id="url" name="url" value="http://" placeholder="Your long url"/>
            </div>
            <div id="row-optional">
                <div id="col-code" class="form-group">
                    <input type="text" id="name" name="name" maxlength="16" value="" placeholder="Code (optional)"/>
                </div>
                <div id="col-reuse" class="form-group">
                    <input type="checkbox" id="reuse" name="reuse" value="1" checked="checked" />
                    <label for="reuse">If possible reuse an existing short url</label>
                </div>
            </div>
            <div id="row-controls">
                <input type="submit" class="btn btn-success" value="Shorten" />
            </div>
        </form>
    </div>
</body>
{% if jsonp %}
{% comment %}
(function() {
document.log=function(data){ prompt('The short version', data); };
var e=document.createElement("script");
e.src="{{jsonp}}?q=" + encodeURIComponent(document.location.href) + "&t=" + encodeURIComponent(document.title);
e.type="text/javascript";<commit_msg>Minfixes on form layout and labels<commit_after>{% load staticfiles %}

<!DOCTYPE html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    {% load bootstrap3 %}

    {% bootstrap_css %}

    <script type="text/javascript" src="{% bootstrap_jquery_url %}">

    {% bootstrap_javascript %}

    {% bootstrap_messages %}

    <link rel="stylesheet" type="text/css" href="{% static 'surl/css/main.css' %}" />

    <script type="text/javascript">
        $(function() {
            $('#url').focus();
            $('input[type=submit]').click(function(e) {
                e.preventDefault();
                var data = {
                    url: $('#url').val(),
                    name: $('#name').val(),
                    reuse: $('#reuse').attr('checked') ? '1': '',
                    csrfmiddlewaretoken: '{{ csrf_token }}'
                }
                $.ajax({
                    url: '{% url "root" %}',
                    type: 'POST',
                    data: data,
                    error: function(xhr, textStatus, errorThrown) {
                        $('#error').remove();
                        $('#result').remove();
                        $('<div class="col-md-4 col-xs-9 col-centered"><div id="error"></div></div>').appendTo($('form'));
                        var msg = 'generic error.';
                        switch(xhr.responseText) {
                            case 'invalid request':
                                msg = 'invalid url.';
                                break;
                            case 'name already used':
                                msg = 'duplicate code.';
                                break;
                        }
                        $('#error').text('Error: ' + msg);
                    },
                    success: function(data, textStatus, xhr) {
                        $('#error').remove();
                        $('#result').remove();
                        $('<div class="col-md-4 col-xs-9 col-centered"><a id="result" href="#"><div id="result"></div></a></div>').appendTo($('form'));
                        $('#result div').text(data);
                        $('#result').attr('href', data);
                    }
                });
            })
        });
    </script>
</head>
<body>
    <div class="col-md-12 col-xs-12" style="text-align: center;display: table-cell;vertical-align: middle;">
        <img src="{% static 'surl/images/logo.png' %}" style="margin:10px"/>
        <form action="{% url 'root' %}" method="post" role="form">
            {% csrf_token %}
            <div id="row-url" class="form-group">
                <input class="col-md-4 col-xs-9 col-centered" type="text" id="url" name="url" value="http://" placeholder="Your long url"/>
            </div>
            <div id="row-optional">
                <div id="col-code" class="form-group">
                    <input class="col-md-2 col-xs-5 col-centered" type="text" id="name" name="name" maxlength="16" value="" placeholder="Code (optional)"/>
                </div>
                <div id="col-reuse" class="form-group">
                    <input type="checkbox" id="reuse" name="reuse" value="1" checked="checked" />
                    <label for="reuse">If possible reuse an existing short url</label>
                </div>
            </div>
            <div id="row-controls">
                <input type="submit" class="btn btn-success" value="Shorten" />
            </div>
        </form>
    </div>
</body>
{% if jsonp %}
{% comment %}
(function() {
document.log=function(data){ prompt('The short version', data); };
var e=document.createElement("script");
e.src="{{jsonp}}?q=" + encodeURIComponent(document.location.href) + "&t=" + encodeURIComponent(document.title);
e.type="text/javascript";
{'fraction_non_alphanumeric': 0.18125165738530893, 'fraction_numerical': 0.00503845133916733, 'mean_word_length': 1.5414420485175202, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3491558', 'n_tokens_mistral': 2118, 'n_tokens_neox': 1978, 'n_words': 397}