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

This commit is contained in:
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; var windowHeight = window.innerHeight;
webpassword = webpass webpassword = webpass
newPostForm = document.getElementById('addMsg') newPostForm = document.getElementById('addMsg')
firstLoad = true
function appendMessages(msg){ function appendMessages(msg){
var humanDate = new Date(0) var humanDate = new Date(0)
if (msg.length == 0){ if (msg.length == 0){
@ -18,9 +18,8 @@ function appendMessages(msg){
} }
else{ else{
humanDate.setUTCSeconds(msgDate) humanDate.setUTCSeconds(msgDate)
msgDate = humanDate.toDateString() + ' ' + humanDate.toTimeString() msgDate = humanDate.toDateString()
} }
dateEl.textContent = msgDate
el.className = 'entry' el.className = 'entry'
el.innerText = msg['content'] el.innerText = msg['content']
@ -31,16 +30,21 @@ function appendMessages(msg){
// Instantiate the table with the existing HTML tbody // Instantiate the table with the existing HTML tbody
// and the row with the template // 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 // 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 clone = document.importNode(template.content, true);
var div = clone.querySelectorAll("div"); var div = clone.querySelectorAll("div")
div[2].textContent = msg['content']; div[2].textContent = msg['content']
div[3].textContent = msgDate; div[3].textContent = msgDate
feed.appendChild(clone); if (firstLoad){
feed.appendChild(clone)
}
else{
feed.prepend(clone)
}
} else { } else {
// Find another way to add the rows to the table because // Find another way to add the rows to the table because
@ -54,7 +58,7 @@ function getBlocks(){
} }
var feedText = httpGet('/getblocksbytype/txt') var feedText = httpGet('/getblocksbytype/txt')
var blockList = feedText.split(',') var blockList = feedText.split(',').reverse()
for (i = 0; i < blockList.length; i++){ for (i = 0; i < blockList.length; i++){
if (! requested.includes(blockList[i])){ if (! requested.includes(blockList[i])){
bl = httpGet('/getblockdata/' + blockList[i]) bl = httpGet('/getblockdata/' + blockList[i])
@ -62,16 +66,13 @@ function getBlocks(){
requested.push(blockList[i]) requested.push(blockList[i])
} }
} }
firstLoad = false
} }
document.getElementById('refreshFeed').onclick = function(){ document.getElementById('refreshFeed').onclick = function(){
getBlocks() getBlocks()
} }
window.onload = function() {
getBlocks();
}
newPostForm.onsubmit = function(){ newPostForm.onsubmit = function(){
var message = document.getElementById('newMsgText').value var message = document.getElementById('newMsgText').value
var postData = {'message': message, 'type': 'txt', 'encrypt': false} 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='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/bulma.min.css'>
<link rel="stylesheet" href="/shared/main/styles-new.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> </head>
<body> <body>
@ -66,11 +70,7 @@
</p> </p>
</div> </div>
</div> </div>
<div class="field is-grouped is-grouped-centered"> </div>
<p class="control">
<a class="button is-link" id='refreshFeed'>Refresh Feed</a>
</p>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -86,25 +86,24 @@
<!--Add Friend--> <!--Add Friend-->
<div class="column is-one-third"> <div class="column is-one-third">
<div class="card"> <div class="card">
<header class="card-header"> <form method='POST' action='/' id='addMsg'>
<p class="card-header-title"> <header class="card-header">
Post message <p class="card-header-title">
</p> Post message
</header> </p>
<div class="card-content"> </header>
<div class="content"> <div class="card-content">
<form method='POST' action='/' id='addMsg'> <div class="content">
<textarea id='newMsgText' class="textarea" name='newMsgText' rows=10 cols=50 required <textarea id='newMsgText' class="textarea" name='newMsgText' rows=10 cols=50 required
minlength="2"></textarea> minlength="2"></textarea>
<input class='btn successBtn' value='Post' type='submit'> </div>
</form>
</div> </div>
</div> <footer class="card-footer">
<footer class="card-footer"> <a class="card-footer-item">
<a class="card-footer-item"> <input class='button' type='submit' value='Post'>
<button class='button' type='submit'>Post</button> </a>
</a> </footer>
</footer> </form>
</div> </div>
</div> </div>
<!--Feed--> <!--Feed-->
@ -116,6 +115,21 @@
</p> </p>
</header> </header>
<div class="card-content"> <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 class="content">
<div id='feed'> <div id='feed'>
<span id='none'>None Yet :)</span> <span id='none'>None Yet :)</span>
@ -130,21 +144,17 @@
<!--Template markup for Circle message--> <!--Template markup for Circle message-->
<template id="cMsgTemplate"> <template id="cMsgTemplate">
<div class="box" id="cMsgBox"> <div class="box cMsgBox">
<div class="columns"> <div class="columns">
<div class="column" id="cMsg"> <div class="column cMsg">
Message Message
</div> </div>
<div class="column is-narrow" id="cMsgDate"> <div class="column is-narrow cMsgDate">
Date Date
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script src='/shared/misc.js'></script>
<script src='board.js'></script>
</body> </body>
</html> </html>

View File

@ -1,37 +1,5 @@
body{
background-color: white;
color: black;
}
.hidden{ .cMsg{
display: none; word-wrap:break-word;
} word-break:break-word;
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;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -13,8 +13,8 @@
<div class='content'> <div class='content'>
<p></p> <p></p>
</div> </div>
<script src='/shared/navbar.js'></script>
<script src='/shared/misc.js'></script> <script src='/shared/misc.js'></script>
<script src='/profiles/profiles.js'></script> <script src='/profiles/profiles.js'></script>
</body> </body>
</html> </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;
}
}