2021-11-23 03:17:29 -05:00
|
|
|
import { escape, whenReady } from './dom';
|
2022-03-12 13:56:32 -05:00
|
|
|
import { DataTable, dumbFilterCallback } from './data_tables';
|
2022-03-26 23:48:19 -04:00
|
|
|
import { tagsToHtml } from "./utils";
|
2021-11-23 03:17:29 -05:00
|
|
|
import { globalSetup } from './main';
|
2021-09-03 08:00:22 -04:00
|
|
|
|
2021-11-23 03:17:29 -05:00
|
|
|
whenReady(() => {
|
|
|
|
globalSetup();
|
|
|
|
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
|
const myParam = urlParams.get('q');
|
2022-01-06 07:58:29 -05:00
|
|
|
const apiUrl = /* myParam !== null ? '/api/ajax_pastes.php?q=' + myParam : */ '/api/ajax_pastes.php';
|
2021-11-23 03:17:29 -05:00
|
|
|
|
|
|
|
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>
|
2023-05-25 09:31:14 -04:00
|
|
|
<td>${escape(rowData.updated_at)}</td>
|
2022-03-26 23:48:19 -04:00
|
|
|
<td>${tagsToHtml(rowData.tags)}</td>
|
2021-11-23 03:17:29 -05:00
|
|
|
</tr>`;
|
2022-01-06 07:58:29 -05:00
|
|
|
},
|
2022-03-12 13:56:32 -05:00
|
|
|
filterCallback: dumbFilterCallback,
|
2022-01-06 07:58:29 -05:00
|
|
|
preFilter: myParam
|
2021-11-23 03:17:29 -05:00
|
|
|
});
|
|
|
|
table.attach();
|
|
|
|
});
|