More work on polls and themes

This commit is contained in:
Daisuke 2020-04-21 20:53:40 -05:00
parent f59049c3c2
commit 2c7a8e1da4
4 changed files with 62 additions and 2 deletions

21
css/post.txt Normal file
View File

@ -0,0 +1,21 @@
<div class='element'>
<div class='avatar' style='background-image:url(:avatar:) :style:'></div>
<div class='post' id=':id:' pid=':pid:'>
<div id='a:id:' class='ancestors'>:ancestors:</div>
<div class='postHeader'>
<span style='margin:5px; display:block; float:left; line-height:30px;'><img src=':avatar:' width=30 class='mobile' style='vertical-align:middle; border-radius:30px'> :name: :rt: </span>
<span style="margin-top:12px; margin-right:10px; float:right; display:block;">
<span class='postMenu fontello'>&#xf0c9;<div style='display:none; z-index:99; width:130px; position: absolute; top: 15px; right: -1px;' class='menu'>:menu:</div></span>
</span>
</div>
:spoiler:
<div class='media' style='text-align:center;'>:media:</div>
<div class='postbody'><div class='content' style='margin-bottom:5px;'>
:replyto: :text:
</div></div>
<div class='post_footer'>:footer:</DIV>
<div class='post_notes'>:notes:</DIV>
<div id=':id:' class='replies_container'><noscript>:form:</noscript>:descendants:</div>
</div>
<script type='application/json' id='data-:id:'>:json:</script>
</div>

View File

@ -284,7 +284,7 @@ function render_reply($item) {
$unlisted = "&#xe816;"; $unlisted = "&#xe816;";
$direct = "&#xf0e0;"; $direct = "&#xf0e0;";
$reply['date'] = "<a class='ldr' style='text-decoration:none;' target='_blank' href='?thread=" . $item['id'] . "&instance=$srv" . "'>" . time_elapsed_string($item['created_at']) . "</a> - <span class='fontello'>" . $$item['visibility'] . "</span>"; $reply['date'] = "<a class='ldr postAge' id='".strtotime($item['created_at'])."' style='text-decoration:none;' target='_blank' href='?thread=" . $item['id'] . "&instance=$srv" . "'>" . time_elapsed_string($item['created_at']) . "</a> - <span class='fontello'>" . $$item['visibility'] . "</span>";
$reply['media'] = ""; $reply['media'] = "";
if (!empty($item['media_attachments'])) { if (!empty($item['media_attachments'])) {

View File

@ -424,6 +424,11 @@ function newPosts() {
}; };
window.setInterval(function() { window.setInterval(function() {
var timestamp;
$('.postAge').each(function(a){
timestamp = $(this).attr('id');
$(this).html(timeSince(timestamp)+' ago');
});
newPosts(); newPosts();
}, 25000); }, 25000);
@ -477,3 +482,37 @@ function themecheck(name){
$('#customtheme').css("display","none"); $('#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";
}

View File

@ -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 */ /* the code of the post footer (date, visibility and like/reblog buttons */
$post['footer'] = "<div style='float:left;'> $post['footer'] = "<div style='float:left;'>
<a style='text-decoration:none;' class='ldr' target='_blank' href='?thread=" . $elem['id'] . "&instance=$srv" . "' title='".gmdate("d/m/y H:i", strtotime($elem['created_at']))."'>" .time_elapsed_string($elem['created_at']) . "</a> - <span class='fontello'>" . $$elem['visibility'] . " </span> <a style='text-decoration:none;' class='ldr postAge' id='".strtotime($elem['created_at'])."' target='_blank' href='?thread=" . $elem['id'] . "&instance=$srv" . "' title='".gmdate("d/m/y H:i", strtotime($elem['created_at']))."'>" .time_elapsed_string($elem['created_at']) . "</a> - <span class='fontello'>" . $$elem['visibility'] . " </span>
</div> </div>
<div class='post_buttons' id='" . $elem['id'] . "'> <div class='post_buttons' id='" . $elem['id'] . "'>
" . ($logedin ? "<div class='felem'><a onClick='return false' class='replyform' href='?thread=" . $elem['id'] . "' style='font-family:fontello; vertical-align:middle;' alt='reply'>&#xf112;</a></div>" : "") . " " . ($logedin ? "<div class='felem'><a onClick='return false' class='replyform' href='?thread=" . $elem['id'] . "' style='font-family:fontello; vertical-align:middle;' alt='reply'>&#xf112;</a></div>" : "") . "