Add pad sorting
This commit is contained in:
parent
15f4dad630
commit
426af0e4fc
@ -1,16 +1,21 @@
|
|||||||
function fileInputHanlder() {
|
function sortByTitle() {
|
||||||
console.log("WIN");
|
var sort_by_title = function (a, b) {
|
||||||
var file = document.getElementById("fileUpload").files[0];
|
let x = a.getElementsByClassName('card-title')[0];
|
||||||
if (file) {
|
let y = b.getElementsByClassName('card-title')[0];
|
||||||
var reader = new FileReader();
|
console.log(x);
|
||||||
reader.readAsText(file, "UTF-8");
|
return x.innerHTML.toLowerCase().localeCompare(y.innerHTML.toLowerCase());
|
||||||
reader.onload = function (evt) {
|
};
|
||||||
document.getElementById("fileUpload").innerHTML = evt.target.result;
|
|
||||||
console.log( evt.target.result);
|
var notes = document.getElementsByClassName("sortable");
|
||||||
document.getElementById("textArea").value = evt.target.result
|
var notesArr = [];
|
||||||
};
|
for (const node of notes) {
|
||||||
reader.onerror = function (evt) {
|
notesArr.push(node);
|
||||||
document.getElementById("fileUpload").innerHTML = "error reading file";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
console.log(notesArr);
|
||||||
|
notesArr.sort(sort_by_title);
|
||||||
|
console.log(notesArr);
|
||||||
|
let parent = document.getElementById('sortable-wrapper');
|
||||||
|
for (let elem of notesArr) {
|
||||||
|
parent.appendChild(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,9 +14,14 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<button class="btn btn-success" onclick="sortByTitle()">Sort By Title</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="sortable-wrapper" class="row">
|
||||||
{% for note in notes %}
|
{% for note in notes %}
|
||||||
{% if note[1] and note[2] %}
|
{% if note[1] and note[2] %}
|
||||||
<div class="col-12 col-sm-6 col-md-6 col-lg-4 col-xl-3 mb-2">
|
<div class="sortable col-12 col-sm-6 col-md-6 col-lg-4 col-xl-3 mb-2">
|
||||||
<a href="{{host}}/{{note[2]}}">
|
<a href="{{host}}/{{note[2]}}">
|
||||||
<div class="card" style="width: 18rem;">
|
<div class="card" style="width: 18rem;">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user