Skip to content

Commit

Permalink
Remove all the jQuery stuff in favor of some 2006 javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
johnholdun committed Mar 14, 2012
1 parent fea17a3 commit 4cf180b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
21 changes: 18 additions & 3 deletions public/tonight.js
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,18 @@
$(function() { (function(){
$('.timestamp').timezone(); var
}); offset = (new Date()).getTimezoneOffset() * -60000,
timestamps = document.getElementsByClassName("timestamp"),
i,
timestamp,
date,
label

for (i = 0; i < timestamps.length; i++) {
timestamp = timestamps[i]
date = new Date(parseInt(timestamp.attributes["data-unixtime"].value, 10) * 1000 + offset)
label = (date.getHours() > 12 ? date.getHours() - 12 : date.getHours())
label += ":" + date.getMinutes()
label += (date.getHours() >= 12 ? "PM" : "AM")
timestamp.innerHTML = label
}
})()
7 changes: 7 additions & 0 deletions public/tonight.min.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
(function(){var offset=(new Date()).getTimezoneOffset()*-60000,timestamps=document.getElementsByClassName("timestamp"),i,timestamp,date,label
for(i=0;i<timestamps.length;i++){timestamp=timestamps[i]
date=new Date(parseInt(timestamp.attributes["data-unixtime"].value,10)*1000+offset)
label=(date.getHours()>12?date.getHours()-12:date.getHours())
label+=":"+date.getMinutes()
label+=(date.getHours()>=12?"PM":"AM")
timestamp.innerHTML=label}})()
2 changes: 1 addition & 1 deletion views/index.haml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- @attending.each do |attendee| - @attending.each do |attendee|
%li{ :class => (@added_id == attendee.id ? 'added' : nil) } %li{ :class => (@added_id == attendee.id ? 'added' : nil) }
%span.name= html_escape attendee.name %span.name= html_escape attendee.name
%span.timestamp= attendee.timestamp.strftime('%I:%M%p').sub(/^0/, '') %span.timestamp{ :data => { :unixtime => attendee.timestamp.to_time.to_i }}= attendee.timestamp.strftime('%I:%M%p').sub(/^0/, '')
%form.delete{ :action => '/delete', :method => 'POST' } %form.delete{ :action => '/delete', :method => 'POST' }
%input{ :name => 'id', :value => attendee.id, :type => 'hidden' } %input{ :name => 'id', :value => attendee.id, :type => 'hidden' }
%button{ :title => "Delete #{ attendee.name }" } &times; %button{ :title => "Delete #{ attendee.name }" } &times;
Expand Down
13 changes: 10 additions & 3 deletions views/layout.haml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
%head %head
%title tonight.pm %title tonight.pm
%meta{ :name => 'viewport', :content => 'width=320, initial-scale=1, maximum-scale=1' } %meta{ :name => 'viewport', :content => 'width=320, initial-scale=1, maximum-scale=1' }
%link{ :rel => 'stylesheet', :href => 'tonight.css' } %link{ :rel => 'stylesheet', :href => '/tonight.css' }
%script{ :src => 'http://code.jquery.com/jquery-1.7.1.min.js' } - if false
%script{ :src => 'application.js' } %script{ :src => 'jquery.js' }
%script{ :src => 'date-en-US.js' }
%script{ :src => 'jquery.timezone.js' }
:javascript
$(function() {
$('.timestamp').timezone();
});


%body %body
= yield = yield
%script{ :src => '/tonight.min.js' }

0 comments on commit 4cf180b

Please sign in to comment.