mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
31 lines
No EOL
1.1 KiB
JavaScript
31 lines
No EOL
1.1 KiB
JavaScript
import { escape, whenReady } from './dom';
|
|
import { DataTable, dumbFilterCallback } from './data_tables';
|
|
import { tagsToHtml } from "./utils";
|
|
import { globalSetup } from './main';
|
|
|
|
whenReady(() => {
|
|
globalSetup();
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const myParam = urlParams.get('q');
|
|
const apiUrl = /* myParam !== null ? '/api/ajax_pastes.php?q=' + myParam : */ '/api/ajax_pastes.php';
|
|
|
|
const table = new DataTable(document.getElementById('archive'), {
|
|
ajaxCallback: (resolve) => {
|
|
fetch(apiUrl)
|
|
.then(r => r.json())
|
|
.then(resolve);
|
|
},
|
|
rowCallback: (rowData) => {
|
|
return `<tr>
|
|
<td><a href="/${rowData.id}">${escape(rowData.title)}</a></td>
|
|
<td><a href="/user/${escape(rowData.author)}">${escape(rowData.author)}</a></td>
|
|
<td>${escape(rowData.updated_at)}</td>
|
|
<td>${tagsToHtml(rowData.tags)}</td>
|
|
</tr>`;
|
|
},
|
|
filterCallback: dumbFilterCallback,
|
|
preFilter: myParam
|
|
});
|
|
table.attach();
|
|
}); |