Skip to content

Commit

Permalink
Merge pull request #1 from MaximSukhochev/master
Browse files Browse the repository at this point in the history
Fixed code formatting
  • Loading branch information
123jjck authored Dec 11, 2023
2 parents 301e651 + c66c8f0 commit d63eb84
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions list.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ class InstantList {

this.init();
}

init() {
window.onhashchange = this.handleHashChange.bind(this);
this.handleHashChange();
}

goToPage(page = 1) {
if (page <= 0) page = 1;
let from = ((page - 1) * this.config.itemsPerPage) + 1;
Expand All @@ -90,6 +92,7 @@ class InstantList {
});
this.table.renderTable(this.items, page, from, to);
}

handleHashChange() {
if (!window.location.hash.includes('#search_')) {
this.table.titleHolder.innerHTML = "Вещи";
Expand All @@ -100,9 +103,11 @@ class InstantList {
let query = this.search.value = decodeURIComponent(window.location.hash.replace("#search_", ""));
this.table.renderSearchResults(query, this.items);
}

getItemType(goodTypeId) {
return goodTypeMap[goodTypeId] || goodTypeId;
}

buildItemsArray(t, g, mr, tr) {
// TODO tags
let items = [];
Expand Down Expand Up @@ -130,6 +135,7 @@ class Table {
this.domain = domain;
this.fsPath = fsPath;
}

renderTable(items, page, from, to) {
/* Table */
let html = '<table class="table table-striped table-borderless"><thead>';
Expand All @@ -155,6 +161,7 @@ class Table {
paginationHtml += '</ul></nav>';
this.pageHolder.innerHTML = paginationHtml;
}

renderItems(items, from, to) {
let html = '';
for (let i = from - 1; i < to; i++) {
Expand All @@ -164,6 +171,7 @@ class Table {
}
return html;
}

renderElement(item) {
let html = '<tr>';
html += `<td>${item['Id']}</td>`;
Expand All @@ -174,12 +182,15 @@ class Table {
html += `</tr>`;
return html;
}

normalizeString(str) {
return str.toLowerCase().replace(/ё/g, 'е').replace(/'/g, "").replace(/"/g, '').trim();
}

normalizeStringKeepQuotes(str) {
return str.toLowerCase().replace(/ё/g, 'е').trim();
}

renderSearchResults(query, items) {
let html = '<table class="table table-striped table-borderless"><thead>';

Expand Down

0 comments on commit d63eb84

Please sign in to comment.