zero-fill date and add cookie recognition

pull/16/head
posativ 12 years ago
parent 10b1b1b470
commit d9a9eaf8c5

@ -6,6 +6,22 @@
<script type="text/javascript" src="/static/ender.js"></script> <script type="text/javascript" src="/static/ender.js"></script>
<script type="text/javascript"> <script type="text/javascript">
/* utility functions -- JS Y U SO STUPID? */
function read(cookie){
return(document.cookie.match('(^|; )' + cookie + '=([^;]*)') || 0)[2]
};
function zfill(arg, i) {
var res = String(arg);
if (res.length < i) {
for (var j = 0; j <= (i - res.length); j++) {
res = '0' + res;
};
}
return res;
}
var createForm = function(id, func) { var createForm = function(id, func) {
/* /*
Returns HTML for form and registers submit call. Returns HTML for form and registers submit call.
@ -92,6 +108,12 @@
}; };
var insert = function(thread, post) { var insert = function(thread, post) {
/*
Insert a comment into #isso_thread.
:param thread: XXX remove this
:param post: JSON from API call
*/
// pythonic strftime // pythonic strftime
var format = function(date, lang, fmt) { var format = function(date, lang, fmt) {
@ -105,10 +127,10 @@
}; };
var conversions = [ var conversions = [
['%Y', date.getFullYear()], ['%m', date.getMonth()], ['%Y', date.getFullYear()], ['%m', zfill(date.getMonth(), 2)],
['%B', months[lang][date.getMonth() - 1]], ['%B', months[lang][date.getMonth() - 1]],
['%d', date.getDate()], ['%H', date.getHours()], ['%d', zfill(date.getDate(), 2)], ['%H', zfill(date.getHours(), 2)],
['%H', date.getHours()], ['%M', date.getMinutes()], ['%H', zfill(date.getHours(), 2)], ['%M', zfill(date.getMinutes(), 2)],
]; ];
conversions.map(function(item) { fmt = fmt.replace(item[0], item[1]) }); conversions.map(function(item) { fmt = fmt.replace(item[0], item[1]) });
@ -139,6 +161,12 @@
' </footer>' + ' </footer>' +
'</article>'); '</article>');
if (read('session-' + encodeURIComponent(window.location.pathname) + '-' + post['id'])) {
var node = $('#isso_' + post['id'] + '> footer > a:first-child')
.after('<a href="#">Bearbeiten</a>');
}
// ability to answer directly to a comment // ability to answer directly to a comment
$('footer > a:first-child', '#isso_' + post['id']).on('click', function(event) { $('footer > a:first-child', '#isso_' + post['id']).on('click', function(event) {

@ -17,10 +17,14 @@
padding-left: 12px; padding-left: 12px;
} }
.isso header { .isso > header {
border-bottom: solid 1px lightgray; border-bottom: solid 1px lightgray;
} }
.isso > footer > a {
padding: 0 10px 10px 0;
}
.isso + .issoform { .isso + .issoform {
margin-left: 20px; margin-left: 20px;
} }

Loading…
Cancel
Save