-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
162 lines (142 loc) · 4.25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<title>TypePad Favorites Widget powered by TypePad</title>
<style type="text/css">
body {
background: #EE0000;
color: white;
height: 100%;
}
#star {
position: absolute;
right: 0;
bottom: 20px;
opacity: 0.3;
}
#faves {
position: absolute;
width: 500px;
}
h1 {
font-family: Helvetica;
font-size: 4em;
font-weight: bold;
letter-spacing: -0.1em;
line-height: 0.95em;
text-transform: lowercase;
margin: 0;
}
#fave-content p {
font-family: Helvetica;
font-size: 1.2em;
}
#permalink {
float: right;
}
a:link, a:hover, a:visited, a:active {
color: white;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head><body>
<div id="star">
<img src="star.png" width="240" height="190">
</div>
<div id="faves">
<h1><a href="#" target="_new" id="title"></a></h1>
<div id="fave-content"></div>
<p>
<a href="#" id="permalink">#</a>
<a href="#" id="see-next">→</a>
</p>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var profileAlias = 'btrott';
$.fn.centerize = function () {
var ph = $( document ).height();
var pw = $( document ).width();
return this.each( function ( i ) {
var ah = $( this ).height();
var aw = $( this ).width();
var mh = ( ph - ah ) / 2;
var mw = ( pw - aw ) / 2;
$( this ).css( {
top: mh,
left: mw
} );
} );
};
$( window ).resize( function () {
$( '#faves' ).centerize();
} );
var entries = new Array();
var currentEntry = 0; // 1-based index into the entries array
var seenFirst = false;
$( document ).ready( function() {
$( '#see-next' ).click( function() {
seeentry();
return false;
} );
loadmore();
} );
function loadmore() {
$.getJSON(
'http://api.typepad.com/users/' + escape( profileAlias ) + '/favorites.js?callback=?',
{
'start-index': currentEntry + 1,
'max-results': 15
},
function( data ) {
for ( var i = 0; i < data.entries.length; i++ ) {
$.getJSON(
'http://api.typepad.com/assets/' + data.entries[ i ].inReplyTo.urlId + '.js?callback=?',
function( entry ) {
entries.push( entry );
if ( !seenFirst ) seeentry();
}
);
}
}
);
}
function seeentry() {
seenFirst = true;
var asset = entries[ currentEntry ];
if ( !asset ) {
seenFirst = false;
loadmore();
return;
}
$( '#fave-content' ).empty();
var image = null;
if ( asset.imageLink ) {
image = asset.imageLink;
} else if ( asset.previewImageLink ) {
image = asset.previewImageLink;
} else if ( asset.embeddedImageLinks && asset.embeddedImageLinks.length > 0 ) {
image = asset.embeddedImageLinks[0];
}
$( '#title' ).attr( 'href', asset.permalinkUrl );
if ( asset.title ) {
$( '#title' ).text( asset.title );
document.title = asset.title;
} else {
$( '#title' ).empty();
}
$( '#permalink' ).attr( 'href', asset.permalinkUrl );
if ( image && image.urlTemplate ) {
$( '#fave-content' ).append( '<p><img src="' + image.urlTemplate.replace( '{spec}', '350wi' ) + '" /></p>' );
}
if ( asset.excerpt ) {
$( '#fave-content' ).append( '<p>' + asset.excerpt + '</p>' );
}
$( '#faves' ).centerize();
currentEntry++;
}
</script>
</body></html>