Hello I need to take the variable hours and split it into hours and minutes and concatenate the variables as strings. I have done so in Java, I am just not sure how to manipulate this script:
javascript/AJAX
function updateDistances(item) {
try {
var prev = $($(item).prevAll('li:not(.show_placeholder):first'));
if (prev != undefined && !$(prev).hasClass('temp_placeholder')) {
calcRoute(prev, $(item));
}
} catch(e) {
log(e);
}
try {
var next = $($(item).nextAll('li:not(.show_placeholder):first'));
if (next == undefined || $(next).hasClass('temp_placeholder')) {
$($(item).find('span.drive_time')[0]).text(hours.toString().substring(0, 4) + ' h' + ' :' + ' m');
$($(item).find('span.drive_miles')[0]).text('0.0 mi');
$(item).find('select.transfer').val('');
} else {
calcRoute($(item), next);
}
} catch(e) {
log(e);
}
}
It was done in the Java file, but I cannot figure out how to do it with the Javascript / AJAX above.
Java file:
HtmlElement span = new HtmlElement(SPAN_OPEN, SPAN_CLOSE);
span.setValue("Drive Time: ");
td.addNestedElement(span);
HtmlElement span2 = new HtmlElement(SPAN_OPEN, SPAN_CLOSE);
span2.addAttribute("class", "drive_time");
double TransferHours = showSet.getTransferHours();
int hours = (int) TransferHours;
int minutes = (int) ((TransferHours - hours) * 60);
String s = hours + ":" + minutes;
s = s.replace('.', ':');
s = s + " " + "h:m";
span2.setValue(s);
System.out.println(s);
td.addNestedElement(span2);
tr.addNestedElement(td);
return tr;