board appearance and functionality work

This commit is contained in:
Kevin Froman 2019-04-16 12:04:51 -05:00
parent 9604849dbb
commit 705359d3a6
3 changed files with 46 additions and 21 deletions

View File

@ -2,22 +2,25 @@ requested = []
var windowHeight = window.innerHeight; var windowHeight = window.innerHeight;
webpassword = webpass webpassword = webpass
function httpGet(theUrl) { newPostForm = document.getElementById('addMsg')
var xmlHttp = new XMLHttpRequest()
xmlHttp.open( "GET", theUrl, false ) // false for synchronous request function appendMessages(msg){
xmlHttp.setRequestHeader('token', webpassword) var humanDate = new Date(0)
xmlHttp.send( null ) var msg = JSON.parse(msg)
if (xmlHttp.status == 200){ var dateEl = document.createElement('span')
return xmlHttp.responseText var el = document.createElement('div')
var msgDate = msg['meta']['time']
if (msgDate === undefined){
msgDate = 'unknown'
} }
else{ else{
return ""; humanDate.setUTCSeconds(msgDate)
msgDate = humanDate.toDateString() + ' ' + humanDate.toTimeString()
} }
} dateEl.textContent = msgDate
function appendMessages(msg){
el = document.createElement('div')
el.className = 'entry' el.className = 'entry'
el.innerText = msg el.innerText = msg['content']
document.getElementById('feed').appendChild(dateEl)
document.getElementById('feed').appendChild(el) document.getElementById('feed').appendChild(el)
document.getElementById('feed').appendChild(document.createElement('br')) document.getElementById('feed').appendChild(document.createElement('br'))
} }
@ -38,7 +41,10 @@ function getBlocks(){
} }
} }
document.getElementById('refreshFeed').onclick = function(){ document.getElementById('refreshFeed').onclick = function(){
getBlocks() getBlocks()
}
newPostForm.onsubmit = function(){
return false
} }

View File

@ -4,14 +4,27 @@
<meta charset='utf-8'> <meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'> <meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title> <title>
OnionrBoard Circle
</title> </title>
<link rel='stylesheet' href='/shared/style/modal.css'>
<link rel='stylesheet' href='/shared/main/style.css'>
<link rel='stylesheet' href='theme.css'> <link rel='stylesheet' href='theme.css'>
</head> </head>
<body> <body>
<h1>Circle</h1>
<input type='button' id='refreshFeed' value='Refresh Feed'> <p>
<div id='feed'><span id='none'>None Yet :)</span></div> Anonymous message board
</p>
<form method='POST' action='/' id='addMsg'>
<textarea name='newMsgText' rows=10 cols=50 required minlength="2"></textarea>
<br><br>
<input class='btn successBtn' value='Post' type='submit'>
</form>
<br><br>
<div id='feed'>
<input class='primaryBtn' type='button' id='refreshFeed' value='Refresh Feed'>
<br><br>
<span id='none'>None Yet :)</span></div>
<script src='/shared/misc.js'></script> <script src='/shared/misc.js'></script>
<script src='board.js'></script> <script src='board.js'></script>
</body> </body>

View File

@ -1,6 +1,8 @@
h1, h2, h3{ body{
font-family: sans-serif; background-color: white;
color: black;
} }
.hidden{ .hidden{
display: none; display: none;
} }
@ -18,7 +20,7 @@ p{
} }
.entry{ .entry{
color: red; color: green;
} }
#feed{ #feed{
@ -28,4 +30,8 @@ p{
border: 2px solid black; border: 2px solid black;
padding: 5px; padding: 5px;
min-height: 50px; min-height: 50px;
}
.successBtn{
min-width: 100px;
} }