<commit_before>{% extends 'events_evaluation_base.html' %}{% load staticfiles %}{% load bootstrap3 %}

{% block title %}التحضير ل{{ session.name }}{% endblock %}


{% block content %}

<div class="text-center">
   <img src="https://hpc.enjazportal.com/wp-content/uploads/2016/12/hpc.png" style="max-width: 120px;">
</div>

<h1 class="text-center">التحضير ل{{ session.name }}</h1>
<div class="row" style="margin-bottom: 40px; margin-top: 20px;">
<p id="welcome">أهلا، <span id="name"></span>!</p>
{% include "media/polls/ajax-loader.html" %}
<div class="col-sm-4 col-sm-offset-4 text-center">
<input id="barcode" type="text" class="form-control">
{% bootstrap_field form.category %}

<input checked id="id_only_registered" type="checkbox">
<label for="id_only_registered"> حضّر المُسجّلين والمُسجّلات فقط</label>
<br>

<button class="btn btn-danger btn-sm" id="cancel-last"></button>
</div>
</div>
{% endblock %}

{% block customscript %}
<script src="{% static 'neon/assets/js/toastr.js' %}"></script>
<style>

#welcome, #loading-image, #cancel-last{
  visibility: hidden;
}

#barcode{
  text-align: center;
  font-size: 18px;
}

#welcome{
  text-align: center;
  font-size: 24px;
  color: #606060;
}

.form-group{
  margin-top: 20px;
  text-align: center;
}

.form-group .form-control, .form-group label{
  font-size: 0.7em;
}

#id_category{
  width: auto;
  margin-right: auto;
  margin-left: auto;
}


.checkbox label{
  margin-left: -90px;
}
</style>

<script>
$(function(){
  url = "{% url 'events:process_barcode' session.event.code_name session.pk %}";
  $("#barcode").keydown(function(e){

   // get keycode of current keydown event
    var code = (e.keyCode || e.which);

    // do nothing if it's an arrow key
    if(code == 37 || code == 38 || code == 39 || code == 40) {
        return;
    }

    user_pk = $("#barcode").val()
    // If length reaches our target, or enter (code 13) is pressed on a filled input.
    if (user_pk.length == {{ BARCODE_LENGTH }} || code == 13 && user_pk.length){
        $('#loading-image').css('visibility', 'visible');
        $('#welcome').css('visibility', 'invisible');
        $.ajax({
            data: {user_pk: user_pk, action: 'attend',
                   category: $("#id_category").val(),
                   only_registered: $("#id_only_registered:checked").length},
            url: url,
            type: 'POST',
            cache: false,
            success: function(data){
                if (data['success'] == 1){
                    $("#barcode").val("");
                    $("#name").html(data.full_name);
                    $("#welcome, #cancel-last").css('visibility', 'visible');
                    $("#cancel-last").data("last-attendance-pk", data.last_pk).html("ألغِ " + data.full_name);
                } else if (data['success'] == 0){
                    toastr.error(data['message']);
                    $("#cancel-last").css('visibility', 'invisible');
                }
            },
            complete: function(data){
                $('#loading-image').css('visibility', 'invisible');
            }
        });
    } else {
        $('#welcome').css('visibility', 'invisible');
    }
  });<commit_msg>Use keyup!<commit_after>{% extends 'events_evaluation_base.html' %}{% load staticfiles %}{% load bootstrap3 %}

{% block title %}التحضير ل{{ session.name }}{% endblock %}


{% block content %}

<div class="text-center">
   <img src="https://hpc.enjazportal.com/wp-content/uploads/2016/12/hpc.png" style="max-width: 120px;">
</div>

<h1 class="text-center">التحضير ل{{ session.name }}</h1>
<div class="row" style="margin-bottom: 40px; margin-top: 20px;">
<p id="welcome">أهلا، <span id="name"></span>!</p>
{% include "media/polls/ajax-loader.html" %}
<div class="col-sm-4 col-sm-offset-4 text-center">
<input id="barcode" type="text" class="form-control">
{% bootstrap_field form.category %}

<input checked id="id_only_registered" type="checkbox">
<label for="id_only_registered"> حضّر المُسجّلين والمُسجّلات فقط</label>
<br>

<button class="btn btn-danger btn-sm" id="cancel-last"></button>
</div>
</div>
{% endblock %}

{% block customscript %}
<script src="{% static 'neon/assets/js/toastr.js' %}"></script>
<style>

#welcome, #loading-image, #cancel-last{
  visibility: hidden;
}

#barcode{
  text-align: center;
  font-size: 18px;
}

#welcome{
  text-align: center;
  font-size: 24px;
  color: #606060;
}

.form-group{
  margin-top: 20px;
  text-align: center;
}

.form-group .form-control, .form-group label{
  font-size: 0.7em;
}

#id_category{
  width: auto;
  margin-right: auto;
  margin-left: auto;
}


.checkbox label{
  margin-left: -90px;
}
</style>

<script>
$(function(){
  url = "{% url 'events:process_barcode' session.event.code_name session.pk %}";
  $("#barcode").keyup(function(e){
   // get keycode of current keydown event
    var code = (e.keyCode || e.which);

    // do nothing if it's an arrow key
    if(code == 37 || code == 38 || code == 39 || code == 40) {
        return;
    }

    user_pk = $("#barcode").val()

    // If length reaches our target, or enter (code 13) is pressed on a filled input.
    if (user_pk.length == {{ BARCODE_LENGTH }} || code == 13 && user_pk.length){
        $('#loading-image').css('visibility', 'visible');
        $('#welcome').css('visibility', 'invisible');
        $.ajax({
            data: {user_pk: user_pk, action: 'attend',
                   category: $("#id_category").val(),
                   only_registered: $("#id_only_registered:checked").length},
            url: url,
            type: 'POST',
            cache: false,
            success: function(data){
                if (data['success'] == 1){
                    $("#barcode").val("");
                    $("#name").html(data.full_name);
                    $("#welcome, #cancel-last").css('visibility', 'visible');
                    $("#cancel-last").data("last-attendance-pk", data.last_pk).html("ألغِ " + data.full_name);
                } else if (data['success'] == 0){
                    toastr.error(data['message']);
                    $("#cancel-last").css('visibility', 'invisible');
                }
            },
            complete: function(data){
                $('#loading-image').css('visibility', 'invisible');
            }
        });
    } else {
        $('#welcome').css('visibility', 'invisible');
    }
  });
{'fraction_non_alphanumeric': 0.19761418929524407, 'fraction_numerical': 0.01506827813530058, 'mean_word_length': 2.743830787309048, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 2, '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': '4888264', 'n_tokens_mistral': 2284, 'n_tokens_neox': 2129, 'n_words': 441}