From 1ced21f40cca08167a7f610f1c47a584c5759bbf Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 17 Jul 2019 00:10:39 -0500 Subject: [PATCH] forgot navbar.js, work on board web ui refreshing and appearance --- onionr/static-data/www/board/board.js | 29 ++++---- onionr/static-data/www/board/index.html | 70 +++++++++++-------- onionr/static-data/www/board/theme.css | 38 +--------- onionr/static-data/www/clandestine/index.html | 1 + onionr/static-data/www/friends/index.html | 3 +- onionr/static-data/www/mail/index.html | 2 +- onionr/static-data/www/private/index.html | 1 + onionr/static-data/www/profiles/index.html | 2 +- onionr/static-data/www/shared/navbar.js | 49 +++++++++++++ onionr/static-data/www/shared/onionrblocks.js | 7 -- 10 files changed, 112 insertions(+), 90 deletions(-) create mode 100644 onionr/static-data/www/shared/navbar.js delete mode 100755 onionr/static-data/www/shared/onionrblocks.js diff --git a/onionr/static-data/www/board/board.js b/onionr/static-data/www/board/board.js index ad6c4faf..c4ead3c1 100755 --- a/onionr/static-data/www/board/board.js +++ b/onionr/static-data/www/board/board.js @@ -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} diff --git a/onionr/static-data/www/board/index.html b/onionr/static-data/www/board/index.html index 8b17dc53..4d718078 100755 --- a/onionr/static-data/www/board/index.html +++ b/onionr/static-data/www/board/index.html @@ -11,6 +11,10 @@ + + + + @@ -66,11 +70,7 @@

-
-

- Refresh Feed -

-
+ @@ -86,25 +86,24 @@
-
-

- Post message -

-
-
-
-
- - -
+
+
+

+ Post message +

+
+
+
+ +
-
- + +
@@ -116,6 +115,21 @@

+
+
+
+

+ Board Name +

+

+ +

+

+ Refresh Feed +

+
+
+
None Yet :) @@ -130,21 +144,17 @@ - - - - \ No newline at end of file diff --git a/onionr/static-data/www/board/theme.css b/onionr/static-data/www/board/theme.css index 1062e49b..2a9eeaff 100755 --- a/onionr/static-data/www/board/theme.css +++ b/onionr/static-data/www/board/theme.css @@ -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; } \ No newline at end of file diff --git a/onionr/static-data/www/clandestine/index.html b/onionr/static-data/www/clandestine/index.html index bd9f2d8e..cbed280a 100755 --- a/onionr/static-data/www/clandestine/index.html +++ b/onionr/static-data/www/clandestine/index.html @@ -80,6 +80,7 @@
    + diff --git a/onionr/static-data/www/friends/index.html b/onionr/static-data/www/friends/index.html index bcc3ac0a..0df4805a 100755 --- a/onionr/static-data/www/friends/index.html +++ b/onionr/static-data/www/friends/index.html @@ -104,7 +104,6 @@

    -
    @@ -151,7 +150,7 @@
    - + diff --git a/onionr/static-data/www/mail/index.html b/onionr/static-data/www/mail/index.html index 198f6f03..b02b27d1 100755 --- a/onionr/static-data/www/mail/index.html +++ b/onionr/static-data/www/mail/index.html @@ -77,7 +77,6 @@ -
    @@ -153,6 +152,7 @@
    + diff --git a/onionr/static-data/www/private/index.html b/onionr/static-data/www/private/index.html index add1c223..6b09f976 100755 --- a/onionr/static-data/www/private/index.html +++ b/onionr/static-data/www/private/index.html @@ -181,6 +181,7 @@
    + diff --git a/onionr/static-data/www/profiles/index.html b/onionr/static-data/www/profiles/index.html index 7134b943..c03c3eb4 100755 --- a/onionr/static-data/www/profiles/index.html +++ b/onionr/static-data/www/profiles/index.html @@ -13,8 +13,8 @@

    + - \ No newline at end of file diff --git a/onionr/static-data/www/shared/navbar.js b/onionr/static-data/www/shared/navbar.js new file mode 100644 index 00000000..0b281b38 --- /dev/null +++ b/onionr/static-data/www/shared/navbar.js @@ -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'); + + }); + }); + } + + }); \ No newline at end of file diff --git a/onionr/static-data/www/shared/onionrblocks.js b/onionr/static-data/www/shared/onionrblocks.js deleted file mode 100755 index 6be0210d..00000000 --- a/onionr/static-data/www/shared/onionrblocks.js +++ /dev/null @@ -1,7 +0,0 @@ -class Block { - constructor(hash, raw) { - this.hash = hash; - this.raw = raw; - } -} - \ No newline at end of file