From 2075f941205193ce469397e5a13cc4f71486ea91 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 18 Feb 2012 13:21:15 +0000 Subject: [PATCH] format date --- static/js/pandora/infoView.padma.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/static/js/pandora/infoView.padma.js b/static/js/pandora/infoView.padma.js index 58b3c80a..b2408006 100644 --- a/static/js/pandora/infoView.padma.js +++ b/static/js/pandora/infoView.padma.js @@ -246,10 +246,8 @@ pandora.ui.infoView = function(data) { clickLink: pandora.clickLink, editable: key != 'duration', format: function(value) { - return key != 'duration' ? formatValue(listKeys.indexOf(key) >= 0 - ? value.split(', ') : value, key) - : value < 60 ? Math.round(value) + ' sec' - : Math.round(value / 60) + ' min'; + return formatValue(listKeys.indexOf(key) >= 0 + ? value.split(', ') : value, key); }, placeholder: formatLight('unknown'), tooltip: 'Doubleclick to edit', @@ -270,13 +268,7 @@ pandora.ui.infoView = function(data) { html = []; ['location', 'date', 'language', 'duration'].forEach(function(key) { if (data[key]) { - html.push( - formatKey(key) + ( - key != 'duration' ? formatValue(data[key], key) - : data[key] < 60 ? Math.round(data[key]) + ' sec' - : Math.round(data[key] / 60) + ' min' - ) - ); + html.push(formatKey(key) + formatValue(data[key], key)); } }); $('
').css(css).html(html.join('; ')).appendTo($center); @@ -555,6 +547,12 @@ pandora.ui.infoView = function(data) { } function formatValue(value, key) { + if(key == 'date') { + return value ? Ox.formatDate(value, + ['', '%Y', '%B, %Y', '%B %e, %Y'][value.split('-').length]) : ''; + } else if(key == 'duration') { + return value < 60 ? Math.round(value) + ' sec' : Math.round(value / 60) + ' min'; + } return (Ox.isArray(value) ? value : [value]).map(function(value) { return key ? '' + value + ''