diff --git a/css/post.txt b/css/post.txt new file mode 100644 index 0000000..c8bff44 --- /dev/null +++ b/css/post.txt @@ -0,0 +1,21 @@ +
+
+
+
:ancestors:
+
+ :name: :rt: + + + +
+ :spoiler: +
:media:
+
+ :replyto: :text: +
+ +
:notes:
+
:descendants:
+
+ +
diff --git a/include/functions.php b/include/functions.php index b326fd9..2ff4501 100644 --- a/include/functions.php +++ b/include/functions.php @@ -284,7 +284,7 @@ function render_reply($item) { $unlisted = ""; $direct = ""; - $reply['date'] = "" . time_elapsed_string($item['created_at']) . " - " . $$item['visibility'] . ""; + $reply['date'] = "" . time_elapsed_string($item['created_at']) . " - " . $$item['visibility'] . ""; $reply['media'] = ""; if (!empty($item['media_attachments'])) { diff --git a/js/scripts.js b/js/scripts.js index 6748738..fc2c47a 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -424,6 +424,11 @@ function newPosts() { }; window.setInterval(function() { + var timestamp; + $('.postAge').each(function(a){ + timestamp = $(this).attr('id'); + $(this).html(timeSince(timestamp)+' ago'); + }); newPosts(); }, 25000); @@ -477,3 +482,37 @@ function themecheck(name){ $('#customtheme').css("display","none"); } }; + + +function timeSince(date) { + /* https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site */ + + var seconds = Math.floor((new Date() - (date*1000)) / 1000); + + var interval = Math.floor(seconds / 31536000); + + if (interval >= 1) { + return interval + " years"; + } + interval = Math.floor(seconds / 2592000); + if (interval >= 1) { + return interval + " months"; + } + interval = Math.floor(seconds / 604800); + if (interval >= 1) { + return interval + " weeks"; + } + interval = Math.floor(seconds / 86400); + if (interval >= 1) { + return interval + " days"; + } + interval = Math.floor(seconds / 3600); + if (interval >= 1) { + return interval + " hours"; + } + interval = Math.floor(seconds / 60); + if (interval >= 1) { + return interval + " minutes"; + } + return Math.floor(seconds) + " seconds"; +} \ No newline at end of file diff --git a/modules/timeline.php b/modules/timeline.php index 4375ab2..582dc65 100644 --- a/modules/timeline.php +++ b/modules/timeline.php @@ -292,7 +292,7 @@ if ((!isset($thread[0]['id']) && !empty($thread)) || !is_array($thread)) { /* the code of the post footer (date, visibility and like/reblog buttons */ $post['footer'] = "
- " .time_elapsed_string($elem['created_at']) . " - " . $$elem['visibility'] . " + " .time_elapsed_string($elem['created_at']) . " - " . $$elem['visibility'] . "
" . ($logedin ? "
" : "") . "