OW2 Consortium telosys

Rev

Blame | Last modification | View Log | RSS feed

//------------------------------------------------------------------------------
// Picto_func.js  
// Functions set to managed the field picto actions ( Date Picker, Pick List, ... )
//------------------------------------------------------------------------------

//--------------------------------------------------------------------
// Return the field object associated with the given picto object 
// field.id = "foo" => picto.id = "foo_picto"
//--------------------------------------------------------------------
function fwkGetFieldForPicto(oPicto)
{
  if ( oPicto == null )
  {
    alert("ERROR : fwkGetFieldForPicto(picto) : picto object is null ");
    return null ;
  }
  var sPictoId = oPicto.id ;
  if ( sPictoId == null )
  {
    alert("ERROR : fwkGetFieldForPicto(picto) : picto.id is null ");
    return null ;
  }
  var i = sPictoId.lastIndexOf("_picto");
  if ( i <= 0 )
  {
    alert("ERROR : fwkGetFieldForPicto(picto) : invalid picto.id '" + sPictoId + "' ( xx_picto expected ) ! " );
    return null ;
  }
  var sFieldId = sPictoId.substring(0, i);
  //alert("fwkGetFieldForPicto : \n picto id = " + sPictoId + " \n field id = " + sFieldId );
  var oField = document.getElementById(sFieldId);
  if ( oField == null )
  {
    alert("ERROR : fwkGetFieldForPicto(picto) : field '" + sFieldId + "' not found ");
  }
  return oField ;
}
//--------------------------------------------------------------------
function fwkSetPictoFieldValue(oPicto, sValue)
{
  var oField = fwkGetFieldForPicto(oPicto);
  if ( oField != null )
  {
    oField.value = sValue ;
  }
}
//--------------------------------------------------------------------
function fwkDatePicker(oPicto)
{
  //--- 1) Call any Date Picker that returns a selected date in ISO format
  alert("Show the calendar ..." );
  var sSelectedDate = "2001-03-25" ;
  
  //--- 2) Call the date formater
  // TODO 
  var sFormatedDate = "25/03/2001" ; 
  
  //--- 3) Set the formated date in the field
  fwkSetPictoFieldValue(oPicto, sFormatedDate);
/**
  var oField = fwkGetFieldForPicto(oPicto);
  if ( oField != null )
  {
    oField.value = sFormatedDate ;
  }
**/
}
//--------------------------------------------------------------------
function fwkPickList(oPicto)
{
  //--- 1) Call any "Pick List" that returns a value
  alert("Show the pick list ..." );
  var sValue = "The value" ;
  
  //--- 2) Set the value in the field
  fwkSetPictoFieldValue(oPicto, sValue);
  /**
  var oField = fwkGetFieldForPicto(oPicto);
  if ( oField != null )
  {
    oField.value = sValue ;
  }
  **/
}
//--------------------------------------------------------------------

Generated by GNU enscript 1.6.4.