Skip to content

Commit

Permalink
beginnings of widget. currently propietary for bsg, needs independent…
Browse files Browse the repository at this point in the history
… style
  • Loading branch information
seaofclouds committed Jan 21, 2009
1 parent 71a3c15 commit 9ffad4c
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 26 deletions.
8 changes: 8 additions & 0 deletions islostonyet.rb
Expand Up @@ -42,6 +42,13 @@ def render_sass(content, options = {})
haml :index
end

get '/widget' do
haml :widget, :layout => :widget
end
get '/widget.js' do
haml :widget_js, :layout => false
end

get '/updates.atom' do
@posts = IsLOSTOnYet::Post.find_replies
@users = users_for @posts
Expand Down Expand Up @@ -72,6 +79,7 @@ def render_sass(content, options = {})
end
end


get '/s*e*' do
@episode = IsLOSTOnYet.episode(:"s#{params[:splat][0]}e#{params[:splat][1]}")
@tags = IsLOSTOnYet::Tag.list
Expand Down
46 changes: 20 additions & 26 deletions views/header.haml
Expand Up @@ -11,29 +11,23 @@
#countdown
%script{:type=>"text/javascript"}
:plain
var countdown_d = new Date();
var countdown_timenow = countdown_d.getTime();
var countdown_targetdate = Date.parse("#{@is_lost_on.next_episode.local_air_date.strftime('%Y/%m/%d %H:%M')}")
var countdown_timeleft = Math.floor((countdown_targetdate-countdown_timenow)/1000);
function countdown(remain,messages) {
var
status = document.getElementById("answer"),
countdown = document.getElementById("countdown"),
timer = setInterval( function () {
var day = (Math.floor(remain/86400))%86400;
var hour = (Math.floor(remain/3600))%24;
var minute = (Math.floor(remain/60))%60;
var second = (Math.floor(remain/1))%60;
countdown.innerHTML = (day > 0 ? "<span class='countdown_day'><strong>"+day+"</strong>d</span> " : "") + (hour > 0 ? "<span class='countdown_hour'><strong>"+hour+"</strong>h</span> " : "") + (minute > 0 ? "<span class='countdown_minute'><strong>"+minute+"</strong>m</span> " : "") + (second > 0 ? "<span class='countdown_second'><strong>"+second+"</strong>s</span> " : "")
if (--remain < 0 ) {
clearInterval(timer);
}
},1000);
}
countdown(countdown_timeleft,
{
86400: "it will be time for lost tomorrow.",
10: "it will be time for lost in ten seconds",
0: "it is time for lost"
}
);
var countdown_d = new Date();
var countdown_timenow = countdown_d.getTime();
var countdown_targetdate = Date.parse("#{@is_lost_on.next_episode.local_air_date.strftime('%Y/%m/%d %H:%M')}")
var countdown_timeleft = Math.floor((countdown_targetdate-countdown_timenow)/1000);
function countdown(remain) {
var
status = document.getElementById("answer"),
countdown = document.getElementById("countdown"),
timer = setInterval( function () {
var day = (Math.floor(remain/86400))%86400;
var hour = (Math.floor(remain/3600))%24;
var minute = (Math.floor(remain/60))%60;
var second = (Math.floor(remain/1))%60;
countdown.innerHTML = (day > 0 ? "<span class='countdown_day'><strong>"+day+"</strong>d</span> " : "") + (hour > 0 ? "<span class='countdown_hour'><strong>"+hour+"</strong>h</span> " : "") + (minute > 0 ? "<span class='countdown_minute'><strong>"+minute+"</strong>m</span> " : "") + (second > 0 ? "<span class='countdown_second'><strong>"+second+"</strong>s</span> " : "")
if (--remain < 0 ) {
clearInterval(timer);
}
},1000);
}
countdown(countdown_timeleft);
107 changes: 107 additions & 0 deletions views/widget.haml
@@ -0,0 +1,107 @@
:plain
<!--
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMOIZMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMZ=7DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM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MMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
-->

