diff --git a/css/swad15.105.css b/css/swad15.105.css index 78217a158..431cae13b 100644 --- a/css/swad15.105.css +++ b/css/swad15.105.css @@ -1668,14 +1668,14 @@ a:hover img.CENTRE_PHOTO_SHOW .LOG_R {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:red; font-size:11pt;} /******************************** Social activity ****************************/ -#view_new_posts_container +#view_new_posts_container,#view_old_posts_container { display:table-cell; height:50px; text-align:center; vertical-align:middle; } -#recent_timeline_list +#new_timeline_list { display:none; } diff --git a/js/swad15.105.js b/js/swad15.106.js similarity index 92% rename from js/swad15.105.js rename to js/swad15.106.js index 534340a3e..3958aa816 100644 --- a/js/swad15.105.js +++ b/js/swad15.106.js @@ -349,15 +349,30 @@ function refreshLastClicks() { } } -//Automatic refresh of social timeline using AJAX. This function must be called from time to time +// Automatic refresh of new publishings in social timeline using AJAX. This function must be called from time to time var objXMLHttpReqSoc = false; -function refreshSocialTimeline() { +function refreshNewTimeline() { objXMLHttpReqSoc = AJAXCreateObject(); if (objXMLHttpReqSoc) { - var RefreshParams = RefreshParamNxtActSoc + '&' + + var RefreshParams = RefreshParamNxtActNewPub + '&' + RefreshParamIdSes; - objXMLHttpReqSoc.onreadystatechange = readSocialTimelineData; // onreadystatechange must be lowercase + objXMLHttpReqSoc.onreadystatechange = readNewTimelineData; // onreadystatechange must be lowercase + objXMLHttpReqSoc.open('POST',ActionAJAX,true); + objXMLHttpReqSoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + objXMLHttpReqSoc.send(RefreshParams); + } +} + +// Refresh of old publishings in social timeline using AJAX. This function is called when user clicks in link +var objXMLHttpReqSoc = false; +function refreshOldTimeline() { + objXMLHttpReqSoc = AJAXCreateObject(); + if (objXMLHttpReqSoc) { + var RefreshParams = RefreshParamNxtActOldPub + '&' + + RefreshParamIdSes; + + objXMLHttpReqSoc.onreadystatechange = readOldTimelineData; // onreadystatechange must be lowercase objXMLHttpReqSoc.open('POST',ActionAJAX,true); objXMLHttpReqSoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); objXMLHttpReqSoc.send(RefreshParams); @@ -446,25 +461,25 @@ function readLastClicksData() { } } -//Receives and show social timeline data -function readSocialTimelineData() { +// Receives and show new social timeline data +function readNewTimelineData() { if (objXMLHttpReqSoc.readyState == 4) { // Check if data have been received if (objXMLHttpReqSoc.status == 200) { var endOfDelay = objXMLHttpReqSoc.responseText.indexOf('|',0); // Get separator position var delay = parseInt(objXMLHttpReqSoc.responseText.substring(0,endOfDelay)); // Get refresh delay - var htmlRecentTimeline = objXMLHttpReqSoc.responseText.substring(endOfDelay+1); // Get HTML code for social timeline + var htmlNewTimeline = objXMLHttpReqSoc.responseText.substring(endOfDelay+1); // Get HTML code for social timeline - var recentTimeline = document.getElementById('recent_timeline_list'); // Access to UL with the recent timeline - if (recentTimeline) { - recentTimeline.innerHTML = htmlRecentTimeline + recentTimeline.innerHTML; // Update list of publishings in recent timeline - var countRecentTimeline = recentTimeline.childNodes.length; + var newTimeline = document.getElementById('new_timeline_list'); // Access to UL with the new timeline + if (newTimeline) { + newTimeline.innerHTML = htmlNewTimeline + newTimeline.innerHTML; // Update list of publishings in new timeline + var countNewTimeline = newTimeline.childNodes.length; - if (countRecentTimeline) { + if (countNewTimeline) { var viewNewPostsContainer = document.getElementById('view_new_posts_container'); var viewNewPostsCount = document.getElementById('view_new_posts_count'); // Update number of new posts - viewNewPostsCount.innerHTML = countRecentTimeline; + viewNewPostsCount.innerHTML = countNewTimeline; // Display message with new posts if hidden viewNewPostsContainer.style.display = ''; @@ -472,23 +487,49 @@ function readSocialTimelineData() { } if (delay >= 5000) // If refresh slower than 1 time each 5 seconds, do refresh; else abort - setTimeout('refreshSocialTimeline()',delay); + setTimeout('refreshNewTimeline()',delay); } } } -// Move recent timeline to timeline -function moveRecentTimelineToTimeline() { +// Receives and show old social timeline data +function readOldTimelineData() { + if (objXMLHttpReqSoc.readyState == 4) { // Check if data have been received + if (objXMLHttpReqSoc.status == 200) { + var endOfDelay = objXMLHttpReqSoc.responseText.indexOf('|',0); // Get separator position + var delay = parseInt(objXMLHttpReqSoc.responseText.substring(0,endOfDelay)); // Get refresh delay + var htmlOldTimeline = objXMLHttpReqSoc.responseText.substring(endOfDelay+1); // Get HTML code for social timeline + + var oldTimeline = document.getElementById('old_timeline_list'); // Access to UL with the recent timeline + if (oldTimeline) { + oldTimeline.innerHTML = htmlOldTimeline; // Fill list of publishings in old timeline + var countOldTimeline = oldTimeline.childNodes.length; + + if (countOldTimeline) { + var timeline = document.getElementById("timeline_list"); + + // Move all the LI elements in UL 'old_timeline_list' to the bottom of UL 'timeline_list' + for (var i=0; i\n"); @@ -626,13 +627,15 @@ static void Lay_WriteScriptParamsAJAX (void) fprintf (Gbl.F.Out,"\n", - Act_Actions[ActRefCon ].ActCod, - Act_Actions[ActRefLstClk].ActCod, - Act_Actions[ActRefSocTim].ActCod, + Act_Actions[ActRefCon ].ActCod, + Act_Actions[ActRefLstClk ].ActCod, + Act_Actions[ActRefNewSocPub].ActCod, + Act_Actions[ActRefOldSocPub].ActCod, Gbl.Session.Id, Gbl.CurrentCrs.Crs.CrsCod); } @@ -1295,9 +1298,10 @@ void Lay_ShowErrorAndExit (const char *Message) /***** Page is generated (except and ). Compute time to generate page *****/ - if (Gbl.CurrentAct != ActRefCon && // Refreshing connected users - Gbl.CurrentAct != ActRefLstClk && // Refreshing last clics - Gbl.CurrentAct != ActRefSocTim) // Refreshing social timeline + if (Gbl.CurrentAct != ActRefCon && // Refreshing connected users + Gbl.CurrentAct != ActRefLstClk && // Refreshing last clics + Gbl.CurrentAct != ActRefNewSocPub && // Refreshing new social publishings in timeline + Gbl.CurrentAct != ActRefOldSocPub) // Refreshing old social publishings in timeline Sta_ComputeTimeToGeneratePage (); if (Gbl.WebService.IsWebService) // Serving a plugin request @@ -1315,9 +1319,10 @@ void Lay_ShowErrorAndExit (const char *Message) Fil_FastCopyOfOpenFiles (Gbl.F.Out,stdout); Fil_CloseAndRemoveFileForHTMLOutput (); - if (Gbl.CurrentAct != ActRefCon && // Refreshing connected users - Gbl.CurrentAct != ActRefLstClk && // Refreshing last clicks - Gbl.CurrentAct != ActRefSocTim) // Refreshing last clicks + if (Gbl.CurrentAct != ActRefCon && // Refreshing connected users + Gbl.CurrentAct != ActRefLstClk && // Refreshing last clicks + Gbl.CurrentAct != ActRefNewSocPub && // Refreshing new social publishings in timeline + Gbl.CurrentAct != ActRefOldSocPub) // Refreshing old social publishings in timeline { /***** Compute time to send page *****/ Sta_ComputeTimeToSendPage (); @@ -1492,15 +1497,27 @@ void Lay_RefreshLastClicks (void) } /*****************************************************************************/ -/********************* Refresh social timeline via AJAX **********************/ +/********** Refresh new publishings in social timeline via AJAX **************/ /*****************************************************************************/ -void Lay_RefreshSocialTimeline (void) +void Lay_RefreshNewTimeline (void) { // Send, before the HTML, the refresh time and the last publishing got from database fprintf (Gbl.F.Out,"%lu|", Cfg_TIME_TO_REFRESH_SOCIAL_TIMELINE); - Soc_GetAndShowRecentTimelineGbl (); + Soc_GetAndShowNewTimelineGbl (); + + /***** All the output is made, so don't write anymore *****/ + Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true; + } + +/*****************************************************************************/ +/************ View new publishings in social timeline via AJAX ***************/ +/*****************************************************************************/ + +void Lay_RefreshOldTimeline (void) + { + Soc_GetAndShowOldTimelineGbl (); /***** All the output is made, so don't write anymore *****/ Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true; diff --git a/swad_layout.h b/swad_layout.h index dc4c7fd1e..80d23da68 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -111,7 +111,8 @@ void Lay_ShowAlert (Lay_AlertType_t MsgType,const char *Message); void Lay_RefreshNotifsAndConnected (void); void Lay_RefreshLastClicks (void); -void Lay_RefreshSocialTimeline (void); +void Lay_RefreshNewTimeline (void); +void Lay_RefreshOldTimeline (void); void Lay_WriteHeaderClassPhoto (unsigned NumColumns,bool PrintView,bool DrawingClassPhoto, long InsCod,long DegCod,long CrsCod); diff --git a/swad_social.c b/swad_social.c index 1912743dc..45a810a1f 100644 --- a/swad_social.c +++ b/swad_social.c @@ -49,10 +49,10 @@ /***************************** Private constants *****************************/ /*****************************************************************************/ -#define Soc_MAX_BYTES_SUMMARY 100 -#define Soc_NUM_PUBS_IN_TIMELINE 100 -#define Soc_WIDTH_TIMELINE "560px" -#define Soc_MAX_NUM_SHARERS_SHOWN 10 // Maximum number of users shown who have share a social note +#define Soc_WIDTH_TIMELINE "560px" +#define Soc_NUM_PUBS_IN_TIMELINE 5 // Number of recent publishings shown before refreshing +#define Soc_MAX_NUM_SHARERS_SHOWN 10 // Maximum number of users shown who have share a social note +#define Soc_MAX_BYTES_SUMMARY 100 static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_NOTES] = { @@ -187,7 +187,10 @@ static void Soc_ShowTimeline (const char *Query,const char *Title); static void Soc_ShowRecentTimeline (const char *Query); static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPublishing *SocPub); -static void Soc_PutLinkToViewRecentPublishings (void); + +static void Soc_PutLinkToViewNewPublishings (void); +static void Soc_PutLinkToViewOldPublishings (void); + static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub, const struct SocialNote *SocNot, bool ShowAlone, @@ -302,7 +305,7 @@ void Soc_ShowTimelineGbl (void) /******* Get and show recent timeline including all the users I follow *******/ /*****************************************************************************/ -void Soc_GetAndShowRecentTimelineGbl (void) +void Soc_GetAndShowNewTimelineGbl (void) { char Query[512]; @@ -317,6 +320,27 @@ void Soc_GetAndShowRecentTimelineGbl (void) Soc_DropTemporaryTableWithPubCods (); } +/*****************************************************************************/ +/******** Get and show old timeline including all the users I follow *********/ +/*****************************************************************************/ + +void Soc_GetAndShowOldTimelineGbl (void) + { + // char Query[512]; + + /***** Build query to get timeline *****/ + // Soc_BuildQueryToGetTimelineGbl (true, // Get only new publishings + // Query); + + /***** Show recent timeline *****/ + // Soc_ShowRecentTimeline (Query); + + /***** Drop temporary table with publishing codes *****/ + // Soc_DropTemporaryTableWithPubCods (); + + fprintf (Gbl.F.Out,"
  • Un ejemplo de post.
  • "); + } + /*****************************************************************************/ /************************ Build query to get timeline ************************/ /*****************************************************************************/ @@ -452,11 +476,13 @@ static void Soc_ShowTimeline (const char *Query,const char *Title) Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me Soc_PutHiddenFormToWriteNewPost (); - /***** Hidden div where insert new publishings via AJAX *****/ - Soc_PutLinkToViewRecentPublishings (); - fprintf (Gbl.F.Out,""); + /***** Link to view new publishings via AJAX *****/ + Soc_PutLinkToViewNewPublishings (); - /***** List publishings in timeline one by one *****/ + /***** Hidden list where insert new publishings via AJAX *****/ + fprintf (Gbl.F.Out,""); + + /***** List with the publishings in timeline *****/ fprintf (Gbl.F.Out,""); + /***** Link to view old publishings via AJAX *****/ + Soc_PutLinkToViewOldPublishings (); + + /***** Hidden list where insert old publishings via AJAX *****/ + fprintf (Gbl.F.Out,""); + /***** End frame *****/ Lay_EndRoundFrame (); } @@ -526,18 +558,18 @@ static void Soc_ShowRecentTimeline (const char *Query) /***************** Put link to view new publishings in timeline **************/ /*****************************************************************************/ -static void Soc_PutLinkToViewRecentPublishings (void) +static void Soc_PutLinkToViewNewPublishings (void) { extern const char *The_ClassFormBold[The_NUM_THEMES]; extern const char *Txt_See_new_activity; - /***** Link to toggle on/off the form to comment a social note *****/ + /***** Link to view (show hidden) new publishings *****/ // div is hidden. When new posts arrive to the client via AJAX, div is shown fprintf (Gbl.F.Out,"
    " "" + " onclick=\"moveNewTimelineToTimeline();return false;\" />" "%s (0)" "" "
    ", @@ -545,6 +577,27 @@ static void Soc_PutLinkToViewRecentPublishings (void) Txt_See_new_activity); } +/*****************************************************************************/ +/***************** Put link to view old publishings in timeline **************/ +/*****************************************************************************/ + +static void Soc_PutLinkToViewOldPublishings (void) + { + extern const char *The_ClassFormBold[The_NUM_THEMES]; + extern const char *Txt_See_more; + + /***** Link to view old publishings *****/ + fprintf (Gbl.F.Out,"
    " + "" + "%s" + "" + "
    ", + The_ClassFormBold[Gbl.Prefs.Theme], + Txt_See_more); + } + /*****************************************************************************/ /***************************** Write social note *****************************/ /*****************************************************************************/ diff --git a/swad_social.h b/swad_social.h index 9c47edd06..e038f0a2c 100644 --- a/swad_social.h +++ b/swad_social.h @@ -83,7 +83,8 @@ typedef enum void Soc_ShowTimelineUsr (void); void Soc_ShowTimelineGbl (void); -void Soc_GetAndShowRecentTimelineGbl (void); +void Soc_GetAndShowNewTimelineGbl (void); +void Soc_GetAndShowOldTimelineGbl (void); void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod); void Soc_MarkSocialNoteAsUnavailableUsingNotCod (long NotCod); diff --git a/swad_text.c b/swad_text.c index 05a5485b8..bb8e1998d 100644 --- a/swad_text.c +++ b/swad_text.c @@ -33851,6 +33851,27 @@ const char *Txt_See_messages_received = "Veja mensagens recebidas"; #endif +const char *Txt_See_more = +#if L==1 + "Veure més"; +#elif L==2 + "Weitere"; +#elif L==3 + "See more"; +#elif L==4 + "Ver más"; +#elif L==5 + "Voir plus"; +#elif L==6 + "Ver más"; // Okoteve traducción +#elif L==7 + "Vedere più"; +#elif L==8 + "Zobacz więcej"; +#elif L==9 + "Veja mais"; +#endif + const char *Txt_See_new_activity = #if L==1 "Veure nova activitat";