This commit is contained in:
dickreckard 2014-05-28 20:48:08 +02:00
parent fdc3d06675
commit 722aa2a8d0

View File

@ -27,7 +27,7 @@
document.getElementById( 'send' ).onclick = function() { document.getElementById( 'send' ).onclick = function() {
var outStr = localStorage.getItem( 'outbox' ) || ''; var outStr = localStorage.getItem( 'outbox' ) || '';
outStr += new Date().getTime() + ' ' + document.getElementById('message').value + '\n'; outStr += new Date().getTime() + ' ' + document.getElementById('name').value + '///' + document.getElementById('message').value + '\n';
localStorage.setItem( 'outbox', outStr ); localStorage.setItem( 'outbox', outStr );
updateOutboxView(); updateOutboxView();
checkOutbox(); checkOutbox();
@ -113,14 +113,39 @@ function doStuffForEach( entriesString, stuffFunction ) {
/* /*
* INBOX STUFF * INBOX STUFF
*/ */
function updateInboxView() { function updateInboxView() {
var localStorageArray = new Array();
var contentString = ''; var contentString = '';
for(var i in localStorage)
if (localStorage.length>0) {
for (i=0;i<localStorage.length;i++){
element=localStorage.getItem(localStorage.key(i))
elesplit=element.split('///');
if ( localStorage.key(i).length === 0 || element === 'outbox' ) {
continue;
}
localStorageArray[i] = { time:localStorage.key(i), content:elesplit[0] };
}
}
orderStorage = localStorageArray.sort(function(a,b) { return b.time - a.time } );
for(var i in orderStorage)
{ {
if ( i.length === 0 || i === 'outbox' ) { if ( i.length === 0 || i === 'outbox' ) {
continue; continue;
} }
contentString += '<li><b>' + i + ' </b>' + localStorage[i] + '</li>'; var date = new Date(parseInt(orderStorage[i].time));
// date.setHours(date.getHours() + 2);
var datereadable = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear()+" "+date.getHours()+":"+date.getMinutes();
element=orderStorage[i].content.split('///');
contentString += '<li><b>' + datereadable + ' </b>' + ' <i>'+ element[0] +'</i><br/> '+ element[1]+'</li>';
} }
document.getElementById( 'inbox' ).innerHTML = contentString; document.getElementById( 'inbox' ).innerHTML = contentString;
} }