Commit b42f1e58 authored by Robert Ricci's avatar Robert Ricci

Change expiration display to use moment.js

This produces a much nicer display. We really need to stop setting the
same fields in PHP and JS, though, this is a real nightmare.
parent 2a806f3c
......@@ -16,6 +16,7 @@ window.APT_OPTIONS.config = function ()
'tablesorter': 'js/lib/jquery.tablesorter.min',
'tablesorterwidgets': 'js/lib/jquery.tablesorter.widgets.min',
'marked': 'js/lib/marked',
'moment': 'js/lib/moment',
},
shim: {
'bootstrap': { deps: ['jquery'] },
......
This diff is collapsed.
window.APT_OPTIONS.config();
require(['jquery', 'js/quickvm_sup',
'tablesorter', 'tablesorterwidgets', 'bootstrap'],
function ($, sup)
require(['jquery', 'js/quickvm_sup', 'moment',
'tablesorter', 'tablesorterwidgets', 'bootstrap' ],
function ($, sup, moment)
{
'use strict';
var CurrentTopo = null;
......@@ -236,8 +236,7 @@ function ($, sup)
// Reformat in local time and show the user.
var local_date = new Date(when);
var local_string = local_date.format("yyyy-mm-dd HH:MM:ss Z");
$("#quickvm_expires").html(local_string);
$("#quickvm_expires").html(moment(local_date).calendar());
// Countdown also based on local time.
target_date = local_date.getTime();
......@@ -339,7 +338,7 @@ function ($, sup)
sup.SpitOops("oops", message);
return;
}
$("#quickvm_expires").html(json.value);
$("#quickvm_expires").html(moment(json.value).calendar());
// Reset the countdown clock.
StartCountdownClock.reset = json.value;
......
......@@ -194,6 +194,8 @@ $slice_expires = "n/a";
if (isset($slice)) {
$slice_urn = $slice->urn();
$slice_expires = gmdate("Y-m-d\TH:i:s\Z", strtotime($slice->expires()));
# Simpler version for directly displaying
$slice_expires_text = gmdate("m-d\TH:i\Z", strtotime($slice->expires()));
}
$instance_status = $instance->status();
$creator_uid = $creator->uid();
......@@ -271,7 +273,7 @@ echo "</tr>\n";
echo "<tr>\n";
echo "<td class='uk-width-1-5' $style>Expires:</td>\n";
echo "<td class='uk-width-4-5' $style>
<span id='quickvm_expires'>$slice_expires</span> - Time left:
<span id='quickvm_expires'>$slice_expires_text</span> - Time left:
<span id='quickvm_countdown'></span></td>\n";
echo "</tr>\n";
echo "</table>\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment