diff --git a/isso/js/isso.js b/isso/js/isso.js index 082044d..fdad29e 100644 --- a/isso/js/isso.js +++ b/isso/js/isso.js @@ -34,6 +34,29 @@ function zfill(arg, i) { }; +// pythonic strftime +var format = function(date, lang, fmt) { + + var months = {'de': [ + 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', + 'August', 'September', 'Oktober', 'November', 'Dezember'], + 'en': [ + 'January', 'February', 'March', 'April', 'May', 'June', 'July', + 'August', 'September', 'October', 'November', 'December'], + }; + + var conversions = [ + ['%Y', date.getFullYear()], ['%m', zfill(date.getMonth(), 2)], + ['%B', months[lang][date.getMonth() - 1]], + ['%d', zfill(date.getDate(), 2)], ['%H', zfill(date.getHours(), 2)], + ['%H', zfill(date.getHours(), 2)], ['%M', zfill(date.getMinutes(), 2)], + ]; + + conversions.map(function(item) { fmt = fmt.replace(item[0], item[1]) }); + return fmt; +}; + + /* * isso specific helpers to create, modify, delete and receive comments */ @@ -118,36 +141,20 @@ function form(id, appendfunc, eventfunc) { }; -function insert(thread, post) { +function update(post) { + + var node = $('#isso_' + post['id']); + $('div.text', node).html(post['text']); +}; + + +function insert(post) { /* Insert a comment into #isso_thread. - :param thread: XXX remove this :param post: JSON from API call */ - // pythonic strftime - var format = function(date, lang, fmt) { - - var months = {'de': [ - 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', - 'August', 'September', 'Oktober', 'November', 'Dezember'], - 'en': [ - 'January', 'February', 'March', 'April', 'May', 'June', 'July', - 'August', 'September', 'October', 'November', 'December'], - }; - - var conversions = [ - ['%Y', date.getFullYear()], ['%m', zfill(date.getMonth(), 2)], - ['%B', months[lang][date.getMonth() - 1]], - ['%d', zfill(date.getDate(), 2)], ['%H', zfill(date.getHours(), 2)], - ['%H', zfill(date.getHours(), 2)], ['%M', zfill(date.getMinutes(), 2)], - ]; - - conversions.map(function(item) { fmt = fmt.replace(item[0], item[1]) }); - return fmt; - }; - var author = post['author'] || 'Anonymous'; if (post['website']) { author = '' + author + ''; @@ -163,7 +170,9 @@ function insert(thread, post) { $(post['parent'] ? '#isso_' + post['parent'] + ' > ul:last-child' : '#isso_thread > ul').append( '
' + '
' + author + '' + - '
' + post['text'] + + ' ' + + '
' + post['text'] + + '
' + '