got rid of stray JavaScript in results-page, still need to remove commented out test scripts

This commit is contained in:
Joost Agterhoek 2025-04-19 21:56:54 +02:00
parent 4613bb6d83
commit b7276c1b5e
3 changed files with 94 additions and 25 deletions

View File

@ -10,3 +10,15 @@ $(function() {
} }
}); });
}); });
$.each($('td'), function () {
if ($(this).html().startsWith("Score: 0")) {
$(this).css({"background-color": "green", "color": "white"});
}
else if ($(this).html().startsWith("Score: ")) {
$(this).css({"background-color": "red", "color": "white"});
}
});
console.log("CAN I SEE THIS?");

View File

@ -32,10 +32,13 @@
<script src="https://cdn.datatables.net/v/dt/dt-1.10.16/r-2.2.1/datatables.min.js"></script> <script src="https://cdn.datatables.net/v/dt/dt-1.10.16/r-2.2.1/datatables.min.js"></script>
<script type="text/javascript" charset="utf8" <script type="text/javascript" charset="utf8"
src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.js"></script> src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.js"></script>
<script type="text/javascript" href="/static/javascript.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!--<script type="text/javascript" src="static/javascript.js"></script> -->
<script type="text/javascript" src="{{ url_for('static', filename='javascript.js' )}}"></script>
{% block scripts %}{% endblock %}
{% block scripts %} {% endblock %}
</body> </body>
</html> </html>

View File

@ -1,5 +1,7 @@
<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="static/javascript.js"></script> <script src="static/javascript.js"></script>
-->
<div class="errors-container"> <div class="errors-container">
{% if error in errors %} {% if error in errors %}
@ -70,29 +72,81 @@
{% block scripts %} {% block scripts %}
<script> <script>
$(document).ready(function () { // var data = $('#data').DataTable().rows().data();
$('#data').DataTable({ // console.log("USING .data()", data)
paging: true, // data.each(function (value, index) {
searching: true, // console.log('data in index: ' + index + 'is: ' + value);
info: true, // });
columnDefs: [{ </script>
targets: '_all',
createdCell: function (td, cellData, rowData, row, col) { <script>
if (cellData == 'outlook.com' && col == 0) { // $(document).ready(function () {
$(td).css({'background-color': 'red', 'color': 'white'}); // $('#data').DataTable({
console.log(cellData); // paging: true,
} // searching: true,
if (cellData.startsWith('Score: 0') && col == 1) { // info: true,
console.log("TEST", cellData); // columnDefs: [{
$(td).css({'background-color': 'green', 'color': 'white'}); // targets: '_all',
} // createdCell: function (td, cellData, rowData, row, col) {
else if (!cellData.startsWith('Score: 0') && col == 1) { // if (cellData == 'outlook.com' && col == 0) {
$(td).css({'background-color': 'red', 'color': 'white'}); // $(td).css({'background-color': 'red', 'color': 'white'});
} // }
} //
}] // if (cellData.startsWith('Score: 0') && col == 1) {
}); // console.log("TEST", td, cellData);
}); // $(td).css({'background-color': 'green', 'color': 'white'});
// }
// else if (!cellData.startsWith('Score: 0') && col == 1) {
// $(td).css({'background-color': 'red', 'color': 'white'});
// console.log()
// }
// }
// }]
// });
// });
</script>
<script>
// if ($("td".startsWith("Score: 0"))) {
// ($("td").css("color", "red"));
// console.log("TESTING 2: ", ($("td")));
// }
</script>
<script>
// $("td").each(function () {
// $cell = $(this);
// if ($cell.text().startsWith("Score: 0")) {
// $cell.css({"background-color": "green", "color": "white"});
// }
// else if ($cell.text().startswith("Score: ")) {
// $cell.css({
// "background-color": "red", "color": "white"
// });
// }
//
// })
</script>
<script>
// $("td").each(function () {
// cell = $(this);
// // console.log($cell[0].firstChild.textContent);
// if (cell[0].firstChild.textContent.startsWith("Score: 0")) {
// cell.css({"background-color": "green", "color": "white"});
// }
// else if (cell[0].firstChild.textContent.startsWith("Score: ")) {
// cell.css({"background-color": "red", "color": "white"});
// }
// })
</script>
<script>
// $.each($('td'), function () {
// if ($(this).html().startsWith("Score: 0")) {
// $(this).css({"background-color": "green", "color": "white"});
// }
// else if ($(this).html().startsWith("Score: ")) {
// $(this).css({"background-color": "red", "color": "white"});
// }
// })
</script> </script>
{% endblock %} {% endblock %}