Skip to content

Instantly share code, notes, and snippets.

View dcolthorp's full-sized avatar

Drew Colthorp dcolthorp

View GitHub Profile
// Translate our messages into expand directives.
var messageDirectives = $.map(ajaxResult, formatMessage);
// Replace the dashboard placeholder with a newly cloned
// DOM node copied from #message-template and expanded
// with our messages.
$("#dashboard .placeholder").
replaceWith(
$("#messages-template").
expand(messageDirectives));
// Translate our messages into expand directives.
var messageDirectives = $.map(ajaxResult, formatMessage);
// Replace the dashboard placeholder with a newly cloned
// DOM node copied from #message-template and expanded
// with our messages.
$("#dashboard .placeholder").
replaceWith(
$("#messages-template").
expand(messageDirectives));
<div id="dashboard">
<ul class="messages">
<li class="status-good"><span class="text">John recieved your message.</span></li>
<li class="status-bad"><span class="text">Your password is about to expire</span></li>
</ul>
</div>
<div id="sidebar">
<div class="latest-message status-good">
<h2>Latest News</h2>
<script id="messages-template" type="text/html">
<ul class="messages">
<li><span class="text">&nbsp;</span></li>
</ul>
</script>
// Translate our messages into expand directives.
var messageDirectives = $.map(ajaxResult, formatMessage);
// Replace the dashboard placeholder with a newly cloned
// DOM node copied from #message-template and expanded
// with our messages.
$("#dashboard .placeholder").
replaceWith(
$("#messages-template").
expand(messageDirectives));
function formatMessage(m) {
return $.extend({ "addClass()": "status-"+m.value }, m);
}
var ajaxResult = [
{text: "John recieved your message.", value: "good"},
{text: "Your password is about to expire", value: "bad"},
]
<div id="dashboard">
<div class="placeholder">Loading data...</div>
</div>
<div id="sidebar">
<div class="latest-message">
<h2>Latest News</h2>
<p class="text">
Loading data...
</p>
var $body = $(document.body);
var loadDataSets = function () { $body.trigger("allDataSetsArrived"); };
if (EmployerGroupReporting.PredefinedDataSets) {
loadDataSets = _(EmployerGroupReporting.PredefinedDataSets).
reduceRight(function (rest, dataSet) {
return function () {
EmployerGroupReporting.DataSets[dataSet.Id] = dataSet;
require 'redis'
module MyRedis
class Type
def self.inherited(subklass)
subklass.const_set :ALIASES, {}
end
def initialize(db,key)