... | ... |
@@ -159,6 +159,23 @@ div.comment { |
159 | 159 |
border-bottom: 1px solid #ddd; |
160 | 160 |
} |
161 | 161 |
|
162 |
+div.commentheader { |
|
163 |
+ margin: 10px; |
|
164 |
+} |
|
165 |
+ |
|
166 |
+span.commentauthor { |
|
167 |
+ font-size: 18px; |
|
168 |
+ float: left; |
|
169 |
+} |
|
170 |
+ |
|
171 |
+span.commentdate { |
|
172 |
+ float: right; |
|
173 |
+} |
|
174 |
+ |
|
175 |
+div.commenttext { |
|
176 |
+ margin: 5px 30px 10px; |
|
177 |
+} |
|
178 |
+ |
|
162 | 179 |
p.commentbox { |
163 | 180 |
margin: 0px; |
164 | 181 |
padding: 0px; |
... | ... |
@@ -201,3 +218,23 @@ input.inputsendcomment:active { |
201 | 218 |
color: #eee; |
202 | 219 |
} |
203 | 220 |
|
221 |
+div#prevnext { |
|
222 |
+ width: 820px; |
|
223 |
+ margin-left: auto; |
|
224 |
+ margin-right: auto; |
|
225 |
+ margin-top: 15px; |
|
226 |
+ margin-bottom: 10px; |
|
227 |
+ padding: 10px; |
|
228 |
+} |
|
229 |
+ |
|
230 |
+a.pagenum { |
|
231 |
+ text-decoration: none; |
|
232 |
+} |
|
233 |
+ |
|
234 |
+span.paginas { |
|
235 |
+ float: left; |
|
236 |
+} |
|
237 |
+ |
|
238 |
+span.newerolder { |
|
239 |
+ float: right; |
|
240 |
+} |
... | ... |
@@ -17,8 +17,16 @@ function request(querytext, func, errorfunc) { |
17 | 17 |
req.send(); |
18 | 18 |
} |
19 | 19 |
|
20 |
+function getvar(name) { |
|
21 |
+ var re=new RegExp("[?&]"+name+"=\([^&]*\)"); |
|
22 |
+ var value=window.location.search.match(re); |
|
23 |
+ if(value===null || value.length<2) |
|
24 |
+ return(name+"="); |
|
25 |
+ return(name+"="+value[1]); |
|
26 |
+} |
|
27 |
+ |
|
20 | 28 |
gotonewpost.onclick = function(e) { |
21 |
- window.location="/newpost.html"+window.location.search |
|
29 |
+ window.location="/newpost.html?"+getvar("s"); |
|
22 | 30 |
}; |
23 | 31 |
|
24 | 32 |
document.getElementById("posts").innerHTML='Loading posts...'; |
... | ... |
@@ -55,15 +63,16 @@ function changepost(postnum,data) { |
55 | 63 |
for(var i in p.comments) { |
56 | 64 |
var c=p.comments[i]; |
57 | 65 |
comments.push('<div class="comment">'); |
58 |
- comments.push('<p class="commentheader">'); |
|
66 |
+ comments.push('<div class="commentheader">'); |
|
59 | 67 |
var commentdate=new Date(0); |
60 | 68 |
commentdate.setUTCSeconds(parseInt(c.date)); |
69 |
+ comments.push('<span class="commentauthor">'); |
|
61 | 70 |
comments.push(decodeURIComponent(c.author)); |
62 |
- comments.push(" "); |
|
71 |
+ comments.push('</span> <span class="commentdate">'); |
|
63 | 72 |
comments.push(commentdate.toString()); |
64 |
- comments.push('</p><p>'); |
|
73 |
+ comments.push('</span></div><div class="commenttext">'); |
|
65 | 74 |
comments.push(decodeURIComponent(c.text)); |
66 |
- comments.push('</p>'); |
|
75 |
+ comments.push('</div>'); |
|
67 | 76 |
comments.push('</div>'); |
68 | 77 |
} |
69 | 78 |
comments.push('<div class="commentbox"><p class="commentbox">'); |
... | ... |
@@ -73,8 +82,8 @@ function changepost(postnum,data) { |
73 | 82 |
postsarray[toppost-postnum]='<div class="post">'+header.join("")+body.join("")+'</div>'+comments.join("") /*+JSON.stringify(p) */; |
74 | 83 |
functionsarray[toppost-postnum]=function() { |
75 | 84 |
var requri=[]; |
76 |
- requri.push("/newcomment"); |
|
77 |
- requri.push(window.location.search); |
|
85 |
+ requri.push("/newcomment?"); |
|
86 |
+ requri.push(getvar("s")); |
|
78 | 87 |
requri.push("&n="+postnum); |
79 | 88 |
requri.push("&t="); |
80 | 89 |
requri.push(encodeURIComponent(document.getElementById("comment"+(toppost-postnum)).value)); |
... | ... |
@@ -107,7 +116,7 @@ function displayposts() { |
107 | 116 |
} |
108 | 117 |
|
109 | 118 |
function refreshpost(postnum) { |
110 |
- request("/getpost"+window.location.search+"&n="+postnum, function(r1) { |
|
119 |
+ request("/getpost?"+getvar("s")+"&n="+postnum, function(r1) { |
|
111 | 120 |
changepost(postnum,r1); |
112 | 121 |
displayposts(); |
113 | 122 |
},function() { |
... | ... |
@@ -115,12 +124,79 @@ function refreshpost(postnum) { |
115 | 124 |
}); |
116 | 125 |
} |
117 | 126 |
|
127 |
+function refreshprevnext() { |
|
128 |
+ var nav=[]; |
|
129 |
+ var curpage; |
|
130 |
+ var totalpages; |
|
131 |
+ var inc; |
|
132 |
+ var maxinc=(Number(lastpost)/postsperpage)/2; |
|
133 |
+ nav.push('<span class="paginas">Página:'); |
|
134 |
+ curpage=Math.floor(((Number(lastpost)-Number(toppost))/postsperpage))+1; |
|
135 |
+ totalpages=Math.floor((Number(lastpost)-1)/postsperpage)+1; |
|
136 |
+ for(var page=1;(Number(lastpost)-(page-1)*postsperpage)>0;page+=inc) { |
|
137 |
+ if(Number(toppost)<=(Number(lastpost)-(page-1)*postsperpage) && |
|
138 |
+ Number(toppost)>(Number(lastpost)-(page)*postsperpage)) { |
|
139 |
+ nav.push(" "+page); |
|
140 |
+ } else { |
|
141 |
+ nav.push(' <a href="'); |
|
142 |
+ nav.push('/posts.html?'); |
|
143 |
+ nav.push(getvar("s")); |
|
144 |
+ if(page>1) { |
|
145 |
+ nav.push('&p='); |
|
146 |
+ nav.push(Number(toppost)-(page-1)*postsperpage); |
|
147 |
+ } |
|
148 |
+ nav.push('" class="pagenum">'); |
|
149 |
+ nav.push(page); |
|
150 |
+ nav.push('</a>'); |
|
151 |
+ } |
|
152 |
+ if(Math.abs(curpage-page)<5) { |
|
153 |
+ inc=1; |
|
154 |
+ } else { |
|
155 |
+ inc=Math.floor((Math.abs(curpage-page)/totalpages)*maxinc); |
|
156 |
+ inc=(inc<=0)?1:inc; |
|
157 |
+ if(page<totalpages && (page+inc)>totalpages) |
|
158 |
+ inc=totalpages-page; |
|
159 |
+ } |
|
160 |
+ } |
|
161 |
+ nav.push('</span> '); |
|
162 |
+ nav.push('<span class="newerolder">'); |
|
163 |
+ if(toppost<lastpost) { |
|
164 |
+ nav.push(' <a href="'); |
|
165 |
+ nav.push('/posts.html?'); |
|
166 |
+ nav.push(getvar("s")); |
|
167 |
+ if((Number(toppost)+Number(postsperpage))<lastpost) { |
|
168 |
+ nav.push('&p='); |
|
169 |
+ nav.push(Number(toppost)+Number(postsperpage)); |
|
170 |
+ } |
|
171 |
+ nav.push('" class="pagenum">Posts más nuevos</a>'); |
|
172 |
+ } else |
|
173 |
+ nav.push("Posts más nuevos"); |
|
174 |
+ nav.push(" | "); |
|
175 |
+ if((Number(toppost)-Number(postsperpage))>0) { |
|
176 |
+ nav.push(' <a href="'); |
|
177 |
+ nav.push('/posts.html?'); |
|
178 |
+ nav.push(getvar("s")); |
|
179 |
+ nav.push('&p='); |
|
180 |
+ nav.push(Number(toppost)-Number(postsperpage)); |
|
181 |
+ nav.push('" class="pagenum">Posts más antiguos</a>'); |
|
182 |
+ } else |
|
183 |
+ nav.push('Posts más antiguos'); |
|
184 |
+ nav.push('</span>'); |
|
185 |
+ document.getElementById("prevnext").innerHTML=nav.join(""); |
|
186 |
+} |
|
118 | 187 |
|
119 |
-request("/lastpost"+window.location.search,function(r) { |
|
188 |
+request("/lastpost?"+getvar("s"),function(r) { |
|
189 |
+ var p; |
|
120 | 190 |
lastpost=r; |
121 |
- toppost=r; |
|
191 |
+ toppost=r |
|
192 |
+ p=getvar("p"); |
|
193 |
+ if(p.length>2) |
|
194 |
+ toppost=Number(p.slice(2)); |
|
195 |
+ if(toppost<0 || toppost>lastpost) |
|
196 |
+ toppost=lastpost; |
|
197 |
+ refreshprevnext(); |
|
122 | 198 |
for(var i=0;i<postsperpage;i++) |
123 |
- refreshpost(r-i); |
|
199 |
+ refreshpost(toppost-i); |
|
124 | 200 |
},function() { |
125 | 201 |
document.getElementById("posts").innerHTML='There are no posts'; |
126 | 202 |
}); |
127 | 203 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,7 @@ |
1 |
+/* |
|
2 |
+Copyright (c) 2011, Yahoo! Inc. All rights reserved. |
|
3 |
+Code licensed under the BSD License: |
|
4 |
+http://developer.yahoo.com/yui/license.html |
|
5 |
+version: 2.9.0 |
|
6 |
+*/ |
|
7 |
+html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,select,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,button,caption,cite,code,dfn,em,input,optgroup,option,select,strong,textarea,th,var{font:inherit}del,ins{text-decoration:none}li{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:baseline}sub{vertical-align:baseline}legend{color:#000} |
|
0 | 8 |
\ No newline at end of file |