Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove all the jQuery stuff in favor of some 2006 javascript

  • Loading branch information...
commit 4cf180b014390a22ea08370a8fa3cf8ab2e82809 1 parent fea17a3
@johnholdun johnholdun authored
View
21 public/tonight.js
@@ -1,3 +1,18 @@
-$(function() {
- $('.timestamp').timezone();
-});
+(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
+ }
+})()
View
7 public/tonight.min.js
@@ -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}})()
View
2  views/index.haml
@@ -14,7 +14,7 @@
- @attending.each do |attendee|
%li{ :class => (@added_id == attendee.id ? 'added' : nil) }
%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' }
%input{ :name => 'id', :value => attendee.id, :type => 'hidden' }
%button{ :title => "Delete #{ attendee.name }" } &times;
View
13 views/layout.haml
@@ -2,9 +2,16 @@
%head
%title tonight.pm
%meta{ :name => 'viewport', :content => 'width=320, initial-scale=1, maximum-scale=1' }
- %link{ :rel => 'stylesheet', :href => 'tonight.css' }
- %script{ :src => 'http://code.jquery.com/jquery-1.7.1.min.js' }
- %script{ :src => 'application.js' }
+ %link{ :rel => 'stylesheet', :href => '/tonight.css' }
+ - if false
+ %script{ :src => 'jquery.js' }
+ %script{ :src => 'date-en-US.js' }
+ %script{ :src => 'jquery.timezone.js' }
+ :javascript
+ $(function() {
+ $('.timestamp').timezone();
+ });
%body
= yield
+ %script{ :src => '/tonight.min.js' }
Please sign in to comment.
Something went wrong with that request. Please try again.