Skip to content

Instantly share code, notes, and snippets.

@remixz
Created July 6, 2013 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remixz/5941710 to your computer and use it in GitHub Desktop.
Save remixz/5941710 to your computer and use it in GitHub Desktop.
{
"picroma": true,
"accounts": false,
"shop": false
}
// assume res is the response above from the server
for (var key in res) {
var $text - $('.status-' + key); // in your HTML, wrap each of the status texts with an element with the class status-[name]. example: your picroma status text would be .status-picroma
var status = res[key];
$text.removeClass(); // removes all classes
switch (status) {
case true:
$text.addClass('up'); // green text styling
$text.text('up.');
break;
case false:
$text.addClass('down'); // red text styling
$text.text('down.');
break;
};
};
// after the stuff you need to do individually, continue doing group check things, like notifications, titles, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment