diff --git a/aleksis/core/templates/core/index.html b/aleksis/core/templates/core/index.html index 1c21fad1589233f14b40bc5549c481db30de50d4..ee23f1e7fc8864a79b40e0c048d89131e9ccf409 100644 --- a/aleksis/core/templates/core/index.html +++ b/aleksis/core/templates/core/index.html @@ -1,5 +1,5 @@ {% extends 'core/base.html' %} -{% load i18n %} +{% load i18n static %} {% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %} @@ -32,8 +32,7 @@ {% endwith %} </div> {% endfor %} - </div> - + </div> <div class="row"> <div class="col s12 m6"> @@ -89,58 +88,5 @@ </div> {% endif %} - <script type="text/javascript"> - const asyncIntervals = []; - - const runAsyncInterval = async (cb, interval, intervalIndex) => { - await cb(); - if (asyncIntervals[intervalIndex]) { - setTimeout(() => runAsyncInterval(cb, interval, intervalIndex), interval); - } - }; - - const setAsyncInterval = (cb, interval) => { - if (cb && typeof cb === "function") { - const intervalIndex = asyncIntervals.length; - asyncIntervals.push(true); - runAsyncInterval(cb, interval, intervalIndex); - return intervalIndex; - } else { - throw new Error('Callback must be a function'); - } - }; - - const clearAsyncInterval = (intervalIndex) => { - if (asyncIntervals[intervalIndex]) { - asyncIntervals[intervalIndex] = false; - } - }; - - /* SOURCE: https://dev.to/jsmccrumb/asynchronous-setinterval-4j69 */ - - {# ------------------------------------------ #} - - {#$(document).ready(function () {#} - {# setInterval(function () {#} - {# $('#body').load("/");#} - {# }, 3000);#} - {# });#} - - {# ------------------------------------------ #} - - let dashboard_interval = setAsyncInterval(async () => { - console.log('fetching new data'); - const promise = new Promise((resolve) => { - $('#dashboard').load("/?include_by_ajax_full_render=1 #dashboard"); - resolve(1); - }); - await promise; - console.log('data fetched successfully'); - }, 15000); - - $(document).on('include_by_ajax_all_loaded', function() { - console.log('Now all placeholders are loaded and replaced with content'); - }) - - </script> + <script type="text/javascript" src="{% static "js/include_ajax_live.js" %}"></script> {% endblock %}