Commit a2b46609 authored by robbertv's avatar robbertv

Fixed bug in format.js and changed the type to match the module name.

parent aa7ceb45
......@@ -23,7 +23,12 @@ function formatTimeField(f,numDecimals){
if(!theTime) {
return;
}
// Check if the user entered a time as m:ss, with no fraction of a second.
// If so, the time will be updated to include the fraction.
if(theTime.match(/^\d?\d:\d\d$/)) {
theTime += '.' + Array(numDecimals + 1).join(0)
}
// Remove any periods and colons from theTime using a regular expression
// the regular expression is
//
......@@ -45,9 +50,7 @@ function formatTimeField(f,numDecimals){
// Create a regular expression that will test for non numeric characters.
var regEx = new RegExp("\\D");
// If the number has any non numeric characters in it
// or if the number is longer then 6 characters, then
// If the number has any non numeric characters in it, then
// an invalid time was entered.
if(regEx.test(theTime)) {
// Display an alert that the time is invalid.
......@@ -58,6 +61,11 @@ function formatTimeField(f,numDecimals){
return false;
}
// If the length of the time entered is less then the number of decimals
// plus one, format the time a little differently
else if( theTime.length <= numDecimals + 1) {
theTime = theTime / Math.pow(10,numDecimals);
}
// Otherwise, format the time.
else {
// Get the decimal portion of the time by getting
......@@ -87,11 +95,10 @@ function formatTimeField(f,numDecimals){
// Add the minutesPart, the secondsPart a period and the decimalsPart.
theTime = minutesPart + secondsPart + "." + decimalsPart;
// Set the form field value to theTime.
f.value = theTime;
return true;
}
// Set the form field value to theTime.
f.value = theTime;
return true;
}
......@@ -49,7 +49,7 @@ function racetime_form_process($element) {
function racetime_field_info() {
return array(
'racetime' => array(
'label' => t('Time'),
'label' => t('Race Time'),
'description' => t('Time in format mm:ss.00'),
'settings' => array(),
'instance_settings' => array(
......@@ -82,7 +82,7 @@ function racetime_field_instance_settings_form($field, $instance) {
function racetime_field_widget_info() {
return array(
'racetime_default_widget' => array(
'label' => t('Time Field'),
'label' => t('Racetime Field'),
'field types' => array(
'racetime',
),
......@@ -122,7 +122,7 @@ function racetime_field_widget_form(& $form, &$form_state, $field, $instance, $l
);
if (!isset ($widget['description']) || !strlen($widget['description'])) {
$widget['#description'] = t('Add description here');
$widget['#description'] = t('Enter the race time here');
}
if (!isset ($widget['#process'])) {
$widget['#process'] = array();
......@@ -144,7 +144,7 @@ function racetime_field_widget_form(& $form, &$form_state, $field, $instance, $l
function racetime_field_formatter_info() {
return array(
'racetime_default_formatter' => array(
'label' => t('Time'),
'label' => t('Racetime'),
'field types' => array(
'racetime',
),
......@@ -190,7 +190,11 @@ function racetime_field_formatter_settings_form($field, $instance, $view_mode, $
function racetime_help($path, $arg) {
switch ($path) {
case "admin/help#racetime":
return '<p>' . t("A field for recording a race time in the format m:ss.00") . '</p>';
$helpfile = drupal_get_path('module','racetime') . '/README.txt';
$text = '<pre>' . file_get_contents($helpfile) . '</pre>';
return $text;
break;
}
}
......@@ -205,7 +209,6 @@ function racetime_field_formatter_view($entity_type, $entity, $field, $instance,
$element[$delta]['#theme'] = 'racetime';
$element[$delta]['#time'] = $item['time'];
$element[$delta]['#number_decimals'] = $instance['settings']['number_decimals'];
}
}
......
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