Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions javascripts/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i+1);
if ((ch < "0" || "9" < ch) && ch != '.') {
alert("Only numeric input is allowed!\n\n"
+ parseFloat(ok) + " will be used because '"
+ str + "' is invalid.\nYou may correct "
alert("Template '<hours>h <minutes>m' or numeric input is allowed!\n\n"
+ "'" + str + "' is invalid.\nYou may correct "
+ "this entry and try again.");
return parseFloat(ok);
}
Expand All @@ -197,6 +196,26 @@
}

function makeTime(value) {
var str = $.trim(value);
if (str.length > 0 && str.match(/^(\d{1,2}h{1}(\s*[0-5]?\d{1})?)?(\s*[0-5]?\d{1}m{1})?$/i)) {
var arr = str.split(' ');
arr = arr.filter(function(e){return e});
var res = "";
if (arr[0].charAt(arr[0].length - 1) == 'h') {
res = leftPad(arr[0].substr(0, arr[0].length - 1), 2);
arr.splice(0, 1);
} else {
res = "00"
}
if (arr.length > 0 && arr[0].charAt(arr[0].length - 1) == 'm') {
res = res + ":" + leftPad(arr[0].substr(0, arr[0].length - 1), 2);
arr.splice(0, 1);
} else {
res = res + ":00"
}
res = res + ":00"
return res;
}
var num = (checkDecimal(value)); // validates input
if (num) {
var hour = parseInt(num);
Expand Down