{% extends "waliki/history.html" %}
{% load i18n %}
{% load static %}

{% block title %}
    <h3 id="top">{% trans "Diff" %}: <a href="{{ page.get_absolute_url }}">/{{ page.slug }}</a></h3>
{% endblock title %}

{% block content %}

    <div class="alert alert-info">
        {% trans "Comparing" %} <a href="{% url "waliki_version" page.slug new_commit %}">{{ new_commit }}</a> vs. <a href="{% url "waliki_version" page.slug old_commit %}">{{ old_commit }}</a>

        <a href="{% url 'waliki_diff_raw' page.slug old_commit new_commit %}" class="btn btn-default btn-sm">{% trans "Raw" %}</a>
    </div>




    <div id="diff" class="monospace"></div>


{% endblock %}

{% block extra_script %}
<!-- Taken from http://neil.fraser.name/news/2006/03/19/ //-->
<script src="{% static 'js/diff_match_patch.js' %}"></script>
<script type="text/javascript">
function diff() {
  var dmp = new diff_match_patch();
  var new_content = "{{ new_content|escapejs }}";
  var old_content = "{{ old_content|escapejs }}";
  var d = dmp.diff_main(old_content, new_content);
  dmp.diff_cleanupSemantic(d);
  var ds = dmp.diff_prettyHtml(d);
  $('#diff').append(ds);;
}
diff();
</script>
{% endblock %}