}
+
+var CONTENT_LIST = []
+
+var ROOM_LIST = []
+
+var CONTENT_PAGE_PTR = 0
+var ROOM_PAGE_PTR = 0
+
+var PAGE_MAX = 5
+
+
async function getContentList(){
let resp = await fetch("/api/content/entry", {
}
+ CONTENT_LIST = JSON.parse(result.reply)
+
+ renderContentList()
+
+}
+
+
+
+async function getRoomList(){
+
+ let resp = await fetch("/api/peers/entry", {
+ method: "GET"
+ })
+
+ let result = await resp.json()
+
+ if(result.status != "success"){
+
+ alert("failed to get sample list")
+
+ return
+
+ }
+
+
+ ROOM_LIST = JSON.parse(result.reply)
+
+
+ renderRoomList()
+
+
+ }
+
+
+
+
+function renderContentList(){
+
let contentReader = document.getElementById("content-reader")
- let contentEntry = JSON.parse(result.reply)
+ let contentEntry = JSON.parse(JSON.stringify(CONTENT_LIST))
+
+ contentReader.innerHTML = ""
if (contentEntry.entry == null){
`
-
} else {
let sortedEntry = getNewDateSortedList("desc", "timestamp", contentEntry.entry)
+ let pageStart = CONTENT_PAGE_PTR * PAGE_MAX
+ let pageEnd = pageStart + PAGE_MAX
+
for(let i = 0; i < sortedEntry.length; i ++){
- contentReader.innerHTML += `
- <a class="tui-button" href="/content/${sortedEntry[i].type}/${sortedEntry[i].id}">
- ${sortedEntry[i].title}
- </a> [${sortedEntry[i].author}:${sortedEntry[i].timestamp}]
- <br>
- `
+ if(pageStart <= i && i < pageEnd){
+
+ contentReader.innerHTML += `
+ <div style="display: block;">
+ <a class="tui-button" href="/content/${sortedEntry[i].type}/${sortedEntry[i].id}">
+ ${sortedEntry[i].title}
+ </a> [${sortedEntry[i].author}:${sortedEntry[i].timestamp}]
+ </div>
+ <br>
+ `
+ } else {
+
+ contentReader.innerHTML += `
+ <div style="display: none;">
+ <a class="tui-button" href="/content/${sortedEntry[i].type}/${sortedEntry[i].id}">
+ ${sortedEntry[i].title}
+ </a> [${sortedEntry[i].author}:${sortedEntry[i].timestamp}]
+ </div>
+ <br>
+ `
+ }
}
}
-
-
}
+function renderRoomList(){
-async function getRoomList(){
- let resp = await fetch("/api/peers/entry", {
- method: "GET"
- })
-
- let result = await resp.json()
-
- if(result.status != "success"){
-
- alert("failed to get sample list")
-
- return
-
- }
-
-
- let roomReader = document.getElementById("room-reader")
-
- let roomEntry = JSON.parse(result.reply)
-
- if (roomEntry.room_name == null){
-
- roomReader.innerHTML = `
-
- <pre> :( You're not invited, yet </pre>
- `
+ let roomReader = document.getElementById("room-reader")
-
- } else {
-
- for(let i = 0; i < roomEntry.room_name.length; i ++){
-
- roomReader.innerHTML += `
+ let roomEntry = JSON.parse(JSON.stringify(ROOM_LIST))
+
+ roomReader.innerHTML = ""
+
+ if (roomEntry.room_name == null){
+
+ roomReader.innerHTML = `
+
+ <pre> :( You're not invited, yet </pre>
+
+ `
+
+
+ } else {
+
+ let pageStart = ROOM_PAGE_PTR * PAGE_MAX
+ let pageEnd = pageStart + PAGE_MAX
+
+ for(let i = 0; i < roomEntry.room_name.length; i ++){
+
+ if(pageStart <= i && i < pageEnd){
+ roomReader.innerHTML += `
+ <div style="display: block;">
<a class="tui-button" href="/room/${roomEntry.room_name[i]}">
${roomEntry.room_name[i]}
</a>
- <br>
- `
-
+ </div>
+ <br>
+ `
+
+ } else {
+
+ roomReader.innerHTML += `
+ <div style="display: none;">
+ <a class="tui-button" href="/room/${roomEntry.room_name[i]}">
+ ${roomEntry.room_name[i]}
+ </a>
+ </div>
+ <br>
+ `
}
- }
-
+
+ }
+
}
+}
+
+function contentNext(){
+
+
+ let contentLength = CONTENT_LIST.entry.length
+
+ let tmpPagePtr = (CONTENT_PAGE_PTR + 1) * PAGE_MAX
+
+ if(tmpPagePtr >= contentLength){
+
+ alert("goto: content: first page")
+
+ CONTENT_PAGE_PTR = 0
+
+ } else {
+
+ CONTENT_PAGE_PTR += 1
+ }
+
+ renderContentList()
+
+
+}
+
+function roomNext(){
+
+ let roomLength = ROOM_LIST.room_name.length
+
+ let tmpPagePtr = (ROOM_PAGE_PTR + 1) * PAGE_MAX
+
+ if(tmpPagePtr >= roomLength){
+
+ alert("goto: room: first page")
+
+ ROOM_PAGE_PTR = 0
+
+ } else {
+
+ ROOM_PAGE_PTR += 1
+
+ }
+
+ renderRoomList()
+
+}
+
+
(async function() {
await getContentList()
<html class="tui-bg-blue-black">
<head>
<title> feebdaed.xyz </title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/public/image/favicon.ico">
<link rel="stylesheet" href="/public/vendor/TuiCss/dist/tuicss.min.css"/>
<script src="/public/vendor/TuiCss/dist/tuicss.min.js"></script>
</div>
<div class="tui-panel-content">
Welcome to feebdaed.xyz, where worthlessness becomes the norm. <br>
- [Menu] at the top, [README] at the bottom!
+ To sign in, use [Menu] <br>
+ To find out more, check [README] at the bottom.
</div>
</div>
</div>
<fieldset class="tui-fieldset tui-border-dotted">
<div id="content-reader"></div>
</fieldset>
+ <button class="tui-button orange-168 white-text" onclick="contentNext()">next</button>
</fieldset>
</div>
</div>
+ </div>
+ <div class="row">
<div class="col s6 m6 l6">
<div class="tui-window tui-scroll-white">
<fieldset class="tui-fieldset tui-border-double">
<fieldset class="tui-fieldset tui-border-dotted">
<div id="room-reader"></div>
</fieldset>
+ <button class="tui-button orange-168 white-text" onclick="roomNext()">next</button>
</fieldset>
</div>
</div>