Skip to content

Commit 86f5769

Browse files
committed
Start UI refinement including replacing jQuery with JS
Reference: #798 Reference: #851 Reference: #813 Signed-off-by: John M. Horan <johnmhoran@gmail.com>
1 parent 0089933 commit 86f5769

11 files changed

Lines changed: 93 additions & 10948 deletions

vulnerabilities/templates/base.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
<link rel="stylesheet" href="{% static 'css/font-awesome.css' %}" />
1414
<link rel="stylesheet" href="{% static 'css/bulma-tooltip.css' %}" />
1515

16-
<script type="text/javascript" src="{% static 'js/jquery-3.6.0.js' %}"></script>
17-
1816
{% block extrahead %}{% endblock %}
1917
</head>
2018

2119
<body class="Site">
2220
<div class="container max-desktop-width is-fullheight">
2321
{% block content %}{% endblock %}
22+
<script src="{% static 'js/main.js' %}" crossorigin="anonymous"></script>
2423

2524
<div style="margin-top: 50px;"></div>
2625

vulnerabilities/templates/index.html

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<div class="panel-block">
5353
<!-- <div style="padding-bottom: 10px; width: 100%;"> -->
5454
<div class="pb-3 width-100-pct">
55-
<form action="{% url 'package_search' %}" method="get">
55+
<form action="{% url 'package_search' %}" method="get" name="pkg_form" onsubmit="return validatePkgForm()">
5656
{% load widget_tweaks %}
5757
<!-- <div class="field has-addons" style="margin: 10px 0px 0px 0px;"> -->
5858
<div class="field has-addons mt-3">
@@ -126,7 +126,7 @@
126126
<div class="panel-block">
127127
<!-- <div style="padding-bottom: 10px; width: 100%;"> -->
128128
<div class="pb-3 width-100-pct">
129-
<form action="{% url 'vulnerability_search' %}" method="get">
129+
<form action="{% url 'vulnerability_search' %}" method="get" name="vuln_form" onsubmit="return validateVulnForm()">
130130
{% load widget_tweaks %}
131131
<!-- <div class="field has-addons" style="margin: 10px 0px 0px 0px;"> -->
132132
<div class="field has-addons mt-3">
@@ -170,20 +170,19 @@
170170
});
171171
});
172172

173-
$(document).ready(function () {
174-
$('#submit_pkg').click(function () {
175-
if ($('#id_name').val().trim().length === 0) {
176-
return false;
177-
}
178-
})
179-
});
173+
function validatePkgForm() {
174+
var x = document.forms["pkg_form"]["name"].value;
175+
if (x.trim().length == "") {
176+
return false;
177+
}
178+
}
179+
180+
function validateVulnForm() {
181+
var x = document.forms["vuln_form"]["vuln_id"].value;
182+
if (x.trim().length == "") {
183+
return false;
184+
}
185+
}
180186

181-
$(document).ready(function () {
182-
$('#submit_vuln').click(function () {
183-
if ($('#id_vuln_id').val().trim().length === 0) {
184-
return false;
185-
}
186-
})
187-
});
188187
</script>
189188
{% endblock %}

vulnerabilities/templates/package_update.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</div>
3838
<div class="panel-block">
3939
<div style="padding-bottom: 10px; width: 100%;">
40-
<form action="{% url 'package_search' %}" method="get">
40+
<form action="{% url 'package_search' %}" method="get" name="pkg_form" onsubmit="return validatePkgForm()">
4141
{% load widget_tweaks %}
4242
<div class="field has-addons" style="margin: 10px 0px 0px 0px;">
4343
<div class="control">
@@ -229,25 +229,25 @@
229229
});
230230
});
231231

