From fd5a7ea56cba2f22f84e7ada257c89d5ee354331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CPaul?= <“pstoica@paulstoica.com”> Date: Tue, 14 Nov 2023 16:32:44 -0500 Subject: [PATCH 1/6] moved styles and javascript to files --- linkcheck/static/linkcheck/css/styles.css | 96 +++++++++++++ linkcheck/static/linkcheck/js/script.js | 55 ++++++++ .../templates/linkcheck/base_linkcheck.html | 5 + linkcheck/templates/linkcheck/coverage.html | 4 +- linkcheck/templates/linkcheck/paginator.html | 4 +- linkcheck/templates/linkcheck/report.html | 131 ++---------------- linkcheck/tests/test_linkcheck.py | 4 +- linkcheck/views.py | 2 +- 8 files changed, 172 insertions(+), 129 deletions(-) create mode 100644 linkcheck/static/linkcheck/css/styles.css create mode 100644 linkcheck/static/linkcheck/js/script.js diff --git a/linkcheck/static/linkcheck/css/styles.css b/linkcheck/static/linkcheck/css/styles.css new file mode 100644 index 0000000..8bc4690 --- /dev/null +++ b/linkcheck/static/linkcheck/css/styles.css @@ -0,0 +1,96 @@ + +.objecttype { + width: 99%!important; + margin-bottom: 30px; + border: 0 !important; +} + +.objecttype td { + border: 0; +} + +.module { + width: 100%!important; + border: 0 !important; +} + +.object { + width: 100%!important; + margin: 0; + padding: 35px 0 0 0; +} + +.links { + width: 100%!important; + background-color: white; + border: 1px solid #ddd; + margin: 10px 0 0 0; +} + +.links td, .links tr { + border: 1px solid #ddd; +} + +.links th { + border: 0!important; +} + +td.actioncell { + border-left: 0 !important; + width: 60px !important; +} + +#linkcheck-nav { + width: 100%; + margin-left: auto; + margin-right: auto; + text-align: center; + padding: 10px; +} + +#linkcheck-nav a { + text-decoration: underline; +} + +/* Header Styles */ +.header-cell { + padding: 0; +} + +.header-table-small { + width: 20%; +} + +.header-table-big { + width: 40%; + +} + +.header-report { + display: inline; + padding-left: 5px; +} + +.header-link { + text-decoration: underline; +} + +/* table body styles */ +.emphasis { + font-weight: bold; +} +.coloured-green { + color: green; +} +.coloured-red { + color: red; +} + +/* other styles */ +.current { + margin: 0 25px; +} + +.center-aligned { + text-align: center; +} \ No newline at end of file diff --git a/linkcheck/static/linkcheck/js/script.js b/linkcheck/static/linkcheck/js/script.js new file mode 100644 index 0000000..e54735d --- /dev/null +++ b/linkcheck/static/linkcheck/js/script.js @@ -0,0 +1,55 @@ +function showProgressDots(numberOfDots) { + var progress = document.getElementById('progressDots'); + if (!progress) return; + switch(numberOfDots) { + case 1: + progress.innerHTML = '. '; + timerHandle = setTimeout('showProgressDots(2)',200); + break; + case 2: + progress.innerHTML = '.. '; + timerHandle = setTimeout('showProgressDots(3)',200); + break; + case 3: + progress.innerHTML = '...'; + timerHandle = setTimeout('showProgressDots(1)',200); + break; + } +} + +$(document).ready(function() { + + const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]').value; + + $(".ignore").submit(function(){ + $.post(this.action, {'csrfmiddlewaretoken': csrfToken}, (data) => { + $('tr#link' + data.link).hide('medium'); + var ignored_count = parseInt($('#ignored_count').text()); + ignored_count++; + $('#ignored_count').text(ignored_count); + }); + return false; + }); + + $(".unignore").submit(function(){ + $.post(this.action, {'csrfmiddlewaretoken': csrfToken}, (data) => { + $('tr#link' + data.link).hide('medium'); + var ignored_count = parseInt($('#ignored_count').text()); + ignored_count--; + $('#ignored_count').text(ignored_count); + }); + return false; + }); + + $(".recheck").submit(function(){ + $(this).closest('tr').find('td.link_message').html('Checking'); + showProgressDots(1); + $.post(this.action, {'csrfmiddlewaretoken': csrfToken}, (data) => { + var links = data['links']; + for (var link in links) { + $('tr#link'+links[link]).find('td.link_message').text(data['message']).css('color', data['colour']); + } + }); + return false; + }); +}); diff --git a/linkcheck/templates/linkcheck/base_linkcheck.html b/linkcheck/templates/linkcheck/base_linkcheck.html index 03bdcd8..756fc4f 100644 --- a/linkcheck/templates/linkcheck/base_linkcheck.html +++ b/linkcheck/templates/linkcheck/base_linkcheck.html @@ -5,6 +5,11 @@ {% translate "Link Checker" %} {{ block.super }} {% endblock %} +{% block head %} + + +{% endblock %} + {% block breadcrumbs %}