// ui test (just for fun)
// nunzio you can copy all of this if you want
// you can change this template function to use your data format (dont change the HTML)
function template_messages() {
var i, len, html = '';
for (i = 0, len = messages.length; i < len; i = i + 1) {
html +=
'<div class="message ' + (messages[i].from === 'you' ? 'you': 'them') + '">' +
'<div class="message_header">' + messages[i].from + '</div>' +
'<div class="message_content">' + messages[i].message + '</div>' +
'</div>';
}
return html;
}
// the from can be from anyone but if it is the conecting user then it needs to be: 'you'
var messages = [
{'from': 'you', 'message': 'hi'},
{'from': 'nunzio', 'message': 'hello'},
{'from': 'nunzio', 'message': 'whats up'},
{'from': 'you', 'message': 'not much you?'},
{'from': 'nunzio', 'message': 'same here'},
{'from': 'you', 'message': 'i have been testing some CSS'},
{'from': 'nunzio', 'message': 'cool for what?'},
{'from': 'you', 'message': 'a message website'},
{'from': 'you', 'message': 'its coming along nicely'},
{'from': 'nunzio', 'message': 'sweet'}
];
// append the templated HTML
$('#messages').append(template_messages());
// scroll to the bottom of the messages box
$('body').scrollTop($('body')[0].scrollHeight);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.