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 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) {
|
function swap_networks(index1, index2) {
|
||||||
|
|
||||||
@@ -15,22 +24,10 @@ function swap_networks(index1, index2) {
|
|||||||
table.rows[index2+1].innerHTML = temp_row;
|
table.rows[index2+1].innerHTML = temp_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
function invert_networks() {
|
function sort_networks(fields) {
|
||||||
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();
|
|
||||||
|
|
||||||
for (let i = 0; i != Networks.length; i++)
|
for (let i = 0; i != Networks.length; i++)
|
||||||
for (let j = i + 1; j != Networks.length; j++)
|
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);
|
swap_networks(i, j);
|
||||||
|
}
|
||||||
Network_Sorting = field;
|
|
||||||
};
|
|
||||||
@@ -344,3 +344,12 @@ td pre {
|
|||||||
#content .site-title {
|
#content .site-title {
|
||||||
color: var(--color-font3);
|
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>
|
<script>
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
'DOMContentLoaded', function () {
|
'DOMContentLoaded', function () {
|
||||||
sort_networks("name");
|
sort_networks(['default', 'engine', 'name']);
|
||||||
sort_networks("engine");
|
|
||||||
sort_networks("default");
|
|
||||||
}, false
|
}, false
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
@@ -25,21 +23,21 @@
|
|||||||
<table id="network-table" class="hoverable">
|
<table id="network-table" class="hoverable">
|
||||||
|
|
||||||
<tr class="table-header">
|
<tr class="table-header">
|
||||||
<th class="cursor" onclick="sort_networks('default')"></th>
|
<th class="cursor" onclick="sort_networks(['default'])"></th>
|
||||||
<th class="cursor" onclick="sort_networks('engine')">Engine</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(['author'])">Author</th>
|
||||||
<th class="cursor" onclick="sort_networks('name')">Name</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(['sha256'])")>Hash</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for network in networks %}
|
{% for network in networks %}
|
||||||
<tr>
|
<tr>
|
||||||
{% if network.default %}
|
{% 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 %}
|
{% else %}
|
||||||
<td><a class="unstarred" href="/networks/{{network.engine}}/default/{{network.sha256}}">
|
<td><a href="/networks/{{network.engine}}/default/{{network.sha256}}">
|
||||||
<i class="far fa-star" aria-hidden="true"></i></a></td>
|
<i class="far fa-star non-default-network" aria-hidden="true"></i></a></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<td><a href="/networks/{{network.engine}}/">{{network.engine}}</a></td>
|
<td><a href="/networks/{{network.engine}}/">{{network.engine}}</a></td>
|
||||||
@@ -51,7 +49,7 @@
|
|||||||
<a class="redlink"
|
<a class="redlink"
|
||||||
onclick="return confirm('YOU ARE DELETING THIS NETWORK FILE FOREVER')"
|
onclick="return confirm('YOU ARE DELETING THIS NETWORK FILE FOREVER')"
|
||||||
href="/networks/{{network.engine}}/delete/{{network.sha256}}">
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -38,15 +38,15 @@
|
|||||||
{% for engine, repo in profile.repos.items %}
|
{% for engine, repo in profile.repos.items %}
|
||||||
<div class="row" id="engine-row-{{ engine }}">
|
<div class="row" id="engine-row-{{ engine }}">
|
||||||
<label>{{ engine }}</label>
|
<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>
|
<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 %}>
|
{% if profile.engine == engine %}checked{% endif %}>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span onclick="deleteRow(event)">
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -102,8 +102,6 @@
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (engine) {
|
if (engine) {
|
||||||
// Perform the delete action here
|
|
||||||
console.log(`Deleting engine: ${engine}`);
|
|
||||||
|
|
||||||
// Remove the corresponding row from the DOM
|
// Remove the corresponding row from the DOM
|
||||||
const row = button.parentNode.parentNode;
|
const row = button.parentNode.parentNode;
|
||||||
@@ -115,7 +113,6 @@
|
|||||||
|
|
||||||
deletedRepos.push(engine);
|
deletedRepos.push(engine);
|
||||||
deletedReposInput.value = JSON.stringify(deletedRepos);
|
deletedReposInput.value = JSON.stringify(deletedRepos);
|
||||||
console.log(deletedRepos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in new issue
Block a user