webapp with user option and stuff

This commit is contained in:
dickreckard 2014-05-28 21:22:11 +02:00
parent 261621dd46
commit c750d062be

View File

@ -105,7 +105,7 @@ text-shadow: 1px 1px orange;
</div> </div>
<div id="fixedDiv"> <div id="fixedDiv">
<textarea id="name" rows="1" style="width:100%" placeholder="Your Name"></textarea> <textarea id="name" rows="1" style="width:100%" placeholder="Your Name (leave empty for anonymous)"></textarea>
<textarea id="message" rows="3" style="width:100%" placeholder="Your Message"></textarea> <textarea id="message" rows="3" style="width:100%" placeholder="Your Message"></textarea>
<button style="width:100%" id="send">Send</button> <button style="width:100%" id="send">Send</button>
</div> </div>
@ -124,7 +124,14 @@ text-shadow: 1px 1px orange;
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('name').value + '///' + document.getElementById('message').value + '\n'; if (document.getElementById('name').value == ""){
var namm= "anonymous";
}
else{
var namm= document.getElementById('name').value;
}
outStr += new Date().getTime() + ' ' + namm + '///' + document.getElementById('message').value + '\n';
localStorage.setItem( 'outbox', outStr ); localStorage.setItem( 'outbox', outStr );
updateOutboxView(); updateOutboxView();
checkOutbox(); checkOutbox();
@ -228,7 +235,7 @@ function updateInboxView() {
if ( localStorage.key(i).length === 0 || element === 'outbox' ) { if ( localStorage.key(i).length === 0 || element === 'outbox' ) {
continue; continue;
} }
localStorageArray[i] = { time:localStorage.key(i), content:elesplit[0] }; localStorageArray[i] = { time:localStorage.key(i), user:elesplit[0], message:elesplit[1] };
} }
} }
orderStorage = localStorageArray.sort(function(a,b) { return b.time - a.time } ); orderStorage = localStorageArray.sort(function(a,b) { return b.time - a.time } );
@ -241,8 +248,7 @@ function updateInboxView() {
var date = new Date(parseInt(orderStorage[i].time)); var date = new Date(parseInt(orderStorage[i].time));
// date.setHours(date.getHours() + 2); // date.setHours(date.getHours() + 2);
var datereadable = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear()+" "+date.getHours()+":"+date.getMinutes(); var datereadable = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear()+" "+date.getHours()+":"+date.getMinutes();
element=orderStorage[i].content.split('///'); contentString += '<li><b>' + datereadable + ' </b>' + ' <i>'+ orderStorage[i].user +'</i><br/> '+orderStorage[i].message+'</li>';
contentString += '<li><b>' + datereadable + ' </b>' + ' <i>'+ element[0] +'</i><br/> '+ element[1]+'</li>';
} }
document.getElementById( 'inbox' ).innerHTML = contentString; document.getElementById( 'inbox' ).innerHTML = contentString;
} }