Created
January 29, 2012 15:25
-
-
Save hitode909/1699286 to your computer and use it in GitHub Desktop.
はてなブログ古い順に読むやつ http://hitode909.hatenablog.com/entry/2012/01/30/014140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
later = (func) -> | |
setTimeout func, 0 | |
executeByQueue = do -> | |
queue = [] | |
timer = null | |
(func) -> | |
if timer | |
queue.push func | |
return | |
else | |
timer = setInterval -> | |
if queue.length > 0 | |
queue.shift()() | |
else | |
clearInterval(timer) | |
timer = null | |
, 1000 | |
func() | |
keyWithPrefix = (key) -> | |
"blog-viewer-#{key}" | |
extractPath = (url) -> | |
url.replace "#{location.protocol}//#{location.host}", "" | |
roundEpoch = (epoch) -> | |
date = new Date(epoch * 1000) | |
Math.floor(new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() / 1000) | |
appendBar = (x, css) -> | |
bar = $('<div>') | |
.attr | |
class: 'calendar-bar' | |
.css | |
left: x | |
bar.css(css) if css | |
bar.appendTo('#calendar') | |
bar | |
appendBarAtTime = (created, css) -> | |
date_from = new Date(2011, 11-1, 7) | |
date_now = new Date() | |
appendBar("#{(created - date_from) / (date_now - date_from) * 100}%", css) | |
selectEntryByUUID = (uuid) -> | |
$(".calendar-bar.selected").removeClass("selected") | |
$(".calendar-bar[data-uuid=\"#{uuid}\"]").addClass('selected') | |
return unless $(".calendar-bar.selected").length | |
left = $(".calendar-bar.selected").position().left - $("#scroll-bar").width() / 2 | |
left = 3 if left < 3 | |
left = 550 - 13 if left > 550-13 | |
$("#scroll-bar").css | |
left: left | |
throttle = (fn, delay) -> | |
timer = null | |
-> | |
return if timer | |
context = this | |
args = arguments | |
timer = setTimeout -> | |
timer = null | |
fn.apply context, args | |
,delay || 100 | |
debounce = `function (func, threshold, execAsap) { | |
var timeout; | |
return function debounced () { | |
var obj = this, args = arguments; | |
function delayed () { | |
if (!execAsap) | |
func.apply(obj, args); | |
timeout = null; | |
}; | |
if (timeout) | |
clearTimeout(timeout); | |
else if (execAsap) | |
func.apply(obj, args); | |
timeout = setTimeout(delayed, threshold || 100); | |
}; | |
}` | |
# 画面のより下の途中に入るとおかしくなるのでは | |
checkScroll = debounce -> | |
entry = $('#main-inner article:last') | |
return unless entry.length | |
top_before = entry.position().top | |
later -> | |
top_after = entry.position().top | |
window.scrollBy(0, top_after - top_before) | |
, 100, true | |
updateStars = debounce -> | |
Hatena.Locale.updateTimestamps(document.body) | |
$(document.body).find('span.hatena-star-comment-container, span.hatena-star-star-container').remove() | |
Hatena.Star.EntryLoader.loadNewEntries(document.body) | |
,1000 | |
scrollToEntry = debounce (entry) -> | |
return unless entry | |
top = $(entry).position().top - $('#blog-title-inner').height() - 20 | |
if Math.abs($(window).scrollTop() - top) < $(window).height() * 0.4 | |
window.scrollTo(0, top) | |
else | |
$('html,body').animate({ scrollTop: top }, 300) | |
updateScrollBar = -> | |
entry = entryFromScrollTop() | |
return unless entry | |
selectEntryByUUID(entry.attr('data-uuid')) | |
created = new Date(entry.find('time').attr('datetime')) | |
setTip(formatDate(created)) | |
autoloader() | |
autoloader = throttle -> | |
if $(window).scrollTop() <= 0 | |
entry = $('#main-inner article:first') | |
return unless entry.length | |
created = new Date(entry.find('time').attr('datetime')) | |
showEntries(created.getTime() / 1000) | |
if $(window).scrollTop() + $(window).height() >= $(document).height() | |
entry = $('#main-inner article:last') | |
return unless entry.length | |
created = new Date(entry.find('time').attr('datetime')) | |
showEntries(created.getTime() / 1000 + 3600*24*3) | |
,500 | |
_tipTimer = null | |
setTip = (text) -> | |
tip = $('#calendar-container #tip') | |
return if tip.text() == text | |
tip | |
.text(text) | |
.stop() | |
.css | |
opacity: 1 | |
clearTimeout(_tipTimer) if _tipTimer | |
_tipTimer = setTimeout -> | |
tip.animate | |
opacity: 0 | |
, 1500 | |
,10000 | |
entryFromTime = (time) -> | |
date = new Date(time) | |
found = null | |
found_created = 0 | |
$('#main-inner article').each -> | |
entry = $(this) | |
entry_created = new Date(entry.find('time').attr('datetime')) | |
if Math.abs(entry_created - date) < Math.abs(found_created - date) | |
found = entry | |
found_created = entry_created | |
found | |
entryFromScrollTop = -> | |
top = $(document).scrollTop() | |
window_height = $(window).height() | |
found = null | |
distance = $(document).height() | |
$('#main-inner article').each -> | |
entry = $(this) | |
entry_top = entry.position().top | |
entry_height = entry.height() | |
if Math.abs(top - entry_top) < distance | |
found = entry | |
distance = Math.abs(top - entry_top) | |
found | |
formatDate = (date) -> | |
return "" if isNaN(date.getFullYear()) | |
"#{date.getFullYear()}-#{date.getMonth()+1}-#{date.getDate()}" | |
# todo: image load fail | |
waitForLoadImages = (element, callback) -> | |
images = $(element).find('img') | |
if images.length == 0 | |
callback(element) | |
return | |
count = 0 | |
images.each -> | |
image = $(this) | |
image.load -> | |
count++ | |
if count == images.length | |
callback(element) | |
scrollByLocation = -> | |
pathname = location.pathname | |
if pathname == "/" | |
scrollToEntry($('article:last')) | |
return | |
link = $(".entry-footer-time a[href=\"#{pathname}\"]") | |
return unless link.length | |
scrollToEntry(link.parents('article')) | |
appendEntry = (entry) -> | |
entry = $(entry) | |
uuid = entry.attr('data-uuid') | |
entry_created = new Date(entry.find('time').attr('datetime')) | |
entry_old = null | |
entry_old_created = null | |
entry_recent = null | |
entry_recent_created = null | |
$('#main-inner article').each -> | |
tmp_entry = $(this) | |
tmp_created = new Date(tmp_entry.find('time').attr('datetime')) | |
if tmp_created <= entry_created && (!entry_old || entry_old_created < tmp_created) | |
entry_old = tmp_entry | |
entry_old_created = tmp_created | |
if tmp_created >= entry_created && (!entry_recent || entry_recent_created > tmp_created) | |
entry_recent = tmp_entry | |
entry_recent_created = tmp_created | |
if entry_old && entry_old.attr('data-uuid') == uuid | |
entry.remove() | |
return | |
if entry_recent && entry_recent.attr('data-uuid') == uuid | |
entry.remove() | |
return | |
bar = appendBarAtTime(entry_created) | |
bar.attr | |
'data-uuid': uuid | |
later -> | |
updateStars() | |
checkScroll() | |
later -> | |
updateScrollBar() | |
if entry_old | |
entry_old.after(entry) | |
return | |
if entry_recent | |
entry_recent.before(entry) | |
return | |
$('#main-inner').prepend(entry) | |
fetchedHash = {} | |
showEntries = (epoch) -> | |
return unless epoch | |
return if epoch < 0 | |
return if isNaN(epoch) #??? | |
deferred = $.Deferred() | |
epoch = roundEpoch(epoch) | |
url = "/?page=#{epoch}" | |
if fetchedHash[url] | |
later -> | |
deferred.resolve() | |
return deferred.promise() | |
fetchedHash[url] = true | |
executeByQueue -> | |
$.ajax | |
url: url | |
dataType: 'html' | |
.success (page) -> | |
fragment = document.createDocumentFragment() | |
$(page).find('article').each -> | |
entry = $(this) | |
uuid = entry.attr('data-uuid') | |
return if $("article[data-uuid=\"#{uuid}\"]").length > 0 | |
return if entry.is('.no-entry') | |
if entry.find('img').length > 0 | |
$('#loading-entry').append(entry) | |
waitForLoadImages this, (entry) -> | |
appendEntry(entry) | |
else | |
appendEntry(entry) | |
deferred.resolve() | |
deferred.promise() | |
fetchYear = (year, res) -> | |
res ||= | |
entries: [] | |
completed: false | |
deferred = $.Deferred() | |
$.ajax | |
url: '/archive' | |
data: | |
year: year | |
dataType: 'html' | |
.success (page) -> | |
date = null | |
$(page).find('h1, a.entry-title').each -> | |
elem = this | |
try | |
if elem.tagName.toLowerCase() == 'h1' | |
[_, year, month, day] = $(elem).text().match /(\d{4})-(\d{2})-(\d{2})/ | |
date = | |
year: +year | |
month: +month | |
day: +day | |
else if elem.tagName.toLowerCase() == 'a' | |
res.entries.unshift | |
url: elem.href | |
title: $(elem).text() | |
date: date | |
res.completed = $(page).find('a.entry-title').length == 0 | |
deferred.resolve(res) | |
deferred.promise() | |
collectCalendar = -> | |
deferred = $.Deferred() | |
year = new Date().getFullYear() | |
fetchYear(year).then (calendar)-> | |
if calendar.completed | |
deferred.resolve(calendar) | |
return | |
year-- | |
fetchYear(year, calendar).then arguments.callee | |
deferred.promise() | |
main = -> | |
if Hatena && Hatena.Star | |
Hatena.Star.SiteConfig = | |
entryNodes: | |
'div.entry-inner': | |
uri: 'a.bookmark' | |
title: 'h1.entry-title' | |
container: 'p.entry-footer-section' | |
$('<div>').attr | |
id: 'loading-entry' | |
.css | |
display: 'none' | |
.appendTo($('body')) | |
container = $('<div>') | |
.attr | |
id: 'calendar-container' | |
calendar = $('<div>') | |
.attr | |
id: 'calendar' | |
container.append(calendar) | |
tip = $('<div>') | |
.attr | |
id: 'tip' | |
container.append(tip) | |
$('#container').append(container) | |
calendar.click (event) -> | |
width = container.width() | |
x = event.clientX - container.position().left | |
date_from = new Date(2011, 11-1, 7) | |
date_now = new Date() | |
time_selected = date_from.getTime() + (date_now.getTime() - date_from.getTime()) * (x / width) # | |
entry = entryFromTime(time_selected) | |
path = extractPath(entry.find('.entry-footer-time a').attr('href')) | |
history.pushState(path, path, path) | |
scrollToEntry(entry) | |
calendar.mousemove throttle (event) -> | |
width = container.width() | |
x = event.clientX - container.position().left | |
date_from = new Date(2011, 11-1, 7) | |
date_now = new Date() | |
time_selected = date_from.getTime() + (date_now.getTime() - date_from.getTime()) * (x / width) # | |
time_selected_3days_up = date_from.getTime() + (date_now.getTime() - date_from.getTime()) * (x / width) + 3600*24*1000*3 # | |
date_selected = new Date(time_selected) | |
date_selected_3days_up = new Date(time_selected_3days_up) | |
setTip(formatDate(date_selected)) | |
showEntries(Math.floor(date_selected_3days_up.getTime() / 1000)) | |
scrollBar = $('<div>') | |
.attr | |
id: 'scroll-bar' | |
calendar.append(scrollBar) | |
$(window).bind 'scroll', throttle (event) -> | |
updateScrollBar() | |
articles = [] | |
$('article').each -> | |
entry = this | |
articles.push($(entry).clone()) | |
$(entry).remove() | |
$.each articles, -> | |
appendEntry(this) | |
setTimeout -> | |
scrollByLocation() | |
,100 | |
module_dummy = $('<div>').addClass('hatena-module').addClass('hatena-module-profile') | |
$('.hatena-follow-button-box').appendTo(module_dummy) | |
module_dummy.appendTo($('#blog-title-inner')) | |
$('body').delegate '.entry-footer-time a', 'click', (event) -> | |
return true unless history && history.pushState | |
path = extractPath(this.href) | |
history.pushState(path, path, path) | |
later -> | |
scrollByLocation() | |
false | |
$('body').delegate 'article .date', 'click', (event) -> | |
$(this).parents('article').find('.entry-footer-time a').click() | |
false | |
$('body').delegate '#blog-title a', 'click', (event) -> | |
return true unless history && history.pushState | |
path = extractPath(this.href) | |
history.pushState(path, path, path) | |
later -> | |
scrollByLocation() | |
false | |
$(window).bind 'popstate', (event) -> | |
scrollByLocation() | |
setTimeout -> | |
updateStars() | |
,1000 | |
main() | |
window.scrollBy(0,1) | |
$('.pager').remove() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CSS Document */ | |
@import url(http://fonts.googleapis.com/css?family=Maven+Pro:700); | |
/* @Main | |
====================================== */ | |
html{ | |
margin:0; | |
padding:0; | |
} | |
body{ | |
margin:0; | |
padding:0; | |
color:#000; | |
background:#022b5c url('bg.jpg') repeat-x fixed top center; | |
font-family: 'Maven Pro','Helvetica','Arial','ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'ï¼ï¼³ Pゴシック','MS PGothic',sans-serif; | |
} | |
a{ | |
color:#0e4b84; | |
} | |
a:visited{ | |
color:#3c6b97; | |
} | |
a:hover{ | |
color:#1673c9; | |
} | |
a,pre{ | |
word-break: break-all; | |
overflow: hidden; | |
} | |
pre{ | |
padding:10px; | |
background:#fafafa; | |
white-space: pre-wrap; | |
border-radius: 3px; | |
-webkit-border-radius: 3px; | |
-moz-border-radius: 3px; | |
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,.20); | |
-moz-box-shadow: inset 0 0 5px rgba(0,0,0,.20); | |
box-shadow: inset 0 0 5px rgba(0,0,0,.20); | |
} | |
/* @GLOBALHEADER | |
====================================== */ | |
#globalheader-container{ | |
background: rgba(255, 255, 255, 0.5); | |
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.40); | |
-moz-box-shadow: 0 0 10px rgba(0,0,0,.40); | |
box-shadow: 0 0 10px rgba(0,0,0,.40); | |
} | |
/* @Container | |
====================================== */ | |
#container{ | |
width:800px; | |
margin:0 auto; | |
text-align:center; | |
} | |
#container-inner{ | |
text-align:left; | |
} | |
/* @Blog-Title | |
====================================== */ | |
#title{ | |
margin:0; | |
display:inline; | |
font-size:35px; | |
text-shadow:0 2px 2px rgba(0,0,0,.50); | |
-moz-text-shadow:0 2px 2px rgba(0,0,0,.50); | |
-webkit-text-shadow: 0 2px 2px rgba(0,0,0,.50); | |
filter: dropshadow(color=#333333,offX=0,offY=2); | |
} | |
#title a{ | |
text-decoration:none; | |
color:#fff; | |
} | |
#blog-description{ | |
display:inline; | |
color:#fff; | |
margin:0; | |
padding-left:1em; | |
font-size:13px; | |
text-shadow:0 2px 2px rgba(0,0,0,.70); | |
-moz-text-shadow:0 2px 2px rgba(0,0,0,.70); | |
-webkit-text-shadow: 0 2px 2px rgba(0,0,0,.70); | |
filter: dropshadow(color=#333333,offX=0,offY=2); | |
} | |
/* @Top-box and Navigation Module | |
====================================== */ | |
/* @Content-Box | |
====================================== */ | |
#content-inner{ | |
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.30); | |
-moz-box-shadow: 0 0 5px rgba(0,0,0,.30); | |
box-shadow: 0 0 5px rgba(0,0,0,.30); | |
-moz-border-radius: 10px; | |
-webkit-border-radius: 10px; | |
-ms-border-radius: 10px; | |
border-radius: 10px; | |
background: rgba(255, 255, 255, 0.5); | |
background: url('opacity5.png') repeat\9; | |
} | |
#main{ | |
background: rgba(255, 255, 255, 1); | |
background: #fff\9; | |
-moz-border-radius: 10px 0 0 10px; | |
-webkit-border-radius: 10px 0 0 10px; | |
-ms-border-radius: 10px 0 0 10px; | |
border-radius: 10px 0 0 10px; | |
padding:20px; | |
float:left; | |
width:510px; | |
-webkit-box-shadow: 5px 0px 10px -10px rgba(0,0,0,.70); | |
-moz-box-shadow: 5px 0px 10px -10px rgba(0,0,0,.70); | |
box-shadow: 5px 0px 10px -10px rgba(0,0,0,.70); | |
min-height: 800px; | |
} | |
* html #main{ | |
box-shadow: 0px 0px 0px 0px rgba(255,255,255,.00); | |
} | |
#box1{ | |
float:right; | |
width:240px; | |
-moz-transition:all 1s ease; | |
-webkit-transition:all 1s ease; | |
} | |
#box2{ | |
float:right; | |
-moz-transition:all 1s ease; | |
-webkit-transition:all 1s ease; | |
} | |
#box2:after{ | |
content:""; | |
display:block; | |
clear:both; | |
} | |
#footer-box:after{ | |
content:""; | |
display:block; | |
clear:both; | |
} | |
/* @Section,Article | |
====================================== */ | |
.entry-content { | |
font-size: 13px; | |
line-height: 1.8; | |
margin:1em 0; | |
font-family:'Helvetica','Arial','ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'ï¼ï¼³ Pゴシック','MS PGothic',sans-serif; | |
} | |
.entry{ | |
margin-bottom:50px; | |
position:relative; | |
} | |
.date{ | |
display:block; | |
width: 95px; | |
background: rgba(0, 0, 0, 0.5); | |
background: #666\9; | |
color:#fff; | |
padding: 5px 15px 5px 20px; | |
position:relative; | |
left:-20px; | |
text-shadow:0 1px 2px #000; | |
-moz-text-shadow:0 1px 2px #000; | |
-webkit-text-shadow: 0 1px 2px #000; | |
-moz-border-radius: 0 3px 3px 0; | |
-webkit-border-radius: 0 3px 3px 0; | |
-ms-border-radius: 0 3px 3px 0; | |
border-radius: 0 3px 3px 0; | |
} | |
.entry-title{ | |
font-size:20px; | |
padding:10px 0; | |
margin:0; | |
} | |
.entry-title a{ | |
text-decoration:none; | |
} | |
.entry-footer-section{ | |
font-style:italic; | |
color:#666; | |
margin:0; | |
} | |
.entry-footer-time a{ | |
color:#666; | |
} | |
.entry-footer-time a:hover{ | |
color:#1673C9; | |
} | |
.pager{ | |
text-align:center; | |
} | |
.pager a{ | |
background: rgba(0, 0, 0, 0.5); | |
color:#fff; | |
padding: 5px 15px; | |
margin:0px 2px; | |
font-size:13px; | |
-moz-border-radius: 3px; | |
-webkit-border-radius: 3px; | |
-ms-border-radius: 3px; | |
border-radius: 3px; | |
text-decoration:none; | |
} | |
.pager a:hover{ | |
color:#fff !important; | |
background: rgba(0, 0, 0, 0.7); | |
} | |
/* @Article headline | |
====================================== */ | |
.entry-content h1{ | |
font-size:16px; | |
margin:0.5em 0; | |
} | |
.entry-content h2{ | |
font-size:15px; | |
margin:0.5em 0; | |
} | |
.entry-content h3{ | |
font-size:14px; | |
margin:0.5em 0; | |
} | |
.entry-content p{ | |
margin:0.5em 0; | |
} | |
/* @Entry TextStyle | |
====================================== */ | |
.entry-content img{ | |
max-width:500px; | |
height:auto; | |
} | |
.entry blockquote{ | |
padding: 10px; | |
margin: 1em 0; | |
border:1px solid #ddd; | |
border-radius: 3px; | |
-webkit-border-radius: 3px; | |
-moz-border-radius: 3px; | |
} | |
.entry blockquote p{ | |
margin-top:0; | |
margin-bottom:0; | |
} | |
.entry-content table { | |
border-collapse: collapse; | |
border-spacing: 0; | |
} | |
.entry-content table th, | |
.entry-content table td{ | |
border:1px solid #ddd; | |
padding:5px 10px; | |
} | |
.entry-content table th{ | |
background:#fafafa; | |
} | |
.entry-content h1, | |
.entry-content h2, | |
.entry-content h3, | |
.entry-content h4, | |
.entry-content h5, | |
.entry-content h6{ | |
margin: 1em 0 0.5em 0; | |
} | |
.entry-content h1, | |
.entry-content h2{ | |
font-size:130%; | |
} | |
.entry-content h3{ | |
font-size:120%; | |
} | |
.entry-content h4{ | |
font-size:110%; | |
} | |
.entry-content h5{ | |
font-size:100%; | |
} | |
.entry-content h6{ | |
font-size:100%; | |
} | |
.entry-content h1, | |
.entry-content h2, | |
.entry-content h3{ | |
border-bottom:1px dashed #999; | |
} | |
.entry-content ul{ | |
margin: 0 0 0 1.5em; | |
padding: 0; | |
} | |
a.keyword{ | |
color:#000; | |
text-decoration:none; | |
border-bottom: 1px solid #DEDEDE; | |
} | |
pre.lang-aa{ | |
font-size:13px; | |
line-height:14px; | |
} | |
/* @Edit HEADER-MENU | |
====================================== */ | |
.entry-header-menu a{ | |
font-size:13px; | |
display:inline; | |
cursor: pointer; | |
border-radius: 3px; | |
-webkit-border-radius: 3px; | |
-moz-border-radius: 3px; | |
color: #fff; | |
padding:3px 10px; | |
background:#5297de; | |
text-decoration: none; | |
background: -webkit-gradient( | |
linear, | |
left top, | |
left bottom, | |
from(#73b0ee), | |
to(#3675b4) | |
); | |
background: -moz-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#3675b4 100% | |
); | |
background: -o-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#3675b4 100% | |
); | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#3675b4)); | |
-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#3675b4))"; | |
zoom: 1; | |
font-weight:bold; | |
border:1px solid #447296; | |
text-shadow:0 -1px 0px #164a5a; | |
-moz-text-shadow:0 -1px 0px #164a5a; | |
-webkit-text-shadow: 0 -1px 0px #164a5a; | |
position:absolute; | |
top:0px; | |
left:120px; | |
} | |
.entry-header-menu a:hover{ | |
background:#2f81d5; | |
background: -webkit-gradient( | |
linear, | |
left top, | |
left bottom, | |
from(#73b0ee), | |
to(#1f62a7) | |
); | |
background: -moz-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#1f62a7 100% | |
); | |
background: -o-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#1f62a7 100% | |
); | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#1f62a7)); | |
-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#1f62a7))"; | |
zoom: 1; | |
border:1px solid #2066ad; | |
text-shadow: 0 -1px 0px #164A5A; | |
text-decoration:none; | |
color:#fff !important; | |
} | |
/* @Comment | |
====================================== */ | |
.entry-footer{ | |
margin-top:30px; | |
margin-bottom:80px; | |
font-size:12px; | |
} | |
.entry-footer .social-buttons{ | |
margin: 10px 0; | |
} | |
.comment{ | |
padding:0; | |
list-style:none; | |
} | |
.comment-user-name{ | |
display:block; | |
color:#666; | |
line-height: 40px; | |
margin:0; | |
} | |
.comment-content{ | |
margin-bottom:0.5em; | |
} | |
.comment-content p{ | |
margin:0; | |
word-wrap: break-word; | |
} | |
.comment-metadata{ | |
margin:0; | |
} | |
.comment li { | |
margin-bottom: 2px; | |
} | |
.entry-comment:last-child{ | |
margin-bottom:30px; | |
} | |
.comment-metadata a{ | |
text-decoration:none; | |
font-style: italic; | |
color: #666; | |
} | |
.leave-comment-title{ | |
display:inline; | |
cursor: pointer; | |
border-radius: 3px; | |
-webkit-border-radius: 3px; | |
-moz-border-radius: 3px; | |
background:#5297de; | |
color: #fff; | |
padding:6px 15px; | |
text-decoration: none; | |
background: -webkit-gradient( | |
linear, | |
left top, | |
left bottom, | |
from(#73b0ee), | |
to(#3675b4) | |
); | |
background: -moz-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#3675b4 100% | |
); | |
background: -o-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#3675b4 100% | |
); | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#3675b4)); | |
-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#3675b4))"; | |
font-weight:bold; | |
border:1px solid #447296; | |
text-shadow:0 -1px 0px #164a5a; | |
-moz-text-shadow:0 -1px 0px #164a5a; | |
-webkit-text-shadow: 0 -1px 0px #164a5a; | |
} | |
.leave-comment-title:hover{ | |
color: #fff; | |
background:#2f81d5; | |
background: -webkit-gradient( | |
linear, | |
left top, | |
left bottom, | |
from(#73b0ee), | |
to(#1f62a7) | |
); | |
background: -moz-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#1f62a7 100% | |
); | |
background: -o-linear-gradient( | |
top, | |
#73b0ee 0%, | |
#1f62a7 100% | |
); | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#1f62a7)); | |
-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startcolorstr=#73b0ee, endcolorstr=#1f62a7))"; | |
zoom: 1; | |
border:1px solid #2066ad; | |
text-shadow: 0 -1px 0px #164A5A; | |
text-decoration:none; | |
} | |
.hatena-id-icon{ | |
position:relative; | |
left:-5px; | |
top:15px; | |
padding: 13px 17px 12px 11px; | |
background:transparent url('comment.png') no-repeat center; | |
} | |
.comment-user-name .hatena-id-icon{ | |
position: relative; | |
left: -5px; | |
} | |
/* @Module | |
====================================== */ | |
/* .hatena-module{ */ | |
/* width:200px; */ | |
/* margin:20px 20px 50px 20px; */ | |
/* font-size:13px; */ | |
/* } */ | |
.hatena-module-title{ | |
color:#fff; | |
margin:0; | |
font-size:20px; | |
text-shadow:0 2px 2px rgba(0,0,0,.70); | |
-moz-text-shadow:0 2px 2px rgba(0,0,0,.70); | |
-webkit-text-shadow: 0 2px 2px rgba(0,0,0,.70); | |
padding: 0 0 0.4em 0; | |
border-bottom: 1px dashed #666; | |
margin-bottom:0.5em; | |
} | |
.hatena-module ul{ | |
margin:0; | |
padding:0; | |
list-style:none; | |
} | |
.hatena-module li{ | |
padding-bottom:0.5em; | |
} | |
.hatena-module li.archive{ | |
border-top: 1px dashed #666; | |
margin-top:0.5em; | |
padding-top:0.5em; | |
} | |
/* @Module::Profile | |
====================================== */ | |
.hatena-module .profile-icon{ | |
display:block; | |
margin-bottom:5px; | |
} | |
.hatena-module-body .id a{ | |
font-size:13px; | |
text-decoration:none; | |
font-weight:bold; | |
} | |
.hatena-module-body .profile-description{ | |
margin: 0 0 5px 0; | |
} | |
/* @Module::Search | |
====================================== */ | |
form.search-form{ | |
margin-top:10px; | |
} | |
form.search-form input { | |
border:none; | |
vertical-align:middle; | |
} | |
.search-form .search-module-input { | |
width: 168px; | |
background: -webkit-gradient( | |
linear, | |
left top, | |
left bottom, | |
from(#eee), | |
color-stop(0.5, #eee), | |
to(#fff) | |
); | |
background: -moz-linear-gradient( | |
top, | |
#eee 0%, | |
#eee 50%, | |
#fff 100% | |
); | |
padding: 3px; | |
margin:0; | |
font-size:12px; | |
border-radius: 12px; | |
-webkit-border-radius: 12px; | |
-moz-border-radius: 12px; | |
background: rgba(0, 0, 0, 0.2); | |
box-shadow: 0px -1px 0px #454545; | |
} | |
.search-form .search-module-button { | |
height:23px; | |
width:23px; | |
border: none; | |
text-indent: -999px; | |
margin-left: -3px; | |
*margin-left: -5px; | |
cursor: pointer; | |
background:#565656 url('/images/theme/search_w.png') 50% 50% no-repeat; | |
border-radius: 12px; | |
-webkit-border-radius: 12px; | |
-moz-border-radius: 12px; | |
} | |
/* @Footer-Area-Module | |
====================================== */ | |
#footer-box{ | |
} | |
/* @Footer | |
====================================== */ | |
#footer{ | |
clear:both; | |
text-align:center; | |
margin:30px 0; | |
} | |
#footer a{ | |
color:#fff; | |
font-weight:bold; | |
text-decoration:none; | |
text-shadow:0 2px 2px #000; | |
-moz-text-shadow:0 2px 2px #000; | |
-webkit-text-shadow: 0 2px 2px #000; | |
font-style:normal; | |
} | |
/* @HATENA-EMBED(FOTOLIFE,TWITPIC) | |
====================================== */ | |
.hatena-embed.hatena-fotolife, | |
.hatena-embed.twitpic{ | |
padding:10px 10px 30px 10px; | |
margin:1em 0; | |
background: transparent; | |
display: inline-block; | |
border:1px solid #dfdfdf; | |
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
-moz-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
background:#fff; | |
text-align:center; | |
} | |
.hatena-embed.hatena-fotolife{ | |
background:#fff url('/images/theme/hatena-embed/embed-fotolife.png')no-repeat right bottom; | |
} | |
.hatena-embed.twitpic{ | |
padding:10px 10px 10px 10px; | |
} | |
.hatena-embed.hatena-fotolife .hatena-embed-image, | |
.hatena-embed.twitpic .hatena-embed-image{ | |
display:inline-block; | |
max-width:488px; | |
} | |
.hatena-embed.hatena-fotolife .hatena-embed-body, | |
.hatena-embed.hatena-fotolife .hatena-embed-body a, | |
.hatena-embed.twitpic .hatena-embed-body, | |
.hatena-embed.twitpic .hatena-embed-body a{ | |
text-align:center; | |
font-family: 'Homemade Apple', cursive; | |
color:#454545; | |
font-size:16px; | |
margin-top:10px; | |
} | |
/* @HATENA-EMBED(COCO,4SQ) | |
====================================== */ | |
.hatena-embed.hatena-coco, | |
.hatena-embed.foursquare{ | |
margin:1em 0; | |
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
-moz-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
} | |
.hatena-embed.hatena-coco{ | |
border: 1px solid #e2d279; | |
padding: 20px 30px; | |
background:#faf9e6 url('/images/theme/hatena-embed/embed-coco.png')no-repeat right bottom; | |
} | |
.hatena-embed.hatena-coco .hatena-embed-image, | |
.hatena-embed.foursquare .hatena-embed-image{ | |
width:100px; | |
height:100px; | |
} | |
.hatena-embed.foursquare{ | |
border: 1px solid #C1D5DB; | |
padding: 20px 30px; | |
background:#E6EFF2 url('/images/theme/hatena-embed/embed-4sq.png')no-repeat right bottom; | |
} | |
/* @HATENA-EMBED(BOOKMARK) | |
====================================== */ | |
.hatena-embed.hatena-bookmark{ | |
padding:15px 15px 15px 70px; | |
margin:1em 0; | |
background: transparent; | |
border:1px solid #dfdfdf; | |
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
-moz-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
background:#fff url('/images/theme/hatena-embed/embed-bookmark.png')no-repeat 10px top; | |
position:relative; | |
} | |
.hatena-embed.hatena-bookmark a{ | |
text-decoration:underline; | |
} | |
.hatena-embed.hatena-bookmark .hatena-embed-image{ | |
max-height:50px; | |
} | |
.hatena-embed.hatena-bookmark .hatena-embed-body{ | |
} | |
/* @HATENA-EMBED(HAIKU) | |
====================================== */ | |
.hatena-embed.hatena-haiku{ | |
padding:15px 15px 15px 70px; | |
margin:1em 0; | |
background: transparent; | |
border:1px solid #dfdfdf; | |
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
-moz-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
background:#fff url('/images/theme/hatena-embed/embed-haiku.png')no-repeat 5px 5px; | |
} | |
/* @HATENA-EMBED(MONOLITH) | |
====================================== */ | |
.hatena-embed.hatena-monolith{ | |
width:478px; | |
padding:15px; | |
margin:1em 0; | |
background: transparent; | |
border:1px solid #dfdfdf; | |
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
-moz-box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
box-shadow: 0 1px 5px rgba(0,0,0,.16); | |
background:#fff url('/images/theme/hatena-embed/embed-monolith.png')no-repeat right bottom; | |
} | |
.hatena-embed.hatena-monolith .hatena-embed-image{ | |
display:block; | |
float:left; | |
max-width:98px; | |
border:1px solid #dfdfdf; | |
} | |
.hatena-embed.hatena-monolith .hatena-embed-body{ | |
float:left; | |
width:368px; | |
margin-left:10px; | |
} | |
.hatena-embed.hatena-monolith:after{ | |
content: ""; | |
display: block; | |
height: 0; | |
visibility: hidden; | |
clear: both; | |
} | |
/* @HATENA-EMBED(TWITTER) | |
====================================== */ | |
.hatena-embed.twitter{ | |
padding:10px 0; | |
margin:1em 0; | |
border-bottom: 1px dotted #757575; | |
border-top: 1px dotted #757575; | |
} | |
/* @HATENA-EMBED(ATND) | |
====================================== */ | |
.hatena-embed.atnd{ | |
padding:10px 0; | |
margin:1em 0; | |
border-bottom: 1px dotted #757575; | |
border-top: 1px dotted #757575; | |
font-family:'PT Sans Caption', Helvetica, 'ヒラギノ角ゴ Pro W3','HiraKakuProN-W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'ï¼ï¼³ Pゴシック',sans-serif; | |
} | |
.hatena-embed-detail.atnd-detail{ | |
font-size: 20px; | |
font-weight:bold; | |
color:#262626; | |
} | |
.hatena-embed-detail.atnd-detail:hover{ | |
color:#EA1F00; | |
text-decoration:none; | |
} | |
.hatena-embed.atnd .content-body{ | |
font-size:12px; | |
color:#222; | |
} | |
/* @PREVIEW | |
====================================== */ | |
body.preview{ | |
color:#454545; | |
background:#fff; | |
padding:10px; | |
} | |
body.preview .hatena-embed{ | |
margin-right:30px; | |
} | |
/* @About | |
====================================== */ | |
.page-about #main, | |
.page-archive #main{ | |
-moz-border-radius: 10px; | |
-webkit-border-radius: 10px; | |
-ms-border-radius: 10px; | |
border-radius: 10px; | |
width:760px; | |
-webkit-box-shadow: 0px 0px 5px rgba(0,0,0,.30); | |
-moz-box-shadow: 5px 0px 10px -10px rgba(0,0,0,.70); | |
box-shadow: 5px 0px 10px -10px rgba(0,0,0,.70); | |
min-height: 500px; | |
float:none; | |
} | |
.page-about dt{ | |
font-size:16px; | |
font-weight:bold; | |
} | |
.page-about dd{ | |
margin-left:0; | |
margin-bottom:30px; | |
} | |
.page-about img.profile-icon{ | |
height:16px; | |
width:16px; | |
} | |
/* @Archive | |
====================================== */ | |
.page-archive #main-inner{ | |
font-size:14px; | |
} | |
.page-archive #main-inner h1{ | |
font-size:18px; | |
} | |
.page-archive #main-inner .entry-title{ | |
font-size:14px; | |
} | |
.page-archive #main-inner li{ | |
margin:5px 0; | |
} | |
#google_afc_user { | |
height:0px; | |
overflow:hidden; | |
} | |
body { | |
background: #ffffff; | |
} | |
#title { | |
text-shadow: none; | |
} | |
#title a { | |
color: #444; | |
} | |
#main{ | |
margin-top: 70px; | |
background: #ffffff; | |
color: #444; | |
-moz-border-radius: 0px; | |
-webkit-border-radius: 0px; | |
-ms-border-radius: 0px; | |
border-radius: 0px; | |
padding:20px; | |
float:left; | |
width:510px; | |
-webkit-box-shadow: none; | |
-moz-box-shadow: none; | |
box-shadow: none; | |
min-height: 800px; | |
} | |
#box1 { | |
display: none; | |
} | |
#box2 { | |
position: none; | |
} | |
#content-inner{ | |
-webkit-box-shadow: none; | |
-moz-box-shadow: none; | |
box-shadow: none; | |
-moz-border-radius: 0; | |
-webkit-border-radius: 0; | |
-ms-border-radius: 0; | |
border-radius: 0; | |
background: transparent; | |
} | |
.date { | |
color: #444; | |
background: #ffffff; | |
text-shadow: none; | |
cursor: pointer; | |
} | |
a.keyword { | |
color: #444; | |
text-decoration: none; | |
border-bottom: 0px; | |
} | |
.hatena-module-title { | |
color: #444; | |
} | |
.pager a { | |
color: #ffffff; | |
} | |
#footer a { | |
color: #ffffff; | |
} | |
.entry-footer-section{ | |
font-style: normal; | |
} | |
.entry-footer-section a { | |
text-decoration: none; | |
} | |
#globalheader-container{ | |
color: #444; | |
background: transparent; | |
-webkit-box-shadow: none; | |
-moz-box-shadow: none; | |
box-shadow: none; | |
} | |
.hatena-module-links { | |
display: none; | |
} | |
.hatena-module-search-box { | |
display: none; | |
} | |
.comment-box { | |
display: none; | |
} | |
.hatena-module-title { | |
display: none; | |
} | |
h1.entry-title { | |
display: none; | |
} | |
.id { | |
display: none; | |
} | |
.hatena-module .profile-icon { | |
display: none; | |
} | |
.entry-footer-section .author { | |
display: none; | |
} | |
#footer { | |
visibility: hidden; | |
} | |
#container { | |
width: 550px; | |
} | |
.hatena-star-comment-container { | |
display: none; | |
} | |
#globalheader-container { | |
display: none; | |
} | |
.social-buttons { | |
display: none; | |
} | |
.pager { | |
display: none; | |
} | |
#blog-description { | |
display: none; | |
} | |
.profile-description { | |
display: none; | |
} | |
.entry.no-entry { | |
display: none; | |
} | |
/* ----- calendar ----- */ | |
#calendar-container { | |
position: fixed; | |
bottom: 0px; | |
width: 550px; | |
height: 50px; | |
background: white; | |
} | |
#calendar-container #calendar { | |
cursor: pointer; | |
width: 100%; | |
height: 16px; | |
padding: 0; | |
position: absolute; | |
left: 0px; | |
top: 10px; | |
background: #fafafa; | |
border: 1px solid #dadada; | |
} | |
#calendar-container #scroll-bar { | |
position: absolute; | |
top: 3px; | |
left: 0px; | |
width: 10px; | |
height: 10px; | |
opacity: 0.8; | |
background:#666; | |
-webkit-transition-property: left; | |
-webkit-transition-duration: 0.1s; | |
-webkit-transition-timing-function: linear; | |
} | |
#calendar-container .calendar-bar { | |
position: absolute; | |
width: 1px; | |
height: 100%; | |
background: #444; | |
top: 0px; | |
opacity: 0.7; | |
} | |
#calendar-container .calenda-bar.loading { | |
background: #999; | |
} | |
#calendar-container #tip { | |
color: #444; | |
font-size: 14px; | |
margin-top: 30px; | |
} | |
/* ----- header, blog-title */ | |
#blog-title-inner { | |
width:550px; | |
height:60px; | |
background:white; | |
position:fixed; | |
z-index:1000; | |
} | |
#blog-title-inner h1#title { | |
position: absolute; | |
left: 0px; | |
bottom: 0px; | |
} | |
.hatena-module .hatena-follow-button-box { | |
position: absolute; | |
right: 0px; | |
bottom: 0px; | |
padding-bottom:10px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appendBar, appendBarAtTime, appendEntry, autoloader, checkScroll, collectCalendar, debounce, entryFromScrollTop, entryFromTime, executeByQueue, extractPath, fetchYear, fetchedHash, formatDate, keyWithPrefix, later, main, roundEpoch, scrollByLocation, scrollToEntry, selectEntryByUUID, setTip, showEntries, throttle, updateScrollBar, updateStars, waitForLoadImages, _tipTimer; | |
later = function(func) { | |
return setTimeout(func, 0); | |
}; | |
executeByQueue = (function() { | |
var queue, timer; | |
queue = []; | |
timer = null; | |
return function(func) { | |
if (timer) { | |
queue.push(func); | |
} else { | |
timer = setInterval(function() { | |
if (queue.length > 0) { | |
return queue.shift()(); | |
} else { | |
clearInterval(timer); | |
return timer = null; | |
} | |
}, 1000); | |
return func(); | |
} | |
}; | |
})(); | |
keyWithPrefix = function(key) { | |
return "blog-viewer-" + key; | |
}; | |
extractPath = function(url) { | |
return url.replace("" + location.protocol + "//" + location.host, ""); | |
}; | |
roundEpoch = function(epoch) { | |
var date; | |
date = new Date(epoch * 1000); | |
return Math.floor(new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() / 1000); | |
}; | |
appendBar = function(x, css) { | |
var bar; | |
bar = $('<div>').attr({ | |
"class": 'calendar-bar' | |
}).css({ | |
left: x | |
}); | |
if (css) { | |
bar.css(css); | |
} | |
bar.appendTo('#calendar'); | |
return bar; | |
}; | |
appendBarAtTime = function(created, css) { | |
var date_from, date_now; | |
date_from = new Date(2011, 11 - 1, 7); | |
date_now = new Date(); | |
return appendBar("" + ((created - date_from) / (date_now - date_from) * 100) + "%", css); | |
}; | |
selectEntryByUUID = function(uuid) { | |
var left; | |
$(".calendar-bar.selected").removeClass("selected"); | |
$(".calendar-bar[data-uuid=\"" + uuid + "\"]").addClass('selected'); | |
if (!$(".calendar-bar.selected").length) { | |
return; | |
} | |
left = $(".calendar-bar.selected").position().left - $("#scroll-bar").width() / 2; | |
if (left < 3) { | |
left = 3; | |
} | |
if (left > 550 - 13) { | |
left = 550 - 13; | |
} | |
return $("#scroll-bar").css({ | |
left: left | |
}); | |
}; | |
throttle = function(fn, delay) { | |
var timer; | |
timer = null; | |
return function() { | |
var args, context; | |
if (timer) { | |
return; | |
} | |
context = this; | |
args = arguments; | |
return timer = setTimeout(function() { | |
timer = null; | |
return fn.apply(context, args); | |
}, delay || 100); | |
}; | |
}; | |
debounce = function (func, threshold, execAsap) { | |
var timeout; | |
return function debounced () { | |
var obj = this, args = arguments; | |
function delayed () { | |
if (!execAsap) | |
func.apply(obj, args); | |
timeout = null; | |
}; | |
if (timeout) | |
clearTimeout(timeout); | |
else if (execAsap) | |
func.apply(obj, args); | |
timeout = setTimeout(delayed, threshold || 100); | |
}; | |
}; | |
checkScroll = debounce(function() { | |
var entry, top_before; | |
entry = $('#main-inner article:last'); | |
if (!entry.length) { | |
return; | |
} | |
top_before = entry.position().top; | |
return later(function() { | |
var top_after; | |
top_after = entry.position().top; | |
return window.scrollBy(0, top_after - top_before); | |
}); | |
}, 100, true); | |
updateStars = debounce(function() { | |
Hatena.Locale.updateTimestamps(document.body); | |
$(document.body).find('span.hatena-star-comment-container, span.hatena-star-star-container').remove(); | |
return Hatena.Star.EntryLoader.loadNewEntries(document.body); | |
}, 1000); | |
scrollToEntry = debounce(function(entry) { | |
var top; | |
if (!entry) { | |
return; | |
} | |
top = $(entry).position().top - $('#blog-title-inner').height() - 20; | |
if (Math.abs($(window).scrollTop() - top) < $(window).height() * 0.4) { | |
return window.scrollTo(0, top); | |
} else { | |
return $('html,body').animate({ | |
scrollTop: top | |
}, 300); | |
} | |
}); | |
updateScrollBar = function() { | |
var created, entry; | |
entry = entryFromScrollTop(); | |
if (!entry) { | |
return; | |
} | |
selectEntryByUUID(entry.attr('data-uuid')); | |
created = new Date(entry.find('time').attr('datetime')); | |
setTip(formatDate(created)); | |
return autoloader(); | |
}; | |
autoloader = throttle(function() { | |
var created, entry; | |
if ($(window).scrollTop() <= 0) { | |
entry = $('#main-inner article:first'); | |
if (!entry.length) { | |
return; | |
} | |
created = new Date(entry.find('time').attr('datetime')); | |
showEntries(created.getTime() / 1000); | |
} | |
if ($(window).scrollTop() + $(window).height() >= $(document).height()) { | |
entry = $('#main-inner article:last'); | |
if (!entry.length) { | |
return; | |
} | |
created = new Date(entry.find('time').attr('datetime')); | |
return showEntries(created.getTime() / 1000 + 3600 * 24 * 3); | |
} | |
}, 500); | |
_tipTimer = null; | |
setTip = function(text) { | |
var tip; | |
tip = $('#calendar-container #tip'); | |
if (tip.text() === text) { | |
return; | |
} | |
tip.text(text).stop().css({ | |
opacity: 1 | |
}); | |
if (_tipTimer) { | |
clearTimeout(_tipTimer); | |
} | |
return _tipTimer = setTimeout(function() { | |
return tip.animate({ | |
opacity: 0 | |
}, 1500); | |
}, 10000); | |
}; | |
entryFromTime = function(time) { | |
var date, found, found_created; | |
date = new Date(time); | |
found = null; | |
found_created = 0; | |
$('#main-inner article').each(function() { | |
var entry, entry_created; | |
entry = $(this); | |
entry_created = new Date(entry.find('time').attr('datetime')); | |
if (Math.abs(entry_created - date) < Math.abs(found_created - date)) { | |
found = entry; | |
return found_created = entry_created; | |
} | |
}); | |
return found; | |
}; | |
entryFromScrollTop = function() { | |
var distance, found, top, window_height; | |
top = $(document).scrollTop(); | |
window_height = $(window).height(); | |
found = null; | |
distance = $(document).height(); | |
$('#main-inner article').each(function() { | |
var entry, entry_height, entry_top; | |
entry = $(this); | |
entry_top = entry.position().top; | |
entry_height = entry.height(); | |
if (Math.abs(top - entry_top) < distance) { | |
found = entry; | |
return distance = Math.abs(top - entry_top); | |
} | |
}); | |
return found; | |
}; | |
formatDate = function(date) { | |
if (isNaN(date.getFullYear())) { | |
return ""; | |
} | |
return "" + (date.getFullYear()) + "-" + (date.getMonth() + 1) + "-" + (date.getDate()); | |
}; | |
waitForLoadImages = function(element, callback) { | |
var count, images; | |
images = $(element).find('img'); | |
if (images.length === 0) { | |
callback(element); | |
return; | |
} | |
count = 0; | |
return images.each(function() { | |
var image; | |
image = $(this); | |
return image.load(function() { | |
count++; | |
if (count === images.length) { | |
return callback(element); | |
} | |
}); | |
}); | |
}; | |
scrollByLocation = function() { | |
var link, pathname; | |
pathname = location.pathname; | |
if (pathname === "/") { | |
scrollToEntry($('article:last')); | |
return; | |
} | |
link = $(".entry-footer-time a[href=\"" + pathname + "\"]"); | |
if (!link.length) { | |
return; | |
} | |
return scrollToEntry(link.parents('article')); | |
}; | |
appendEntry = function(entry) { | |
var bar, entry_created, entry_old, entry_old_created, entry_recent, entry_recent_created, uuid; | |
entry = $(entry); | |
uuid = entry.attr('data-uuid'); | |
entry_created = new Date(entry.find('time').attr('datetime')); | |
entry_old = null; | |
entry_old_created = null; | |
entry_recent = null; | |
entry_recent_created = null; | |
$('#main-inner article').each(function() { | |
var tmp_created, tmp_entry; | |
tmp_entry = $(this); | |
tmp_created = new Date(tmp_entry.find('time').attr('datetime')); | |
if (tmp_created <= entry_created && (!entry_old || entry_old_created < tmp_created)) { | |
entry_old = tmp_entry; | |
entry_old_created = tmp_created; | |
} | |
if (tmp_created >= entry_created && (!entry_recent || entry_recent_created > tmp_created)) { | |
entry_recent = tmp_entry; | |
return entry_recent_created = tmp_created; | |
} | |
}); | |
if (entry_old && entry_old.attr('data-uuid') === uuid) { | |
entry.remove(); | |
return; | |
} | |
if (entry_recent && entry_recent.attr('data-uuid') === uuid) { | |
entry.remove(); | |
return; | |
} | |
bar = appendBarAtTime(entry_created); | |
bar.attr({ | |
'data-uuid': uuid | |
}); | |
later(function() { | |
return updateStars(); | |
}); | |
checkScroll(); | |
later(function() { | |
return updateScrollBar(); | |
}); | |
if (entry_old) { | |
entry_old.after(entry); | |
return; | |
} | |
if (entry_recent) { | |
entry_recent.before(entry); | |
return; | |
} | |
return $('#main-inner').prepend(entry); | |
}; | |
fetchedHash = {}; | |
showEntries = function(epoch) { | |
var deferred, url; | |
if (!epoch) { | |
return; | |
} | |
if (epoch < 0) { | |
return; | |
} | |
if (isNaN(epoch)) { | |
return; | |
} | |
deferred = $.Deferred(); | |
epoch = roundEpoch(epoch); | |
url = "/?page=" + epoch; | |
if (fetchedHash[url]) { | |
later(function() { | |
return deferred.resolve(); | |
}); | |
return deferred.promise(); | |
} | |
fetchedHash[url] = true; | |
executeByQueue(function() { | |
return $.ajax({ | |
url: url, | |
dataType: 'html' | |
}).success(function(page) { | |
var fragment; | |
fragment = document.createDocumentFragment(); | |
$(page).find('article').each(function() { | |
var entry, uuid; | |
entry = $(this); | |
uuid = entry.attr('data-uuid'); | |
if ($("article[data-uuid=\"" + uuid + "\"]").length > 0) { | |
return; | |
} | |
if (entry.is('.no-entry')) { | |
return; | |
} | |
if (entry.find('img').length > 0) { | |
$('#loading-entry').append(entry); | |
return waitForLoadImages(this, function(entry) { | |
return appendEntry(entry); | |
}); | |
} else { | |
return appendEntry(entry); | |
} | |
}); | |
return deferred.resolve(); | |
}); | |
}); | |
return deferred.promise(); | |
}; | |
fetchYear = function(year, res) { | |
var deferred; | |
res || (res = { | |
entries: [], | |
completed: false | |
}); | |
deferred = $.Deferred(); | |
$.ajax({ | |
url: '/archive', | |
data: { | |
year: year | |
}, | |
dataType: 'html' | |
}).success(function(page) { | |
var date; | |
date = null; | |
$(page).find('h1, a.entry-title').each(function() { | |
var day, elem, month, _, _ref; | |
elem = this; | |
try { | |
if (elem.tagName.toLowerCase() === 'h1') { | |
_ref = $(elem).text().match(/(\d{4})-(\d{2})-(\d{2})/), _ = _ref[0], year = _ref[1], month = _ref[2], day = _ref[3]; | |
return date = { | |
year: +year, | |
month: +month, | |
day: +day | |
}; | |
} else if (elem.tagName.toLowerCase() === 'a') { | |
return res.entries.unshift({ | |
url: elem.href, | |
title: $(elem).text(), | |
date: date | |
}); | |
} | |
} catch (_e) {} | |
}); | |
res.completed = $(page).find('a.entry-title').length === 0; | |
return deferred.resolve(res); | |
}); | |
return deferred.promise(); | |
}; | |
collectCalendar = function() { | |
var deferred, year; | |
deferred = $.Deferred(); | |
year = new Date().getFullYear(); | |
fetchYear(year).then(function(calendar) { | |
if (calendar.completed) { | |
deferred.resolve(calendar); | |
return; | |
} | |
year--; | |
return fetchYear(year, calendar).then(arguments.callee); | |
}); | |
return deferred.promise(); | |
}; | |
main = function() { | |
var articles, calendar, container, module_dummy, scrollBar, tip; | |
if (Hatena && Hatena.Star) { | |
Hatena.Star.SiteConfig = { | |
entryNodes: { | |
'div.entry-inner': { | |
uri: 'a.bookmark', | |
title: 'h1.entry-title', | |
container: 'p.entry-footer-section' | |
} | |
} | |
}; | |
} | |
$('<div>').attr({ | |
id: 'loading-entry' | |
}).css({ | |
display: 'none' | |
}).appendTo($('body')); | |
container = $('<div>').attr({ | |
id: 'calendar-container' | |
}); | |
calendar = $('<div>').attr({ | |
id: 'calendar' | |
}); | |
container.append(calendar); | |
tip = $('<div>').attr({ | |
id: 'tip' | |
}); | |
container.append(tip); | |
$('#container').append(container); | |
calendar.click(function(event) { | |
var date_from, date_now, entry, path, time_selected, width, x; | |
width = container.width(); | |
x = event.clientX - container.position().left; | |
date_from = new Date(2011, 11 - 1, 7); | |
date_now = new Date(); | |
time_selected = date_from.getTime() + (date_now.getTime() - date_from.getTime()) * (x / width); | |
entry = entryFromTime(time_selected); | |
path = extractPath(entry.find('.entry-footer-time a').attr('href')); | |
history.pushState(path, path, path); | |
return scrollToEntry(entry); | |
}); | |
calendar.mousemove(throttle(function(event) { | |
var date_from, date_now, date_selected, date_selected_3days_up, time_selected, time_selected_3days_up, width, x; | |
width = container.width(); | |
x = event.clientX - container.position().left; | |
date_from = new Date(2011, 11 - 1, 7); | |
date_now = new Date(); | |
time_selected = date_from.getTime() + (date_now.getTime() - date_from.getTime()) * (x / width); | |
time_selected_3days_up = date_from.getTime() + (date_now.getTime() - date_from.getTime()) * (x / width) + 3600 * 24 * 1000 * 3; | |
date_selected = new Date(time_selected); | |
date_selected_3days_up = new Date(time_selected_3days_up); | |
setTip(formatDate(date_selected)); | |
return showEntries(Math.floor(date_selected_3days_up.getTime() / 1000)); | |
})); | |
scrollBar = $('<div>').attr({ | |
id: 'scroll-bar' | |
}); | |
calendar.append(scrollBar); | |
$(window).bind('scroll', throttle(function(event) { | |
return updateScrollBar(); | |
})); | |
articles = []; | |
$('article').each(function() { | |
var entry; | |
entry = this; | |
articles.push($(entry).clone()); | |
return $(entry).remove(); | |
}); | |
$.each(articles, function() { | |
return appendEntry(this); | |
}); | |
setTimeout(function() { | |
return scrollByLocation(); | |
}, 100); | |
module_dummy = $('<div>').addClass('hatena-module').addClass('hatena-module-profile'); | |
$('.hatena-follow-button-box').appendTo(module_dummy); | |
module_dummy.appendTo($('#blog-title-inner')); | |
$('body').delegate('.entry-footer-time a', 'click', function(event) { | |
var path; | |
if (!(history && history.pushState)) { | |
return true; | |
} | |
path = extractPath(this.href); | |
history.pushState(path, path, path); | |
later(function() { | |
return scrollByLocation(); | |
}); | |
return false; | |
}); | |
$('body').delegate('article .date', 'click', function(event) { | |
$(this).parents('article').find('.entry-footer-time a').click(); | |
return false; | |
}); | |
$('body').delegate('#blog-title a', 'click', function(event) { | |
var path; | |
if (!(history && history.pushState)) { | |
return true; | |
} | |
path = extractPath(this.href); | |
history.pushState(path, path, path); | |
later(function() { | |
return scrollByLocation(); | |
}); | |
return false; | |
}); | |
$(window).bind('popstate', function(event) { | |
return scrollByLocation(); | |
}); | |
return setTimeout(function() { | |
return updateStars(); | |
}, 1000); | |
}; | |
main(); | |
window.scrollBy(0, 1); | |
$('.pager').remove(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment