diff --git a/swad_action.c b/swad_action.c
index 12adf0395..4681bcce2 100644
--- a/swad_action.c
+++ b/swad_action.c
@@ -4267,14 +4267,36 @@ void Act_LinkFormSubmit (const char *Title,const char *LinkStyle)
// Id can not be NULL
void Act_LinkFormSubmitId (const char *Title,const char *LinkStyle,const char *Id)
{
- fprintf (Gbl.F.Out,"");
+ fprintf (Gbl.F.Out," onclick=\"javascript:"
+ "document.getElementById('%s').submit();return false;\">",
+ Id);
+ }
+
+void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle,
+ const char *StaticIconId,
+ const char *AnimatedIconId)
+ {
+ fprintf (Gbl.F.Out,"",
+ StaticIconId, // Icon to be hiden on click
+ AnimatedIconId, // Icon to be shown on click
+ Gbl.FormId);
}
/*****************************************************************************/
diff --git a/swad_action.h b/swad_action.h
index 577efebe3..a04f914e5 100644
--- a/swad_action.h
+++ b/swad_action.h
@@ -1336,6 +1336,9 @@ void Act_FormStartId (Act_Action_t NextAction,const char *Id);
void Act_FormEnd (void);
void Act_LinkFormSubmit (const char *Title,const char *LinkStyle);
void Act_LinkFormSubmitId (const char *Title,const char *LinkStyle,const char *Id);
+void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle,
+ const char *StaticIconId,
+ const char *AnimatedIconId);
void Act_AdjustActionWhenNoUsrLogged (void);
void Act_AdjustCurrentAction (void);
Act_Action_t Act_GetFirstActionAvailableInCurrentTab (void);
diff --git a/swad_changelog.h b/swad_changelog.h
index e2a704ba1..e0bad8157 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -103,11 +103,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 14.89 (2015/03/13)"
+#define Log_PLATFORM_VERSION "SWAD 14.90 (2015/03/13)"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
+ Version 14.90: Mar 13, 2015 Animated gif icon when calculating user's figures.
+ Changes in all submit links. (181826 lines)
+ Version 14.89.1: Mar 13, 2015 Optimization in database query for first click time. (181771 lines)
Version 14.89: Mar 13, 2015 Lots of changes related with forms and photos. (181769 lines)
Version 14.88: Mar 12, 2015 Changes in layout of public user profile. (181718 lines)
Version 14.87.4: Mar 11, 2015 Added indexes to usr_figures. (181629 lines)
diff --git a/swad_layout.c b/swad_layout.c
index 6fed93ac6..951f90028 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -979,6 +979,25 @@ void Lay_PutSendIcon (const char *Icon,const char *Alt,const char *Text)
Gbl.Prefs.IconsURL,Icon,Alt,Text);
}
+/*****************************************************************************/
+/********** Put a icon with a text to submit a form. **********/
+/********** When clicked, the icon will be replaced by an animation **********/
+/*****************************************************************************/
+
+void Lay_PutCalculateIcon (const char *Alt,const char *Text,
+ const char *StaticIconId,
+ const char *AnimatedIconId)
+ {
+ fprintf (Gbl.F.Out,""
+ "" // Animated icon hidden
+ " %s",
+ StaticIconId,Gbl.Prefs.IconsURL,Alt,
+ AnimatedIconId,Gbl.Prefs.IconsURL,Alt,
+ Text);
+ }
+
/*****************************************************************************/
/********************** Put a button to submit a form ************************/
/*****************************************************************************/
diff --git a/swad_layout.h b/swad_layout.h
index a6ccf0b33..b8a939bd7 100644
--- a/swad_layout.h
+++ b/swad_layout.h
@@ -89,6 +89,9 @@ void Lay_WriteTitle (const char *Title);
void Lay_PutFormToView (Act_Action_t Action);
void Lay_PutFormToEdit (Act_Action_t Action);
void Lay_PutSendIcon (const char *Icon,const char *Alt,const char *Text);
+void Lay_PutCalculateIcon (const char *Alt,const char *Text,
+ const char *StaticIconId,
+ const char *AnimatedIconId);
void Lay_PutSendButton (const char *TextSendButton);
void Lay_StartRoundFrameTable10 (const char *Width,unsigned CellPadding,const char *Title);
void Lay_StartRoundFrameTable10Shadow (const char *Width,unsigned CellPadding);
diff --git a/swad_user.c b/swad_user.c
index a875a3dcb..40a803d2d 100644
--- a/swad_user.c
+++ b/swad_user.c
@@ -7708,8 +7708,10 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
/***** Button to fetch and store first click time *****/
Act_FormStart (ActCal1stClkTim);
Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod);
- Act_LinkFormSubmit (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme]);
- Lay_PutSendIcon ("recycle",Txt_Calculate,Txt_Calculate);
+ Act_LinkFormSubmitAnimated (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme],
+ "calculate1","calculating1");
+ Lay_PutCalculateIcon (Txt_Calculate,Txt_Calculate,
+ "calculate1","calculating1");
Act_FormEnd ();
}
fprintf (Gbl.F.Out,""
@@ -7753,8 +7755,10 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
/***** Button to fetch and store number of clicks *****/
Act_FormStart (ActCalNumClk);
Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod);
- Act_LinkFormSubmit (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme]);
- Lay_PutSendIcon ("recycle",Txt_Calculate,Txt_Calculate);
+ Act_LinkFormSubmitAnimated (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme],
+ "calculate2","calculating2");
+ Lay_PutCalculateIcon (Txt_Calculate,Txt_Calculate,
+ "calculate2","calculating2");
Act_FormEnd ();
}
fprintf (Gbl.F.Out,""
@@ -7789,8 +7793,10 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
/***** Button to fetch and store number of forum posts *****/
Act_FormStart (ActCalNumForPst);
Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod);
- Act_LinkFormSubmit (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme]);
- Lay_PutSendIcon ("recycle",Txt_Calculate,Txt_Calculate);
+ Act_LinkFormSubmitAnimated (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme],
+ "calculate3","calculating3");
+ Lay_PutCalculateIcon (Txt_Calculate,Txt_Calculate,
+ "calculate3","calculating3");
Act_FormEnd ();
}
fprintf (Gbl.F.Out,""
@@ -7825,8 +7831,10 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
/***** Button to fetch and store number of messages sent *****/
Act_FormStart (ActCalNumMsgSnt);
Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod);
- Act_LinkFormSubmit (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme]);
- Lay_PutSendIcon ("recycle",Txt_Calculate,Txt_Calculate);
+ Act_LinkFormSubmitAnimated (Txt_Calculate,The_ClassFormul[Gbl.Prefs.Theme],
+ "calculate4","calculating4");
+ Lay_PutCalculateIcon (Txt_Calculate,Txt_Calculate,
+ "calculate4","calculating4");
Act_FormEnd ();
}
fprintf (Gbl.F.Out,""
@@ -8017,8 +8025,9 @@ static void Usr_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
Usr_ResetUsrFigures (&UsrFigures);
/***** Get first click from log table *****/
- sprintf (Query,"SELECT DATE_FORMAT(ClickTime,'%%Y%%m%%d%%H%%i%%S') FROM log"
- " WHERE UsrCod='%ld' ORDER BY ClickTime LIMIT 1",
+ sprintf (Query,"SELECT DATE_FORMAT("
+ "(SELECT MIN(ClickTime) FROM log WHERE UsrCod='%ld')"
+ ",'%%Y%%m%%d%%H%%i%%S')",
UsrCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's first click"))
{
@@ -8026,8 +8035,9 @@ static void Usr_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
row = mysql_fetch_row (mysql_res);
/* Get first click (row[0] holds the start date in YYYYMMDDHHMMSS format) */
- if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(UsrFigures.FirstClickTime),row[0])))
- Lay_ShowErrorAndExit ("Error when reading first click time.");
+ if (row[0]) // It is NULL when user never logged
+ if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(UsrFigures.FirstClickTime),row[0])))
+ Lay_ShowErrorAndExit ("Error when reading first click time.");
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);