realtime updates of "6 minutes ago" with fallback to iso8601 timestamps (available on tooltip)

This commit is contained in:
friendica 2012-07-23 04:11:59 -07:00
parent 33ea8737b7
commit 3decf67e6d
8 changed files with 85 additions and 8 deletions

View File

@ -473,7 +473,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'title' => template_escape($item['title']),
'body' => template_escape($body),
'text' => strip_tags(template_escape($body)),
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'ago' => relative_date($item['created']),
'app' => $item['app'],
'str_app' => sprintf( t(' from %s'), $item['app']),
'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'),
'location' => template_escape($location),
'indent' => '',
'owner_name' => template_escape($owner_name),
@ -832,7 +835,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'osparkle' => $osparkle,
'sparkle' => $sparkle,
'title' => template_escape($item['title']),
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'ago' => datetime_convert('UTC',date_default_timezone_get(),$item['created'],'r'), // relative_date($item['created']),
'app' => $item['app'],
'str_app' => sprintf( t(' from %s'), $item['app']),
'localtime' => datetime_convert('UTC', 'UTC', $item['created'], 'c'),
'lock' => $lock,
'location' => template_escape($location),
'indent' => $indent,

View File

@ -390,7 +390,29 @@ if(! file_exists($module_css))
'$page_css' => $a->get_baseurl() . '/' . $page_css,
'$module_css' => (($module_css) ? $a->get_baseurl() . '/' . $module_css : null),
'$stylesheet' => current_theme_url(),
'$theme' => current_theme()
'$theme' => current_theme(),
// localisations for jquery.timeago.js, see https://github.com/rmm5t/jquery-timeago
// TRANSLATORS - only translate the conditionals if you require them!
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : 'null'),
'$t02' => ((t('timeago.suffixAgo') != 'timeago.suffixAgo') ? t('timeago.suffixAgo') : 'null'),
'$t03' => t('ago'),
'$t04' => t('from now'),
'$t05' => t('less than a minute'),
'$t06' => t('about a minute'),
'$t07' => t('%d minutes'),
'$t08' => t('about an hour'),
'$t09' => t('about %d hours'),
'$t10' => t('a day'),
'$t11' => t('%d days'),
'$t12' => t('about a month'),
'$t13' => t('%d months'),
'$t14' => t('about a year'),
'$t15' => t('%d years'),
'$t16' => t(' '), // wordSeparator
'$t17' => ((t('timeago.numbers') != 'timeago.numbers') ? t('timeago.numbers') : '[]')
));
$page = $a->page;

View File

@ -686,3 +686,31 @@ function previewTheme(elm) {
});
};
})(jQuery);
$(document).ready(function() {
jQuery.timeago.settings.strings = {
prefixAgo: t01,
prefixFromNow: t02,
suffixAgo: t03,
suffixFromNow: t04,
seconds: t05,
minute: t06,
minutes: t07,
hour: t08,
hours: t09,
day: t10,
days: t11,
month: t12,
months: t13,
year: t14,
years: t15,
wordSeparator: t16,
numbers: t17
};
$("abbr.wall-item-ago-time").timeago();
});

View File

@ -121,7 +121,7 @@
function refresh() {
var data = prepareData(this);
if (!isNaN(data.datetime)) {
$(this).text(inWords(data.atetime));
$(this).text(inWords(data.datetime));
}
return this;
}

View File

@ -26,6 +26,7 @@
<script type="text/javascript" src="$baseurl/js/jquery.textinputs.js" ></script>
<script type="text/javascript" src="$baseurl/js/fk.autocomplete.js" ></script>
<script type="text/javascript" src="$baseurl/library/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="$baseurl/library/jquery.timeago.js"></script>
<script type="text/javascript" src="$baseurl/library/tiptip/jquery.tipTip.minified.js"></script>
<script type="text/javascript" src="$baseurl/library/jgrowl/jquery.jgrowl_minimized.js"></script>
<script type="text/javascript" src="$baseurl/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js" ></script>
@ -104,6 +105,25 @@
}
}
// jquery.timeago localisations
var t01 = $t01 ;
var t02 = $t02 ;
var t03 = "$t03" ;
var t04 = "$t04" ;
var t05 = "$t05" ;
var t06 = "$t06" ;
var t07 = "$t07" ;
var t08 = "$t08" ;
var t09 = "$t09" ;
var t10 = "$t10" ;
var t11 = "$t11" ;
var t12 = "$t12" ;
var t13 = "$t13" ;
var t14 = "$t14" ;
var t15 = "$t15" ;
var t16 = "$t16" ;
var t17 = $t17 ;
</script>

View File

@ -23,7 +23,8 @@
</div>
<div class="wall-item-author">
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle" id="wall-item-name-$item.id" >$item.name</span></a>
<div class="wall-item-ago" id="wall-item-ago-$item.id">$item.ago</div>
<div id="wall-item-ago-$item.id" class="wall-item-ago"><abbr class="wall-item-ago-time" title="$item.localtime">$item.ago</abbr>{{ if $item.app }}<span class="item.app">$item.str_app</span>{{ endif }}</div>
</div>
<div class="wall-item-content" id="wall-item-content-$item.id" >

View File

@ -24,7 +24,7 @@
</div>
<div class="wall-item-author">
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle" id="wall-item-name-$item.id" >$item.name</span></a>
<div class="wall-item-ago" id="wall-item-ago-$item.id">$item.ago</div>
<div id="wall-item-ago-$item.id" class="wall-item-ago"><abbr class="wall-item-ago-time" title="$item.localtime">$item.ago</abbr>{{ if $item.app }}<span class="item.app">$item.str_app</span>{{ endif }}</div>
</div>
<div class="wall-item-content" id="wall-item-content-$item.id" >

View File

@ -29,7 +29,7 @@
</div>
<div class="wall-item-author">
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle" id="wall-item-name-$item.id" >$item.name</span></a> $item.to <a href="$item.owner_url" target="redir" title="$item.olinktitle" class="wall-item-name-link"><span class="wall-item-name$item.osparkle" id="wall-item-ownername-$item.id">$item.owner_name</span></a> $item.vwall<br />
<div class="wall-item-ago" id="wall-item-ago-$item.id">$item.ago</div>
<div id="wall-item-ago-$item.id" class="wall-item-ago"><abbr class="wall-item-ago-time" title="$item.localtime">$item.ago</abbr>{{ if $item.app }}<span class="item.app">$item.str_app</span>{{ endif }}</div>
</div>
<div class="wall-item-content" id="wall-item-content-$item.id" >
<div class="wall-item-title" id="wall-item-title-$item.id">$item.title</div>