inherit
186770
0
Jan 19, 2013 3:22:38 GMT -8
user07
193
December 2012
user07
|
Post by user07 on Mar 28, 2013 17:09:08 GMT -8
... just a silly question: does this script mean that the date for posts written yesterday would have 2 different ways of being displayed ( < 24 h. ago: whole date displayed; > 24 h. ago: just a 'yesterday')?
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 28, 2013 17:32:49 GMT -8
That depends on whether you implement the subsequent edits that were requested, the original poster wanted to get rid of all "ago" dates and see the full Monty while Merl wanted it to say "today". In either case "recent_time" is any time that calculates to an elapse of 23:59 or less so even if it technically occurred yesterday it won't say "yesterday" until 24 hours have passed at which time it loses its distinction of "recent_time"
|
|
inherit
186770
0
Jan 19, 2013 3:22:38 GMT -8
user07
193
December 2012
user07
|
Post by user07 on Mar 28, 2013 17:45:40 GMT -8
... In either case "recent_time" is any time that calculates to an elapse of 23:59 or less so even if it technically occurred yesterday it won't say "yesterday" until 24 hours have passed at which time it loses its distinction of "recent_time" ... Thanks! (that's exactly what I was asking: I wasn't that sure I figured it out correctly, now I am )
|
|
inherit
42808
0
Mar 24, 2021 15:38:57 GMT -8
mookman13
175
May 2005
mookman13
|
Post by mookman13 on Apr 7, 2013 14:10:11 GMT -8
replace $.datepicker.formatDate(user_date, raw_date) with 'Today'what part do I take out and add Today to?
|
|
inherit
42808
0
Mar 24, 2021 15:38:57 GMT -8
mookman13
175
May 2005
mookman13
|
Post by mookman13 on Apr 7, 2013 14:13:38 GMT -8
scratch that.. I got it...
|
|
inherit
42808
0
Mar 24, 2021 15:38:57 GMT -8
mookman13
175
May 2005
mookman13
|
Post by mookman13 on Apr 9, 2013 2:12:38 GMT -8
slight bug here hopefully someone can help me with....
thought everything was working fine.. but a post made last night 11:28 pm EST still is listed as today this morning (6:00 am EST) ..... anyone know how I can fix this bug??/
Thanks in advance....
|
|
inherit
164017
0
Apr 20, 2015 11:11:46 GMT -8
Football Buddah
7
February 2011
footballbuddah
|
Post by Football Buddah on May 2, 2013 4:34:02 GMT -8
slight bug here hopefully someone can help me with.... thought everything was working fine.. but a post made last night 11:28 pm EST still is listed as today this morning (6:00 am EST) ..... anyone know how I can fix this bug??/ Thanks in advance.... I am having the same issue. The code provided in previous posts worked great - initially - until this morning when I looked at posts made yesterday (within the last 24 hours) and they were still displaying as "Today". Short term - I remove the "Today" and replaced it back with "$.datepicker.formatDate(user_date, raw_date)". I can live with the date, but thought someone might want to look at that.
|
|
inherit
(?)?
188910
0
Jan 26, 2013 13:30:48 GMT -8
♥ ℒʊ√ ♥
Clouds float into my life no longer to carry rain or usher storm but to add color to my sunset sky.
10,458
January 2013
luv
|
Post by ♥ ℒʊ√ ♥ on Jun 7, 2013 20:40:14 GMT -8
|
|
inherit
22119
0
Aug 29, 2018 19:39:18 GMT -8
BeccaD
23
March 2004
beccad
|
Post by BeccaD on Jun 8, 2013 9:33:16 GMT -8
We're having the same issue as mookman13 and Football Buddah as well, where posts made late yesterday are showing up as "Today"
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jun 8, 2013 18:22:27 GMT -8
|
|
inherit
(?)?
188910
0
Jan 26, 2013 13:30:48 GMT -8
♥ ℒʊ√ ♥
Clouds float into my life no longer to carry rain or usher storm but to add color to my sunset sky.
10,458
January 2013
luv
|
Post by ♥ ℒʊ√ ♥ on Jun 8, 2013 18:27:13 GMT -8
|
|
soup
New Member
Posts: 123
inherit
soup.alvarado@gmail.com
194992
0
Nov 19, 2015 12:06:06 GMT -8
soup
123
June 2013
soup
|
Post by soup on Jul 1, 2013 13:13:21 GMT -8
bump
in our shoutbox it shows up great with the today then the time, but once it refreshes, it shows the date, military time, then -5 gmt
anyway to keep it from changing once it refreshes?(especially the military time part)
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Sept 15, 2013 10:32:26 GMT -8
bump in our shoutbox it shows up great with the today then the time, but once it refreshes, it shows the date, military time, then -5 gmt anyway to keep it from changing once it refreshes?(especially the military time part) I apologize for the late reply soup but I wasn't even aware of your post until someone tagged me in a reply to this thread yesterday then promptly deleted it. But thanks for the bug report since I never use a shoutbox so was unaware that timestamps in there were being affected and had not even considered a shoutbox when the code was written. This one was a bit tricky since Proboards offers no means to detect when a new shout appears which means I had to write a custom event emitter to detect such an event. The code below detects shoutbox posts and issues various custom events that will notify any code listening when AJAX activity is occurring in the shoutbox until Proboards gets around to adding such events. code:(new code in order to support shoutbox activities)<script type="text/javascript">
$(function(){ var shoutbox_messages = $('.shoutbox_messages') /* create custom shoutbox events * * most useful events would be "shoutbox_update" , "shoutbox_edit" and "shoutbox_add" * eventHandler = function(event,dataObject) * shout prop on dataObject would hold a jQuery array of last shout node if event had a payload * args prop on dataObject would hold a reference to the arguments from the AJAX request itself * all new shoutbox posts (since page load) is given class "shoutbox-new-post" * all new shoutbox posts (since page load) is given a .data("shoutinfo") which is same as data param in handler * events that carry a payload has namespace of "has-payload" else "empty" * events that occur in the send phase gets a namespace of "ajaxSend" else "ajaxComplete" */ shoutbox_messages.bind('ajaxComplete ajaxSend', function(ev,jxhr,inf){ if(inf.url && /shoutbox\/(\w+)/.test(inf.url)){ var data = {"args":arguments, shout:$()} inf.shoutEvent = RegExp.$1.replace(/\//g,"_"); inf.payload = $.parseJSON(jxhr.responseText)||{} var shouts = $(); var cev = 'shoutbox_'+ inf.shoutEvent + "." + ev.type; if((inf.payload.new_ids||[])[0]){ cev += ".has-payload"; var new_ids = $($.map(inf.payload.new_ids,function(e){return ".shoutbox-post-" + e + ' .details abbr.time';}).join(", "),this) new_ids.each(function(i,e){ var shout = $(this).closest('.shoutbox-post'), user = $('.user-link', shout).eq(0); if(shout.data("shoutinfo")) return; shoutbox_last = +inf.payload.new_ids[inf.payload.new_ids.length-1]; data.shout = shout; data.user = { url:user.attr("href"), name: proboards.escape_html(user.text()), username:user.attr("title").substr(1), group_ids: [String(user.attr('class').match(/(?:group-(\d+))/)[1])] } data.message = $('.message',shout).text(); data.user.id = data.user.url.split(/\//).pop(); shouts = shout.add(shouts); shout.data("shoutinfo",data); if(shouts.length == inf.payload.new_ids.length){ //new_ids.expire(arguments.callee); shoutbox_messages.trigger(cev, data); //namespaced shoutbox_messages.trigger(cev.split(/\./)[0], data); //no namespacing } }).closest('.shoutbox-post').addClass('shoutbox-new-post') }else{ //no new shouts then append an "empty" namespace shoutbox_messages.trigger(cev+".empty", data); //namespaced shoutbox_messages.trigger(cev.split(/\./)[0], data); //no namespacing } } }) })
</script>
The code above is a new helper code to assist in converting dates and times in the shoutbox The code below is a modified version of the code found in the first post of this thread and is meant to replace it. The modification allows it to use the shoutbox helper code above. code:(modified code from first post of this thread to be used with shoutbox code above)<script type="text/javascript">
/* Replace elapsed time with specific time (Sept 15, 2013) */ $(function(){ var a = 0, timeID = null, ac = arguments.callee, abbr = this.jquery? this : (this.ownerDocument ? $(this) : $('abbr.time')) for(; a < $.livequery.queries.length; a++){ if($.livequery.queries[a].selector == "abbr.time" && "function" == typeof $.livequery.queries[a].fn && $.livequery.queries[a].fn.toString().indexOf("non_mod_date") != -1) { timeID = $.livequery.queries[a]/*.id*/; $.livequery.stop(timeID.id);break; } } //$('abbr.time') abbr.each(function () { var time = $(this).addClass('modified_time').removeClass('time'), raw_date = new Date(parseInt(time.data("timestamp"),10)); if($(this).hasClass('recent_time') && !/yesterday/i.test($(this).text())){ time = time.removeClass('recent_time'); var today = raw_date.getDate() == (new Date()).getDate()?"today":"yesterday", user_date = ['M d, yy', 'd M, yy'][proboards.data("time_style") || 0]; time.replaceWith( $(this).clone(true).addClass('recent_time') .html( '<span class="'+today+'">'+today+' </span>' + '<span class="at">at</span> <span class="at-time">' + (proboards.data('military_time') ? $.formatTime('HH:mm', raw_date) : $.formatTime('h:mmp', raw_date)) +'</span>' ) ); }else if(/yesterday/i.test($(this).text())){ time.replaceWith( $(this).clone(true) .html( '<span class="yesterday">yesterday </span><span class="at">at </span><span class="at-time">' + $(this).text().split("at ")[1] +'</span>' ) ) }else{ if(time.text().indexOf(" at ")== -1) time.text($.datepicker.formatDate((proboards.data('time_style') ? 'd M yy' : 'M d, yy'), raw_date) + ' at ' + $.formatTime((proboards.data('military_time') ? 'HH:mm' : 'h:mmp'), raw_date)) time.replaceWith(function(){ for(var dt = time.text().split(" at")[0], a = dt.split(/,?\s+/), b=0, c = $('<span></span>'); b<a.length; b++){ if((d = a[b].match(/^(\d+)$/))){ if(d[1].length == 4) c.append('<span class="year">'+a[b]+' </span>').addClass("year_"+a[b]); else c.append('<span class="day">'+a[b]+' </span>').addClass("day_"+a[b]) }else{ c.append('<span class="month">'+a[b]+' </span>').addClass("month_"+a[b]) } } c.append('<span class="at">at </span>').append('<span class="at-time">' + time.text().split(" at ")[1] + '</span>') return time.clone(true).html('').append(c) }) }
}) $('abbr.modified_time').addClass('time'); //re-enable livequery treatment if(!ac.func){ ac.func = function(){ $.livequery.run(timeID.id); ac(); } } if(!ac.shoutbox){ ac.shoutbox = $('.shoutbox_messages') .on('shoutbox_update.has-payload', function(event,data){ if(data.shout.length){ data.shout.each(function(){ var time = $('abbr.time',this) timeID.fn.call(time); ac.call(time.addClass('recent_time')); }) } })} if($.inArray(ac.func, proboards.events.afterSearch) == -1){ proboards.on("afterSearch", ac.func); } })
</script>
I would appreciate any feedback you may offer especially since I had no access to any shoutbox that could be considered active/busy
|
|
soup
New Member
Posts: 123
inherit
soup.alvarado@gmail.com
194992
0
Nov 19, 2015 12:06:06 GMT -8
soup
123
June 2013
soup
|
Post by soup on Sept 20, 2013 9:25:02 GMT -8
ChrisI'm just a rookie at this code stuff. I would need to put both sets of codes on the style sheet? If so, can you point me to where haha? Thanks for all your help.
|
|
soup
New Member
Posts: 123
inherit
soup.alvarado@gmail.com
194992
0
Nov 19, 2015 12:06:06 GMT -8
soup
123
June 2013
soup
|
Post by soup on Sept 20, 2013 9:41:22 GMT -8
scratch that, i put both in the footer and it works like a freaking champ.
the-mainboard.proboards.com
here's the site if you want to check it out. i'm pretty sure you should be able to look at it.
thanks for all your time and effort.
|
|