forgot navbar.js, work on board web ui refreshing and appearance

master
Kevin Froman 2019-07-17 00:10:39 -05:00
parent 837286a970
commit 1ced21f40c
10 changed files with 112 additions and 90 deletions

View File

@ -3,7 +3,7 @@ requested = []
var windowHeight = window.innerHeight;
webpassword = webpass
newPostForm = document.getElementById('addMsg')
firstLoad = true
function appendMessages(msg){
var humanDate = new Date(0)
if (msg.length == 0){
@ -18,9 +18,8 @@ function appendMessages(msg){
}
else{
humanDate.setUTCSeconds(msgDate)
msgDate = humanDate.toDateString() + ' ' + humanDate.toTimeString()
msgDate = humanDate.toDateString()
}
dateEl.textContent = msgDate
el.className = 'entry'
el.innerText = msg['content']
@ -31,16 +30,21 @@ function appendMessages(msg){
// Instantiate the table with the existing HTML tbody
// and the row with the template
var template = document.getElementById('cMsgTemplate');
var template = document.getElementById('cMsgTemplate')
// Clone the new row and insert it into the table
var feed = document.getElementById("feed");
var feed = document.getElementById("feed")
var clone = document.importNode(template.content, true);
var div = clone.querySelectorAll("div");
div[2].textContent = msg['content'];
div[3].textContent = msgDate;
var div = clone.querySelectorAll("div")
div[2].textContent = msg['content']
div[3].textContent = msgDate
feed.appendChild(clone);
if (firstLoad){
feed.appendChild(clone)
}
else{
feed.prepend(clone)
}
} else {
// Find another way to add the rows to the table because
@ -54,7 +58,7 @@ function getBlocks(){
}
var feedText = httpGet('/getblocksbytype/txt')
var blockList = feedText.split(',')
var blockList = feedText.split(',').reverse()
for (i = 0; i < blockList.length; i++){
if (! requested.includes(blockList[i])){
bl = httpGet('/getblockdata/' + blockList[i])
@ -62,16 +66,13 @@ function getBlocks(){
requested.push(blockList[i])
}
}
firstLoad = false
}
document.getElementById('refreshFeed').onclick = function(){
getBlocks()
}
window.onload = function() {
getBlocks();
}
newPostForm.onsubmit = function(){
var message = document.getElementById('newMsgText').value
var postData = {'message': message, 'type': 'txt', 'encrypt': false}

View File

@ -11,6 +11,10 @@
<link rel='shortcut icon' type='image/ico' href='/shared/images/favicon.ico'>
<link rel='stylesheet' href='/shared/main/bulma.min.css'>
<link rel="stylesheet" href="/shared/main/styles-new.css">
<link rel="stylesheet" href="theme.css">
<script defer src='/shared/navbar.js'></script>
<script defer src='/shared/misc.js'></script>
<script defer src='board.js'></script>
</head>
<body>
@ -66,10 +70,6 @@
</p>
</div>
</div>
<div class="field is-grouped is-grouped-centered">
<p class="control">
<a class="button is-link" id='refreshFeed'>Refresh Feed</a>
</p>
</div>
</div>
</div>
@ -86,6 +86,7 @@
<!--Add Friend-->
<div class="column is-one-third">
<div class="card">
<form method='POST' action='/' id='addMsg'>
<header class="card-header">
<p class="card-header-title">
Post message
@ -93,18 +94,16 @@
</header>
<div class="card-content">
<div class="content">
<form method='POST' action='/' id='addMsg'>
<textarea id='newMsgText' class="textarea" name='newMsgText' rows=10 cols=50 required
minlength="2"></textarea>
<input class='btn successBtn' value='Post' type='submit'>
</form>
</div>
</div>
<footer class="card-footer">
<a class="card-footer-item">
<button class='button' type='submit'>Post</button>
<input class='button' type='submit' value='Post'>
</a>
</footer>
</form>
</div>
</div>
<!--Feed-->
@ -116,6 +115,21 @@
</p>
</header>
<div class="card-content">
<div class="content">
<div class="field">
<div class="field has-addons">
<p class="control">
<a class="button is-static">Board Name</a>
</p>
<p class="control is-expanded">
<input id='feedIDInput' class="input" placeholder="Board name" value="global">
</p>
<p class="control">
<a class="button is-success" id='refreshFeed'>Refresh Feed</a>
</p>
</div>
</div>
</div>
<div class="content">
<div id='feed'>
<span id='none'>None Yet :)</span>
@ -130,21 +144,17 @@
<!--Template markup for Circle message-->
<template id="cMsgTemplate">
<div class="box" id="cMsgBox">
<div class="box cMsgBox">
<div class="columns">
<div class="column" id="cMsg">
<div class="column cMsg">
Message
</div>
<div class="column is-narrow" id="cMsgDate">
<div class="column is-narrow cMsgDate">
Date
</div>
</div>
</div>
</template>
<script src='/shared/misc.js'></script>
<script src='board.js'></script>
</body>
</html>

View File

@ -1,37 +1,5 @@
body{
background-color: white;
color: black;
}
.hidden{
display: none;
}
p{
font-family: sans-serif;
}
#webpassWindow{
background-color: black;
border: 1px solid black;
border-radius: 5px;
width: 100%;
z-index: 2;
color: white;
text-align: center;
}
.entry{
color: green;
}
#feed{
margin-left: 2%;
margin-right: 25%;
margin-top: 1em;
border: 2px solid black;
padding: 5px;
min-height: 50px;
}
.successBtn{
min-width: 100px;
.cMsg{
word-wrap:break-word;
word-break:break-word;
}

View File

@ -80,6 +80,7 @@
<div class='content'>
<ul class='conversationList'></ul>
</div>
<script src='/shared/navbar.js'></script>
<script src='/shared/misc.js'></script>
<script src='/clandestine/js/main.js'></script>
</body>

View File

@ -104,7 +104,6 @@
<input id="" class="input" type="text" name='data' placeholder='Name'>
</p>
</div>
<form>
</div>
</div>
<footer class="card-footer">
@ -151,7 +150,7 @@
</div>
</div>
</template>
<script src='/shared/navbar.js'></script>
<script src='/shared/misc.js'></script>
<script src='/friends/friends.js'></script>
</body>

View File

@ -77,7 +77,6 @@
</div>
</div>
</div>
</div>
</section>
<br>
@ -153,6 +152,7 @@
<div id="infoOverlay" class='overlay'>
</div>
<script src='/shared/navbar.js'></script>
<script src='/shared/misc.js'></script>
<script src='/mail/mail.js'></script>
<script src='/mail/sendmail.js'></script>

View File

@ -181,6 +181,7 @@
</div>
</div>
<br>
<script src='/shared/navbar.js'></script>
<script src='/shared/misc.js'></script>
<script src='/shared/main/stats.js'></script>
<script src='/shared/panel.js'></script>

View File

@ -13,8 +13,8 @@
<div class='content'>
<p></p>
</div>
<script src='/shared/navbar.js'></script>
<script src='/shared/misc.js'></script>
<script src='/profiles/profiles.js'></script>
</body>
</html>

View File

@ -0,0 +1,49 @@
document.addEventListener('DOMContentLoaded', () => {
// This function taken from the official bulma docs
/*
The MIT License (MIT)
Copyright (c) 2019 Jeremy Thomas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});

View File

@ -1,7 +0,0 @@
class Block {
constructor(hash, raw) {
this.hash = hash;
this.raw = raw;
}
}