Skip to content
Permalink
Browse files

show N/A delegators when not available

  • Loading branch information
BitDesert committed Aug 4, 2019
1 parent 8c47deb commit f9a46e9d921dd5e205a787f28d7dfffe3bc742b6
Showing with 31 additions and 1 deletion.
  1. +28 −0 static/js/index.js
  2. +3 −1 templates/index.hbs
@@ -35,6 +35,34 @@ init.push(function(){
return hours+':'+minutes+':'+seconds;
});

Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {

switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '!=':
return (v1 != v2) ? options.fn(this) : options.inverse(this);
case '!==':
return (v1 !== v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
});

axios.get('templates/index.hbs')
.then(function (response) {
template=Handlebars.compile(response.data);
@@ -78,7 +78,9 @@
<span class="float-left-truncate">Delegators</span>
<span class="float-right-truncate">
{{#if nodeNinja}}
{{formatNumber nodeNinja.delegators}}
{{#ifCond nodeNinja.delegators '>' 0}}
{{formatNumber nodeNinja.delegators}}
{{else}} N/A {{/ifCond}}
{{else}} N/A {{/if}}
</span>
</li>

0 comments on commit f9a46e9

Please sign in to comment.
You can’t perform that action at this time.