Calendar improvements: add submit button (bug# 1312373) and fix entering time begining with 0 (bug #1312373).

This commit is contained in:
Michal Čihař
2005-10-06 09:23:58 +00:00
parent f58e0ae0ff
commit 102066c088
3 changed files with 30 additions and 5 deletions

View File

@@ -9,6 +9,9 @@ $Source$
* import.php: Correctly report that file could not be read.
* libraries/import/sql.php: Fix handling of whitespace at the end of
imported file.
* calendar.php, libraries/tbl_change.js: Calendar improvements: add submit
button (bug# 1312373) and fix entering time begining with 0 (bug
#1312373).
2005-10-05 Marc Delisle <lem9@users.sourceforge.net>
* db_details_structure.php, tbl_properties_table_info.php: detect

View File

@@ -58,6 +58,7 @@ if (!empty($GLOBALS['cfg']['PmaAbsoluteUri'])) {
<!--
var month_names = new Array("<?php echo implode('","', $month); ?>");
var day_names = new Array("<?php echo implode('","', $day_of_week); ?>");
var submit_text = "<?php echo $strGo; ?>";
//-->
</script>
</head>

View File

@@ -95,6 +95,7 @@ function openCalendar(params, form, field, type) {
* Formats number to two digits.
*
* @param int number to format.
* @param string type of number
*/
function formatNum2(i, valtype) {
f = (i < 10 ? '0' : '') + i;
@@ -123,12 +124,26 @@ function formatNum2(i, valtype) {
return f;
}
/**
* Formats number to two digits.
*
* @param int number to format.
* @param int default value
* @param string type of number
*/
function formatNum2d(i, default_v, valtype) {
i = parseInt(i, 10);
if (isNaN(i)) return default_v;
return formatNum2(i, valtype)
}
/**
* Formats number to four digits.
*
* @param int number to format.
*/
function formatNum4(i) {
i = parseInt(i, 10)
return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i;
}
@@ -251,12 +266,13 @@ function initCalendar() {
dispmonth = 1 + month;
if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
actVal = formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day');
actVal = "" + formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day');
} else {
actVal = "" + formatNum4(year) + formatNum2(dispmonth, 'month') + formatNum2(i, 'day');
}
if (i == day) {
style = ' class="selected"';
current_date = actVal;
} else {
style = '';
}
@@ -281,10 +297,15 @@ function initCalendar() {
}
str = '';
str += '<form class="clock">';
str += '<input id="hour" type="text" size="2" maxlength="2" onblur="this.value=formatNum2(this.value, \'hour\')" value="' + formatNum2(hour, 'hour') + '" />:';
str += '<input id="minute" type="text" size="2" maxlength="2" onblur="this.value=formatNum2(this.value, \'minute\')" value="' + formatNum2(minute, 'minute') + '" />:';
str += '<input id="second" type="text" size="2" maxlength="2" onblur="this.value=formatNum2(this.value, \'second\')" value="' + formatNum2(second, 'second') + '" />';
init_hour = hour;
init_minute = minute;
init_second = second;
str += '<form method="NONE" class="clock" onsubmit="returnDate(\'' + current_date + '\')">';
str += '<input id="hour" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_hour, \'hour\'); init_hour = this.value;" value="' + formatNum2(hour, 'hour') + '" />:';
str += '<input id="minute" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_minute, \'minute\'); init_minute = this.value;" value="' + formatNum2(minute, 'minute') + '" />:';
str += '<input id="second" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_second, \'second\'); init_second = this.value;" value="' + formatNum2(second, 'second') + '" />';
str += '<br />';
str += '<input type="submit" value="' + submit_text + '"/>';
str += '</form>';
cnt.innerHTML = str;