Skip to content

Instantly share code, notes, and snippets.

@antonva
Created April 16, 2012 02:37
Show Gist options
  • Save antonva/2396094 to your computer and use it in GitHub Desktop.
Save antonva/2396094 to your computer and use it in GitHub Desktop.
function show_cost() {
$("div#laun").empty();
$db.view("Siggi/by_counter", {
success: function(data) {
for (i in data.rows) {
id = data.rows[i].id;
ssl = data.rows[i].key;
wage = 1000;
hours = data.rows[i].value;
hours = hours.toString().split(',');
hours = parseFloat(hours[1]);
counter = hours[0];
if (counter=="dv") {
cost = wage * hours
}
else if (counter=="ev") {
cost = wage * 171.5 * 0.008235 * hours
}
else {
cost = 0
};
html = '<div class="cost">' +
'<span class="ssl"><h1>' + ssl + '</h1></span> ' +
'<span class="counter"' + counter + '</span> ' +
'<span class="cost">' + cost + '</span>' +
'</div>';
$("div#laun").append(html);
}
},
error: function(status) {
console.log(status);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment