Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Jul 24, 2014 22:03:03 GMT -8
First it loops through and assigns each timestamp
Second it Sorts it by Largest Number First
Third it loops through and appends the data
$( document ).ready(function() {
var intelOutput = pb.plugin.get('intel');
for(a=0;a<intelOutput.settings.intel.length;a++)
{
var year = intelOutput.settings.intel.intel_date.split('/')[2]
var month = intelOutput.settings.intel.intel_date.split('/')[1]
var day = intelOutput.settings.intel.intel_date.split('/')[0]
var hours = intelOutput.settings.intel.intel_time.split(':')[0]
var minutes = intelOutput.settings.intel.intel_time.split(':')[1]
var seconds = intelOutput.settings.intel.intel_time.split(':')[2]
intelOutput.settings.intel.timestamp=new Date(year,month,day,hours,minutes,seconds, 0).getTime()
}
intelOutput.settings.intel.sort(function(a, b){return parseFloat(b.timestamp)-parseFloat(a.timestamp)});
for(index=0;index<intelOutput.settings.intel.length;index++){
$('div#intel').append('<div style="width: 98%;padding: 3px; text-align: justify;border-bottom: 1px solid #84341E;"><div style="float: right; font-size: 8pt !important;"><abbr class="time" data-timestamp="' +intelOutput.settings.intel[index].timestamp+'"></abbr></div><div style="clear: both;"></div>'+intelOutput.settings.intel[index].input+'</div> '); }
});
The original code I have works, it's just posting it on here wasn't working. I should have used this:
$( document ).ready(function() {
var intelOutput = pb.plugin.get('intel');
for(a=0;a<intelOutput.settings.intel.length;a++)
{
var year = intelOutput.settings.intel[a].intel_date.split('/')[2]
var month = intelOutput.settings.intel[a].intel_date.split('/')[1]
var day = intelOutput.settings.intel[a].intel_date.split('/')[0]
var hours = intelOutput.settings.intel[a].intel_time.split(':')[0]
var minutes = intelOutput.settings.intel[a].intel_time.split(':')[1]
var seconds = intelOutput.settings.intel[a].intel_time.split(':')[2]
intelOutput.settings.intel[a].timestamp=new Date(year,month,day,hours,minutes,seconds, 0).getTime()
}
intelOutput.settings.intel.sort(function(a, b){return parseFloat(b.timestamp)-parseFloat(a.timestamp)});
for(index=0;index<intelOutput.settings.intel.length;index++){
$('div#intel').append('<div style="width: 98%;padding: 3px; text-align: justify;border-bottom: 1px solid #84341E;"><div style="float: right; font-size: 8pt !important;"><abbr class="time" data-timestamp="' +intelOutput.settings.intel[index].timestamp+'"></abbr></div><div style="clear: both;"></div>'+intelOutput.settings.intel[index].input+'</div> '); }
});