aboutsummaryrefslogtreecommitdiff
path: root/web/public
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-17 11:36:37 +0100
committerJochen Topf <jochen@topf.org>2013-01-17 11:36:37 +0100
commit5e05d84eef8b07958dbc9a0dfc8cbba10f8d3a4b (patch)
treebe924c3769ba4f57a3c34b97e394744075670c66 /web/public
parenta759c7680dfb41b366fb1bad8efc2a19c1ff82f6 (diff)
downloadtaginfo-5e05d84eef8b07958dbc9a0dfc8cbba10f8d3a4b.tar
taginfo-5e05d84eef8b07958dbc9a0dfc8cbba10f8d3a4b.tar.gz
Cleanup js function print_value_with_percent
Diffstat (limited to 'web/public')
-rw-r--r--web/public/js/taginfo.js20
1 files changed, 10 insertions, 10 deletions
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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
+}
+
function tag(element, text, attrs) {
var attributes = '';
if (attrs !== undefined) {
@@ -370,6 +374,12 @@ function fmt_checkmark(value) {
return value ? '&#x2714;' : '-';
}
+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(' &bull; ');
}
-function html_escape(text) {
- return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
-}
-
-function print_value_with_percent(value, fraction) {
- return '<div class="value">' + fmt_with_ts(value) +
- '</div><div class="fraction">' + fmt_as_percent(fraction) +
- '</div><div class="bar" style="width: ' + (fraction*100).toFixed() + 'px;"></div>';
-}
-
/* ============================ */
var flexigrid_defaults = {