summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-09-01 08:58:59 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-09-01 08:58:59 -0700
commit860585e6b4fe8d80297c5f1a566746ddbb046a1b (patch)
treea788731fd77720c3faeef82900890f84c0190290
parent095d1a727911a8b5d15021ec55d31103490bfb5f (diff)
Added hours, minutes, seconds calculation to training page
-rw-r--r--src/templates/macros/hms.ftl13
-rw-r--r--src/templates/templates/training.ftl3
2 files changed, 15 insertions, 1 deletions
diff --git a/src/templates/macros/hms.ftl b/src/templates/macros/hms.ftl
new file mode 100644
index 0000000..f9662af
--- /dev/null
+++ b/src/templates/macros/hms.ftl
@@ -0,0 +1,13 @@
+<#macro hms seconds>
+ <#assign h = (seconds / 3600)?int />
+ <#assign m = (seconds % 3600 / 60)?int />
+ <#assign s = (seconds % 3600 % 60)?int />
+
+ <#if (seconds >= 3600)>
+ ${h}:${m}:${s}
+ <#elseif (seconds >= 60)>
+ ${m}:${s}
+ <#else>
+ ${s} seconds
+ </#if>
+</#macro>
diff --git a/src/templates/templates/training.ftl b/src/templates/templates/training.ftl
index 0490a9a..a6d30ea 100644
--- a/src/templates/templates/training.ftl
+++ b/src/templates/templates/training.ftl
@@ -1,5 +1,6 @@
<#include "/macros/common.ftl">
<#include "/macros/common-page.ftl">
+<#include "/macros/hms.ftl">
<@commonpage>
<@noticebox>
@@ -37,7 +38,7 @@
<#list videos as video>
<article>
<div class="image <#if video.completed>completed</#if>" id="${video.id}"><a href="#" onclick="playVideo('${video.id}'); return false"><img src="${video.image!staticRoot+"/images/videoimage.jpg"}" alt="${video.title}" /></a></div>
- <h2>${video.title}</h2> <span class="duration">${video.length}</span>
+ <h2>${video.title}</h2> <span class="duration"><@hms seconds=video.length /></span>
</article>
</#list>
</div>