71 lines
2.5 KiB
HTML
71 lines
2.5 KiB
HTML
<div style="max-height: calc(50vh - 6em); overflow-y: scroll; margin: 0 0 1em 0; padding: 0 2ch 2ch 2ch;" id="rgWrapper">
|
|
<table id="regs" class="bordered selectable">
|
|
<colgroup>
|
|
<col style="width: 25ch;">
|
|
<col>
|
|
<col style="width: 20ch;">
|
|
<col style="width: 19ch;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th>Nomor/Judul</th>
|
|
<th>Abstrak</th>
|
|
<th>Diupload Oleh</th>
|
|
<th>Pada</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="empty">
|
|
<tr>
|
|
<td colspan="4" style="text-align: center;">Data Kosong</td>
|
|
</tr>
|
|
</tbody>
|
|
<tbody id="rgContent" hidden>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<a-button id="newReg">Entri Regulasi</a-button>
|
|
<script type="module">
|
|
let regulations = [];
|
|
async function getRegs()
|
|
{
|
|
regulations = [];
|
|
const regs = await getJson("/api/regs");
|
|
if (regs.status != 200) return;
|
|
regulations = regs.data;
|
|
µ('#empty').prop("hidden",!(regulations.length < 1));
|
|
µ('#rgContent').prop("hidden",(regulations.length < 1));
|
|
µ('#rgContent').empty();
|
|
$.each(regulations,(_,v)=>{
|
|
v.timeStamp = v.timeStamp.replace("T"," ")
|
|
const ro = moly.newElement("tr");
|
|
const jd = moly.newElement("td");
|
|
const ab = moly.newElement("td");
|
|
const ag = moly.newElement("td");
|
|
const ts = moly.newElement("td");
|
|
ro.append(jd);
|
|
ro.append(ab);
|
|
ro.append(ag);
|
|
ro.append(ts);
|
|
jd.append(v.judul);
|
|
ab.append(v.abstrak);
|
|
v.uploader = agents.find(a=>a.agentID == v.agentID).name;
|
|
ag.append(v.uploader);
|
|
ts.append(v.timeStamp);
|
|
$(ro).click(async()=>{
|
|
const rem = await moly.dialog.show({title: "Lihat Regulasi", content: "/modules/regulasi-view.html", fetching: true, data: v});
|
|
if (rem) getRegs();
|
|
});
|
|
µ('#rgContent').append(ro);
|
|
})
|
|
}
|
|
function µ(selector)
|
|
{
|
|
if (selector) return $('body>#main>#content').find(selector);
|
|
return $('body>#main>#content');
|
|
}
|
|
µ('#newReg').click(async()=>{
|
|
const rg = await moly.dialog.show({title: "Entri Dokumen Regulasi", content:"/modules/regulasi-new.html",fetching: true, data: regulations})
|
|
if(rg) getRegs();
|
|
});
|
|
getRegs();
|
|
</script> |