Improve Networks page
Better sorting, more clear fa icons
This commit is contained in:
1 parent
4c2e669fa2
commit
3b4103baf7
4 files changed
+35
-34
No files matched your search
@@ -1,7 +1,16 @@
|
||||
|
||||
var Networks = JSON.parse(document.getElementById('json-networks').textContent);
|
||||
|
||||
var Network_Sorting;
|
||||
function is_greater_than(a, b, attrs) {
|
||||
|
||||
for (const attr of attrs) {
|
||||
if (a[attr] === b[attr])
|
||||
continue;
|
||||
return a[attr] > b[attr];
|
||||
}
|
||||
|
||||
return false; // Objects are equal
|
||||
}
|
||||
|
||||
function swap_networks(index1, index2) {
|
||||
|
||||
@@ -15,22 +24,10 @@ function swap_networks(index1, index2) {
|
||||
table.rows[index2+1].innerHTML = temp_row;
|
||||
}
|
||||
|
||||
function invert_networks() {
|
||||
for (let i = 0; Networks.length > i * 2; i++)
|
||||
swap_networks(i, Networks.length-i-1);
|
||||
}
|
||||
|
||||
function sort_networks(field) {
|
||||
|
||||
console.log(field);
|
||||
|
||||
if (Network_Sorting == field)
|
||||
return invert_networks();
|
||||
function sort_networks(fields) {
|
||||
|
||||
for (let i = 0; i != Networks.length; i++)
|
||||
for (let j = i + 1; j != Networks.length; j++)
|
||||
if (Networks[j][field] > Networks[i][field])
|
||||
if (is_greater_than(Networks[j], Networks[i], fields))
|
||||
swap_networks(i, j);
|
||||
|
||||
Network_Sorting = field;
|
||||
};
|
||||
}
|
||||
@@ -344,3 +344,12 @@ td pre {
|
||||
#content .site-title {
|
||||
color: var(--color-font3);
|
||||
}
|
||||
|
||||
#content .default-network {
|
||||
color: var(--color-font3);
|
||||
}
|
||||
|
||||
#content .non-default-network {
|
||||
color: var(--color-font1);
|
||||
transform: scale(0.75);
|
||||
}
|
||||
@@ -11,9 +11,7 @@
|
||||
<script>
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded', function () {
|
||||
sort_networks("name");
|
||||
sort_networks("engine");
|
||||
sort_networks("default");
|
||||
sort_networks(['default', 'engine', 'name']);
|
||||
}, false
|
||||
);
|
||||
</script>
|
||||
@@ -25,21 +23,21 @@
|
||||
<table id="network-table" class="hoverable">
|
||||
|
||||
<tr class="table-header">
|
||||
<th class="cursor" onclick="sort_networks('default')"></th>
|
||||
<th class="cursor" onclick="sort_networks('engine')">Engine</th>
|
||||
<th class="cursor" onclick="sort_networks('author')">Author</th>
|
||||
<th class="cursor" onclick="sort_networks('name')">Name</th>
|
||||
<th class="cursor" onclick="sort_networks('sha256')")>Hash</th>
|
||||
<th class="cursor" onclick="sort_networks(['default'])"></th>
|
||||
<th class="cursor" onclick="sort_networks(['engine'])">Engine</th>
|
||||
<th class="cursor" onclick="sort_networks(['author'])">Author</th>
|
||||
<th class="cursor" onclick="sort_networks(['name'])">Name</th>
|
||||
<th class="cursor" onclick="sort_networks(['sha256'])")>Hash</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
{% for network in networks %}
|
||||
<tr>
|
||||
{% if network.default %}
|
||||
<td><i class="fas fa-star" aria-hidden="true"></i></td>
|
||||
<td><i class="fas fa-star default-network" aria-hidden="true"></i></td>
|
||||
{% else %}
|
||||
<td><a class="unstarred" href="/networks/{{network.engine}}/default/{{network.sha256}}">
|
||||
<i class="far fa-star" aria-hidden="true"></i></a></td>
|
||||
<td><a href="/networks/{{network.engine}}/default/{{network.sha256}}">
|
||||
<i class="far fa-star non-default-network" aria-hidden="true"></i></a></td>
|
||||
{% endif %}
|
||||
|
||||
<td><a href="/networks/{{network.engine}}/">{{network.engine}}</a></td>
|
||||
@@ -51,7 +49,7 @@
|
||||
<a class="redlink"
|
||||
onclick="return confirm('YOU ARE DELETING THIS NETWORK FILE FOREVER')"
|
||||
href="/networks/{{network.engine}}/delete/{{network.sha256}}">
|
||||
<i class="fas fa-minus-circle"></i></a>
|
||||
<i class="fa-solid fa-trash-can" style="color: #A00000;"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
{% for engine, repo in profile.repos.items %}
|
||||
<div class="row" id="engine-row-{{ engine }}">
|
||||
<label>{{ engine }}</label>
|
||||
<input type="text" name="engine-repo-{{ engine }}" value="{{ repo|removePrefix:'https://github.com/' }}">
|
||||
<input type="text" name="engine-repo-{{engine}}" value="{{ repo|removePrefix:'https://github.com/' }}">
|
||||
|
||||
<span>
|
||||
<input id="radio-{{engine}}" type="radio" name="default-status" value="{{ engine }}"
|
||||
<input id="radio-{{engine}}" type="radio" name="default-status" value="{{engine}}"
|
||||
{% if profile.engine == engine %}checked{% endif %}>
|
||||
</span>
|
||||
|
||||
<span onclick="deleteRow(event)">
|
||||
<i class="fa-solid fa-trash-can" style="color: #A00000;" data-engine="{{ engine }}" ></i>
|
||||
<i class="fa-solid fa-trash-can" style="color: #A00000;" data-engine="{{engine}}" ></i>
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -102,8 +102,6 @@
|
||||
return;
|
||||
|
||||
if (engine) {
|
||||
// Perform the delete action here
|
||||
console.log(`Deleting engine: ${engine}`);
|
||||
|
||||
// Remove the corresponding row from the DOM
|
||||
const row = button.parentNode.parentNode;
|
||||
@@ -115,7 +113,6 @@
|
||||
|
||||
deletedRepos.push(engine);
|
||||
deletedReposInput.value = JSON.stringify(deletedRepos);
|
||||
console.log(deletedRepos);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user