!!!
!!! XML
!!! Strict
%html{ :xmlns => "http://www.w3.org/1999/xhtml", :lang => "en", 'xml:lang' => "en" }
%head
%title= page_title @is_lost_on
%meta{'http-equiv'=>"Content-Type", :content=>"text/html; charset=iso-8859-1"}/
%meta{'http-equiv'=>"Content-Language", :content=>"en-us"}/
// %link{:href => '/updates.atom', :rel => 'alternate', :type => 'application/atom+xml', :title => 'feed'}
// %link{:href=>"/stylesheets/#{IsLOSTOnYet.show_abbrev.downcase}.css", :media=>"all", :rel=>"stylesheet", :type=>"text/css"}/
// - if mobile_safari?
// %link{:href=>"/stylesheets/mobile_safari.css", :media=>"all", :rel=>"stylesheet", :type=>"text/css"}/
// %meta{:name => "viewport", :content => "width = device-width, initial-scale = 1.0"}/
// /[if IE]
// %link{:href=>"/stylesheets/ie.css", :media=>"all", :rel=>"stylesheet", :type=>"text/css"}/
%style{:type=>"text/css"}
:sass
body
:background-color white
.container
:width 250px
#isit_widget
:background-color #333
:background-image url(/bsg-cylon.gif)
:background-position right top
:background-repeat no-repeat
:height 8em
:padding 10px
:font-family arial, sans-serif
:color #fff
:text-transform uppercase
a
:color #fff
:text-decoration none
*
:margin 0
:padding 0
h3,h4,h5,p
:font-size 11pt
:line-height 1em
h3
:font-size 100%
a
:color #C82418
h4
:font-size 75%
:font-weight normal
&:after
:content "."
:display block
:clear both
:visibility hidden
:line-height 0
:height 0
h5
:font-size 180%
:float left
:padding-right 5px
p
span
:font-size 70%
strong
:font-size 170%
:font-weight normal

%body{:id=>"#{@body_id}", :class=>"#{@body_class}"}
.container
%script{:type=>"text/javascript"}
var isit_style=""
%script{:type=>"text/javascript", :src=>"widget.js"}
31 changes: 31 additions & 0 deletions views/widget_js.haml
@@ -0,0 +1,31 @@
:plain
var isit_style_inline="<style type='text/css'> #isit_widget { text-transform: uppercase; color: #fff; font-size: 110%; } #isit_widget a { color: #fff; } #isit_widget #isit_question { font-size: 205%; } #isit_widget #isit_question a { text-decoration: none; color: #a91620; } #isit_widget #isit_answer { font-size: 420%; line-height: 1em; padding-right: 5px; margin-bottom: -8px; float: left; } #isit_widget #isit_reason { font-size: 98%; width: 12em; float: left; color: #777777; } #isit_widget #isit_countdown { font-weight: normal; clear: both; } #isit_widget #isit_countdown strong { font-size: 220%; font-weight: normal; } </style>"

if ( typeof( window[ 'isit_style' ] ) != "undefined" ) {
document.write(isit_style)
}
else {
document.write(isit_style_inline)
}

document.write("<div id='isit_widget' onClick='parent.location=\"http://is#{IsLOSTOnYet.show_abbrev.downcase}onyet.com\"' style='cursor:pointer'><h3 id='isit_question'><a href='http://is#{IsLOSTOnYet.show_abbrev.downcase}onyet.com'>Is #{IsLOSTOnYet.show_abbrev} on yet?</a></h3><h5 id='isit_answer'>#{@is_lost_on.answer}</h5><h4 id='isit_reason'>#{@is_lost_on.reason}</h4><p id='isit_countdown'></p>");
var countdown_targetdate = Date.parse("#{@is_lost_on.next_episode.local_air_date.strftime('%Y/%m/%d %H:%M')}");
var countdown_d = new Date();
var countdown_timenow = countdown_d.getTime();
var countdown_timeleft = Math.floor((countdown_targetdate-countdown_timenow)/1000);
function countdown(remain) {
var
status = document.getElementById("isit_answer");
countdown = document.getElementById("isit_countdown");
timer = setInterval( function () {
var day = (Math.floor(remain/86400))%86400;
var hour = (Math.floor(remain/3600))%24;
var minute = (Math.floor(remain/60))%60;
var second = (Math.floor(remain/1))%60;
countdown.innerHTML = (day > 0 ? "<span class='countdown_day'><strong>"+day+"</strong>d</span> " : "") + (hour > 0 ? "<span class='countdown_hour'><strong>"+hour+"</strong>h</span> " : "") + (minute > 0 ? "<span class='countdown_minute'><strong>"+minute+"</strong>m</span> " : "") + (second > 0 ? "<span class='countdown_second'><strong>"+second+"</strong>s</span> " : "");
if (--remain < 0 ) {
clearInterval(timer);
}
},1000);
}
countdown(countdown_timeleft);

0 comments on commit 9ffad4c

Please sign in to comment.