232-
$(document).ready(function () {
233-
$('#tabs li').on('click', function () {
234-
var tab = $(this).data('tab');
232+
// $(document).ready(function () {
233+
// $('#tabs li').on('click', function () {
234+
// var tab = $(this).data('tab');
235235

236-
$('#tabs li').removeClass('is-active');
237-
$(this).addClass('is-active');
236+
// $('#tabs li').removeClass('is-active');
237+
// $(this).addClass('is-active');
238238

239-
$('#tab-content div').removeClass('is-active');
240-
$('div[data-content="' + tab + '"]').addClass('is-active');
241-
});
242-
});
239+
// $('#tab-content div').removeClass('is-active');
240+
// $('div[data-content="' + tab + '"]').addClass('is-active');
241+
// });
242+
// });
243+
244+
function validatePkgForm() {
245+
var x = document.forms["pkg_form"]["name"].value;
246+
if (x.trim().length == "") {
247+
return false;
248+
}
249+
}
243250

244-
$(document).ready(function () {
245-
$('#submit_pkg').click(function () {
246-
if ($('#id_name').val().trim().length === 0) {
247-
return false;
248-
}
249-
})
250-
});
251251
</script>
252252

253253
{% endblock %}

vulnerabilities/templates/packages.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="panel-block">
4949
<!-- <div style="padding-bottom: 10px; width: 100%;"> -->
5050
<div class="pb-3 width-100-pct">
51-
<form action="{% url 'package_search' %}" method="get">
51+
<form action="{% url 'package_search' %}" method="get" name="pkg_form" onsubmit="return validatePkgForm()">
5252
{% load widget_tweaks %}
5353
<!-- <div class="field has-addons" style="margin: 10px 0px 0px 0px;"> -->
5454
<div class="field has-addons mt-3">
@@ -203,12 +203,12 @@
203203
});
204204
});
205205

206-
$(document).ready(function () {
207-
$('#submit_pkg').click(function () {
208-
if ($('#id_name').val().trim().length === 0) {
209-
return false;
210-
}
211-
})
212-
});
206+
function validatePkgForm() {
207+
var x = document.forms["pkg_form"]["name"].value;
208+
if (x.trim().length == "") {
209+
return false;
210+
}
211+
}
212+
213213
</script>
214214
{% endblock %}

vulnerabilities/templates/vulnerabilities.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</div>
4141
<div class="panel-block">
4242
<div style="padding-bottom: 10px; width: 100%;">
43-
<form action="{% url 'vulnerability_search' %}" method="get">
43+
<form action="{% url 'vulnerability_search' %}" method="get" name="vuln_form" onsubmit="return validateVulnForm()">
4444
{% load widget_tweaks %}
4545
<div class="field has-addons" style="margin: 10px 0px 0px 0px;">
4646
<div class="control" style="width: 100%;">
@@ -187,12 +187,12 @@
187187
});
188188
});
189189

190-
$(document).ready(function () {
191-
$('#submit_vuln').click(function () {
192-
if ($('#id_vuln_id').val().trim().length === 0) {
193-
return false;
194-
}
195-
})
196-
});
190+
function validateVulnForm() {
191+
var x = document.forms["vuln_form"]["vuln_id"].value;
192+
if (x.trim().length == "") {
193+
return false;
194+
}
195+
}
196+
197197
</script>
198198
{% endblock %}

vulnerabilities/templates/vulnerability.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</div>
4040
<div class="panel-block">
4141
<div style="padding-bottom: 10px; width: 100%;">
42-
<form action="{% url 'vulnerability_search' %}" method="get">
42+
<form action="{% url 'vulnerability_search' %}" method="get" name="vuln_form" onsubmit="return validateVulnForm()">
4343
{% load widget_tweaks %}
4444
<div class="field has-addons" style="margin: 10px 0px 0px 0px;">
4545
<div class="control" style="width: 100%;">
@@ -348,13 +348,13 @@
348348
});
349349
});
350350

351-
$(document).ready(function () {
352-
$('#submit_vuln').click(function () {
353-
if ($('#id_vuln_id').val().trim().length === 0) {
354-
return false;
355-
}
356-
})
357-
});
351+
function validateVulnForm() {
352+
var x = document.forms["vuln_form"]["vuln_id"].value;
353+
if (x.trim().length == "") {
354+
return false;
355+
}
356+
}
357+
358358
</script>
359359

360360
{% endblock %}

0 commit comments

Comments
 (0)