From 5e05d84eef8b07958dbc9a0dfc8cbba10f8d3a4b Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 17 Jan 2013 11:36:37 +0100 Subject: Cleanup js function print_value_with_percent --- web/public/js/taginfo.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'web/public') diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index 2fb8e5a..61fc206 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -211,6 +211,10 @@ function link_to_wiki(title, options) { /* ============================ */ +function html_escape(text) { + return String(text).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); +} + function tag(element, text, attrs) { var attributes = ''; if (attrs !== undefined) { @@ -370,6 +374,12 @@ function fmt_checkmark(value) { return value ? '✔' : '-'; } +function fmt_value_with_percent(value, fraction) { + return tag('div', fmt_with_ts(value), { 'class': 'value' }) + + tag('div', fmt_as_percent(fraction), { 'class': 'fraction' }) + + tag('div', '', { 'class': 'bar', style: style({ width: (fraction*100).toFixed() + 'px' }) }); +} + /* ============================ */ function print_key_or_tag_list(list) { @@ -392,16 +402,6 @@ function print_prevalent_value_list(key, list) { }).join(' • '); } -function html_escape(text) { - return String(text).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); -} - -function print_value_with_percent(value, fraction) { - return '
' + fmt_with_ts(value) + - '
' + fmt_as_percent(fraction) + - '
'; -} - /* ============================ */ var flexigrid_defaults = { -- cgit v1.2.3