Skip to content

Commit

Permalink
cDlm's JS date patch. Fixes validation. (closes #247)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.typosphere.org/typo/trunk@477 820eb932-12ee-0310-9ca8-eeb645f39767
  • Loading branch information
scott committed Jul 31, 2005
1 parent 9353fea commit 3a21935
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -117,7 +117,7 @@ def check_cache(aggregator, url)

def js_distance_of_time_in_words_to_now(date)
time = date.utc.strftime("%a, %d %b %Y %H:%M:%S GMT")
%{<script type="text/javascript">document.write(get_local_time_for_date("#{time}"));</script><noscript>on #{time}</noscript>}
"<span class=\"typo_date\" title=\"#{time}\">#{time}</span>"
end

def render_sidebar(sidebar)
Expand Down
9 changes: 9 additions & 0 deletions public/javascripts/typo.js
Expand Up @@ -4,6 +4,15 @@ function register_onload(func) {
else { window.onload = function() { old_event(); func(); }; }
}

function show_dates_as_local_time() {
var spans = document.getElementsByTagName('span');
for (var i=0; i<spans.length; i++) {
if (spans[i].className.match(/\btypo_date\b/i)) {
spans[i].innerHTML = get_local_time_for_date(spans[i].title);
}
}
}

function get_local_time_for_date(time) {
system_date = new Date(time);
user_date = new Date();
Expand Down
3 changes: 2 additions & 1 deletion themes/azure/layouts/default.rhtml
Expand Up @@ -27,7 +27,8 @@

<div id="content" class="clearfix">
<div id="main">
<%= @content_for_layout %>
<%= @content_for_layout %>
<%= javascript_tag "show_dates_as_local_time()" %>
</div>
<div id="sidebar">

Expand Down

0 comments on commit 3a21935

Please sign in to comment.