<commit_before>{% load static admin_urls %}
<div id="page-edit-bar">
  <a href="{% url 'admin:logout' %}" class="btn btn-default">Logout</a>
  <a href="{% url "admin:pages_page_change" current_page.id %}" class="btn btn-default">Edit in admin</a>
  {% if request.COOKIES.enable_edit_mode %}
    <button id="page-disable-edit" class="btn btn-primary">Disable Edit Mode</button>
  {% else %}
    <button id="page-enable-edit" class="btn btn-warning">Enable Edit Mode</button>
  {% endif %}
</div>

<div id="edit-overlay" style="display:none">
  <form class="form-group" action="" method="post" target="post-iframe" enctype="multipart/form-data">
  {% csrf_token %}
  <button style="float:right" id="save-edit">Save</button>
  <button style="float:right" id="undo-edit">Undo</button>
  {{ form.as_p }}
  </form> 
</div>

<iframe id="post-iframe" name="post-iframe"></iframe>

<script src='{% static "pages/javascript/pages.js" %}'></script>

<script>
  var plc = $("*").contents().filter(function(){
    return (this.nodeValue && this.nodeValue.startsWith("placeholder") && this.nodeType == Node.COMMENT_NODE)
  });
  var page_id = "{{ current_page.id }}";
  var lang = "{{ lang }}";

  plc.each(function(i, el) {
    $(el.parentNode).attr('data-placeholder-name', el.nodeValue.split(";")[1]);
    $(el).remove();
  });

  var overlay = $("#edit-overlay");
  var name, page_id, lang, element;

  $(document).on('click', '#undo-edit', function(e) {
    e.preventDefault();
    overlay.hide();
  });
  
  $(document).on('click', '#page-enable-edit', function(e) {
    pages.cookie('enable_edit_mode', 'enabled');
    window.location.reload();
  });

  $(document).on('click', '#page-disable-edit', function(e) {
    pages.cookie('enable_edit_mode', null);
    window.location.reload();
  });

  $(document).on('click', '#save-edit', function(e) {
    setTimeout(function(){
      overlay.find('button,input').prop('disabled', true);
    }, 100);
    //overlay.find('form').submit();
  });

  $(document).on('click', '[data-placeholder-name]', function(){
    element = $(this);
    overlay.show();
    name = $(this).attr('data-placeholder-name');

    var modify_url = '{% url "admin:page-modify-placeholder" current_page.id %}';
    modify_url = modify_url + '?content_type=' + name + '&language_id=' + lang<commit_msg>fix() cookie problem with the path<commit_after>{% load static admin_urls %}
<div id="page-edit-bar">
  <a href="{% url 'admin:logout' %}" class="btn btn-default">Logout</a>
  <a href="{% url "admin:pages_page_change" current_page.id %}" class="btn btn-default">Edit in admin</a>
  {% if request.COOKIES.enable_edit_mode %}
    <button id="page-disable-edit" class="btn btn-primary">Disable Edit Mode</button>
  {% else %}
    <button id="page-enable-edit" class="btn btn-warning">Enable Edit Mode</button>
  {% endif %}
</div>

<div id="edit-overlay" style="display:none">
  <form class="form-group" action="" method="post" target="post-iframe" enctype="multipart/form-data">
  {% csrf_token %}
  <button style="float:right" id="save-edit">Save</button>
  <button style="float:right" id="undo-edit">Undo</button>
  {{ form.as_p }}
  </form> 
</div>

<iframe id="post-iframe" name="post-iframe"></iframe>

<script src='{% static "pages/javascript/pages.js" %}'></script>

<script>
  var plc = $("*").contents().filter(function(){
    return (this.nodeValue && this.nodeValue.startsWith("placeholder") && this.nodeType == Node.COMMENT_NODE)
  });
  var page_id = "{{ current_page.id }}";
  var lang = "{{ lang }}";

  plc.each(function(i, el) {
    $(el.parentNode).attr('data-placeholder-name', el.nodeValue.split(";")[1]);
    $(el).remove();
  });

  var overlay = $("#edit-overlay");
  var name, page_id, lang, element;

  $(document).on('click', '#undo-edit', function(e) {
    e.preventDefault();
    overlay.hide();
  });
  
  $(document).on('click', '#page-enable-edit', function(e) {
    pages.cookie('enable_edit_mode', 'enabled', {path: '/'});
    window.location.reload();
  });

  $(document).on('click', '#page-disable-edit', function(e) {
    pages.cookie('enable_edit_mode', null, {path: '/'});
    window.location.reload();
  });

  $(document).on('click', '#save-edit', function(e) {
    setTimeout(function(){
      overlay.find('button,input').prop('disabled', true);
    }, 100);
    //overlay.find('form').submit();
  });

  $(document).on('click', '[data-placeholder-name]', function(){
    element = $(this);
    overlay.show();
    name = $(this).attr('data-placeholder-name');

    var modify_url = '{% url "admin:page-modify-placeholder" current_page.id %}';
    modify_url = modify_url + '?content_type=' + name + '&language_id=' + lang
{'fraction_non_alphanumeric': 0.22355204103440907, 'fraction_numerical': 0.0017097670442402222, 'mean_word_length': 4.454545454545454, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '4137503', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1578, 'n_words': 280}