diff --git a/onionr/static-data/www/board/board.js b/onionr/static-data/www/board/board.js index 7d70f9db..ad6c4faf 100755 --- a/onionr/static-data/www/board/board.js +++ b/onionr/static-data/www/board/board.js @@ -10,7 +10,7 @@ function appendMessages(msg){ return } var msg = JSON.parse(msg) - var dateEl = document.createElement('span') + var dateEl = document.createElement('div') var el = document.createElement('div') var msgDate = msg['meta']['time'] if (msgDate === undefined){ @@ -23,9 +23,29 @@ function appendMessages(msg){ dateEl.textContent = msgDate el.className = 'entry' el.innerText = msg['content'] - document.getElementById('feed').appendChild(dateEl) - document.getElementById('feed').appendChild(el) - document.getElementById('feed').appendChild(document.createElement('br')) + + /* Template Test */ + // Test to see if the browser supports the HTML template element by checking + // for the presence of the template element's content attribute. + if ('content' in document.createElement('template')) { + + // Instantiate the table with the existing HTML tbody + // and the row with the template + var template = document.getElementById('cMsgTemplate'); + + // Clone the new row and insert it into the table + 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; + + feed.appendChild(clone); + + } else { + // Find another way to add the rows to the table because + // the HTML template element is not supported. + } } function getBlocks(){ @@ -48,6 +68,10 @@ 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 37d22ea9..8101b55c 100755 --- a/onionr/static-data/www/board/index.html +++ b/onionr/static-data/www/board/index.html @@ -1,31 +1,151 @@ -
- - -- Anonymous message board -
- -+ Refresh Feed +
++ Post message +
++ Feed +
+