Version18.74.4

This commit is contained in:
Antonio Cañas Vargas 2019-03-13 00:54:35 +01:00
parent 98782055b1
commit 4b602e2f83
5 changed files with 74 additions and 80 deletions

View File

@ -550,36 +550,36 @@ function readLastClicksData () {
}
/*****************************************************************************/
/**** Automatic refresh of new publishings in social timeline using AJAX *****/
/**** Automatic refresh of new publications in social timeline using AJAX ****/
/*****************************************************************************/
// This function must be called from time to time
var objXMLHttpReqSoc = false;
var objXMLHttpReqNewTL = false;
function refreshNewTimeline () {
objXMLHttpReqSoc = AJAXCreateObject();
if (objXMLHttpReqSoc) {
objXMLHttpReqNewTL = AJAXCreateObject();
if (objXMLHttpReqNewTL) {
var RefreshParams = RefreshParamNxtActNewPub + '&' +
RefreshParamIdSes + '&' +
RefreshParamWhichUsrs;
objXMLHttpReqSoc.onreadystatechange = readNewTimelineData; // onreadystatechange must be lowercase
objXMLHttpReqSoc.open('POST',ActionAJAX,true);
objXMLHttpReqSoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
objXMLHttpReqSoc.send(RefreshParams);
objXMLHttpReqNewTL.onreadystatechange = readNewTimelineData; // onreadystatechange must be lowercase
objXMLHttpReqNewTL.open('POST',ActionAJAX,true);
objXMLHttpReqNewTL.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
objXMLHttpReqNewTL.send(RefreshParams);
}
}
// 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 htmlJustNowTimeline = objXMLHttpReqSoc.responseText.substring(endOfDelay + 1); // Get HTML code for social timeline
if (objXMLHttpReqNewTL.readyState == 4) { // Check if data have been received
if (objXMLHttpReqNewTL.status == 200) {
var endOfDelay = objXMLHttpReqNewTL.responseText.indexOf('|',0); // Get separator position
var delay = parseInt(objXMLHttpReqNewTL.responseText.substring(0,endOfDelay)); // Get refresh delay
var htmlJustNowTimeline = objXMLHttpReqNewTL.responseText.substring(endOfDelay + 1); // Get HTML code for timeline
var justNowTimeline = document.getElementById('just_now_timeline_list');// Access to UL for the just received timeline
if (justNowTimeline) {
justNowTimeline.innerHTML = htmlJustNowTimeline; // Update list of publishings in just now timeline
justNowTimeline.innerHTML = htmlJustNowTimeline; // Update list of publications in just now timeline
var countJustNowTimeline = justNowTimeline.childNodes.length;
if (countJustNowTimeline) { // New pubs just retrieved
@ -613,7 +613,7 @@ function readNewTimelineData () {
}
/*****************************************************************************/
/* View new publishing in timeline by moving new timeline to top of timeline */
/* View new publication in timeline by moving new timeline to top of timeline */
/*****************************************************************************/
function moveNewTimelineToTimeline () {
@ -638,14 +638,14 @@ function moveNewTimelineToTimeline () {
}
/*****************************************************************************/
/********* Refresh of old publishings in social timeline using AJAX **********/
/******** Refresh of old publications in social timeline using AJAX **********/
/*****************************************************************************/
// This function is called when user clicks in link
var objXMLHttpReqSoc = false;
var objXMLHttpReqOldTL = false;
function refreshOldTimeline () {
objXMLHttpReqSoc = AJAXCreateObject ();
if (objXMLHttpReqSoc) {
objXMLHttpReqOldTL = AJAXCreateObject ();
if (objXMLHttpReqOldTL) {
var RefreshParams = RefreshParamNxtActOldPub + '&' +
RefreshParamIdSes;
if (typeof RefreshParamUsr !== 'undefined') {
@ -657,26 +657,22 @@ function refreshOldTimeline () {
RefreshParams += '&' + RefreshParamWhichUsrs;
}
objXMLHttpReqSoc.onreadystatechange = readOldTimelineData; // onreadystatechange must be lowercase
objXMLHttpReqSoc.open('POST',ActionAJAX,true);
objXMLHttpReqSoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
objXMLHttpReqSoc.send(RefreshParams);
objXMLHttpReqOldTL.onreadystatechange = readOldTimelineData; // onreadystatechange must be lowercase
objXMLHttpReqOldTL.open('POST',ActionAJAX,true);
objXMLHttpReqOldTL.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
objXMLHttpReqOldTL.send(RefreshParams);
}
}
// 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 (objXMLHttpReqOldTL.readyState == 4) { // Check if data have been received
if (objXMLHttpReqOldTL.status == 200) {
var oldTimeline = document.getElementById('old_timeline_list'); // Access to UL with the old timeline
if (oldTimeline) {
oldTimeline.innerHTML = htmlOldTimeline; // Fill list of publishings in old timeline
oldTimeline.innerHTML = objXMLHttpReqOldTL.responseText; // Fill list of publications in old timeline
var countOldTimeline = oldTimeline.childNodes.length;
if (countOldTimeline) {
// Scripts in timeline got via AJAX are not executed ==> execute them
evalScriptsInElem (oldTimeline);
@ -688,16 +684,14 @@ function readOldTimelineData () {
var timeline = document.getElementById("timeline_list");
for (var i=0; i<countOldTimeline; i++)
timeline.appendChild(oldTimeline.firstChild);
}
if (countOldTimeline < RefreshParamMaxOldPubsToGetAndShow) // Set to TL_MAX_OLD_PUBS_TO_GET_AND_SHOW
// No more old publishings
document.getElementById("view_old_posts_container").style.display = 'none';
else {
// There may be more publishings
// There may be more publications
document.getElementById('get_old_timeline').style.display=''; // Show icon to be hidden on click
document.getElementById('getting_old_timeline').style.display='none'; // Hide icon to be shown on click
}
else // No old publications retrieved, so we have reached the oldest publication
// Hide container with link to get old publications
document.getElementById("view_old_posts_container").style.display = 'none';
}
}
}

View File

@ -429,8 +429,6 @@ Lo de mutear anuncios, en principio prefiero hacer una opci
// TODO: Change in usability of Announcements of exams, suggested by Javier Fernández Baldomero.
// TODO: Al pulsar sobre una convocatoria de examen / aviso --> ir a la sección de esa convocatoria/aviso en lugar de mostrarlo repetido y destacado arriba
// TODO: Fix important bug: Cuando se baja varias veces el timeline pulsando en "Ver más", se para aleatoriamente tras varias actualizaciones hacia abajo, no siempre llega hasta la primera publicación
// TODO: Los usuarios que no tienes permiso para ver su perfil público, se debería mostrar algo, una mínima ficha sin tinmeline o algo así
/*****************************************************************************/
@ -452,10 +450,14 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.74 (2019-03-12)"
#define Log_PLATFORM_VERSION "SWAD 18.74.4 (2019-03-13)"
#define CSS_FILE "swad18.68.3.css"
#define JS_FILE "swad18.64.js"
#define JS_FILE "swad18.74.4.js"
/*
Version 18.74.4: Mar 13, 2019 Fixed bug in JavaScript related to timeline. (239628 lines)
Version 18.74.3: Mar 13, 2019 Fixed bug in JavaScript related to timeline. (239628 lines)
Version 18.74.2: Mar 13, 2019 Fixed bug in JavaScript related to timeline. (239628 lines)
Version 18.74.1: Mar 12, 2019 Changes in JavaScript related to timeline. (239630 lines)
Version 18.74: Mar 12, 2019 Module swad_social is renamed swad_timeline. (239633 lines)
Version 18.73.7: Mar 12, 2019 Code refactoring related to list of users and options. (239614 lines)
Version 18.73.6: Mar 12, 2019 Create new email message from list of users. This option will be active when email action allows selecting individual users. (239580 lines)

View File

@ -734,11 +734,9 @@ static void Lay_WriteScriptParamsAJAX (void)
put parameters used by AJAX */
fprintf (Gbl.F.Out,"var RefreshParamNxtActNewPub = \"act=%ld\";\n"
"var RefreshParamNxtActOldPub = \"act=%ld\";\n"
"var RefreshParamMaxOldPubsToGetAndShow = \"%u\";\n"
"var RefreshParamWhichUsrs = \"WhichUsrs=%u\";\n",
Act_GetActCod (ActRefNewSocPubGbl),
Act_GetActCod (ActRefOldSocPubGbl),
TL_MAX_OLD_PUBS_TO_GET_AND_SHOW,
(unsigned) Gbl.Timeline.WhichUsrs);
break;
case ActSeeOthPubPrf:
@ -756,10 +754,8 @@ static void Lay_WriteScriptParamsAJAX (void)
Nck_GetNicknameFromUsrCod (Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.Nickname);
fprintf (Gbl.F.Out,"var RefreshParamNxtActOldPub = \"act=%ld\";\n"
"var RefreshParamMaxOldPubsToGetAndShow = \"%u\";\n"
"var RefreshParamUsr = \"OtherUsrCod=%s\";\n",
Act_GetActCod (ActRefOldSocPubUsr),
TL_MAX_OLD_PUBS_TO_GET_AND_SHOW,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
break;
default:

View File

@ -109,7 +109,7 @@ struct TL_Comment
{
long PubCod;
long UsrCod;
long NotCod; // Note code
long NotCod; // Note code to which this comment belongs
time_t DateTimeUTC;
unsigned NumFavs; // Number of times (users) this comment has been favourited
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
@ -136,8 +136,8 @@ static void TL_ShowTimelineUsrHighlightingNot (long NotCod);
static void TL_GetAndShowOldTimeline (TL_TimelineUsrOrGbl_t TimelineUsrOrGbl);
static void TL_BuildQueryToGetTimeline (char **Query,
TL_TimelineUsrOrGbl_t TimelineUsrOrGbl,
TL_WhatToGetFromTimeline_t WhatToGetFromTimeline);
TL_TimelineUsrOrGbl_t TimelineUsrOrGbl,
TL_WhatToGetFromTimeline_t WhatToGetFromTimeline);
static long TL_GetPubCodFromSession (const char *FieldName);
static void TL_UpdateLastPubCodIntoSession (void);
static void TL_UpdateFirstPubCodIntoSession (long FirstPubCod);
@ -376,8 +376,8 @@ void TL_ShowTimelineGbl2 (void)
/***** Show the note highlighted *****/
TL_GetDataOfNoteByCod (&SocNot);
TL_WriteNote (&SocNot,
TopMessages[NotifyEvent],UsrDat.UsrCod,
true,true);
TopMessages[NotifyEvent],UsrDat.UsrCod,
true,true);
}
/***** Show timeline with possible highlighted note *****/
@ -391,8 +391,8 @@ static void TL_ShowTimelineGblHighlightingNot (long NotCod)
/***** Build query to get timeline *****/
TL_BuildQueryToGetTimeline (&Query,
TL_TIMELINE_GBL,
TL_GET_RECENT_TIMELINE);
TL_TIMELINE_GBL,
TL_GET_RECENT_TIMELINE);
/***** Show timeline *****/
TL_ShowTimeline (Query,Txt_Timeline,NotCod);
@ -417,8 +417,8 @@ static void TL_ShowTimelineUsrHighlightingNot (long NotCod)
/***** Build query to show timeline with publications of a unique user *****/
TL_BuildQueryToGetTimeline (&Query,
TL_TIMELINE_USR,
TL_GET_RECENT_TIMELINE);
TL_TIMELINE_USR,
TL_GET_RECENT_TIMELINE);
/***** Show timeline *****/
snprintf (Gbl.Title,sizeof (Gbl.Title),
@ -449,8 +449,8 @@ void TL_RefreshNewTimelineGbl (void)
/***** Build query to get timeline *****/
TL_BuildQueryToGetTimeline (&Query,
TL_TIMELINE_GBL,
TL_GET_ONLY_NEW_PUBS);
TL_TIMELINE_GBL,
TL_GET_ONLY_NEW_PUBS);
/***** Show new timeline *****/
TL_InsertNewPubsInTimeline (Query);
@ -494,8 +494,8 @@ static void TL_GetAndShowOldTimeline (TL_TimelineUsrOrGbl_t TimelineUsrOrGbl)
/***** Build query to get timeline *****/
TL_BuildQueryToGetTimeline (&Query,
TimelineUsrOrGbl,
TL_GET_ONLY_OLD_PUBS);
TimelineUsrOrGbl,
TL_GET_ONLY_OLD_PUBS);
/***** Show old timeline *****/
TL_ShowOldPubsInTimeline (Query);
@ -527,8 +527,8 @@ void TL_MarkMyNotifAsSeen (void)
#define TL_MAX_BYTES_SUBQUERY_ALREADY_EXISTS (256 - 1)
static void TL_BuildQueryToGetTimeline (char **Query,
TL_TimelineUsrOrGbl_t TimelineUsrOrGbl,
TL_WhatToGetFromTimeline_t WhatToGetFromTimeline)
TL_TimelineUsrOrGbl_t TimelineUsrOrGbl,
TL_WhatToGetFromTimeline_t WhatToGetFromTimeline)
{
char SubQueryPublishers[128];
char SubQueryRangeBottom[128];
@ -712,7 +712,8 @@ static void TL_BuildQueryToGetTimeline (char **Query,
switch (TimelineUsrOrGbl)
{
case TL_TIMELINE_USR: // Show the timeline of a user
sprintf (SubQueryRangeBottom,"PubCod>%ld AND ",RangePubsToGet.Bottom);
sprintf (SubQueryRangeBottom,"PubCod>%ld AND ",
RangePubsToGet.Bottom);
break;
case TL_TIMELINE_GBL: // Show the global timeline
switch (Gbl.Timeline.WhichUsrs)
@ -721,7 +722,7 @@ static void TL_BuildQueryToGetTimeline (char **Query,
sprintf (SubQueryRangeBottom,"social_pubs.PubCod>%ld AND ",
RangePubsToGet.Bottom);
break;
case TL_USRS_ALL: // Show the timeline of all users
case TL_USRS_ALL: // Show the timeline of all users
sprintf (SubQueryRangeBottom,"PubCod>%ld AND ",
RangePubsToGet.Bottom);
break;
@ -738,7 +739,8 @@ static void TL_BuildQueryToGetTimeline (char **Query,
switch (TimelineUsrOrGbl)
{
case TL_TIMELINE_USR: // Show the timeline of a user
sprintf (SubQueryRangeTop,"PubCod<%ld AND ",RangePubsToGet.Top);
sprintf (SubQueryRangeTop,"PubCod<%ld AND ",
RangePubsToGet.Top);
break;
case TL_TIMELINE_GBL: // Show the global timeline
switch (Gbl.Timeline.WhichUsrs)
@ -882,7 +884,8 @@ static long TL_GetPubCodFromSession (const char *FieldName)
/***** Get last publication code from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get publication code from session",
"SELECT %s FROM sessions WHERE SessionId='%s'",
"SELECT %s FROM sessions"
" WHERE SessionId='%s'",
FieldName,Gbl.Session.Id) != 1)
Lay_ShowErrorAndExit (Txt_The_session_has_expired);
@ -1027,9 +1030,9 @@ static void TL_ShowTimeline (char *Query,
/* Write note */
TL_WriteNote (&SocNot,
SocPub.TopMessage,SocPub.PublisherCod,
SocNot.NotCod == NotCodToHighlight,
false);
SocPub.TopMessage,SocPub.PublisherCod,
SocNot.NotCod == NotCodToHighlight,
false);
}
fprintf (Gbl.F.Out,"</ul>");
@ -1302,8 +1305,8 @@ static void TL_InsertNewPubsInTimeline (char *Query)
/* Write note */
TL_WriteNote (&SocNot,
SocPub.TopMessage,SocPub.PublisherCod,
false,false);
SocPub.TopMessage,SocPub.PublisherCod,
false,false);
}
/***** Free structure that stores the query result *****/
@ -1344,8 +1347,8 @@ static void TL_ShowOldPubsInTimeline (char *Query)
/* Write note */
TL_WriteNote (&SocNot,
SocPub.TopMessage,SocPub.PublisherCod,
false,false);
SocPub.TopMessage,SocPub.PublisherCod,
false,false);
}
/***** Free structure that stores the query result *****/
@ -3242,8 +3245,8 @@ static long TL_ReceiveComment (void)
/***** Show the note just commented *****/
TL_WriteNote (&SocNot,
TL_TOP_MESSAGE_COMMENTED,Gbl.Usrs.Me.UsrDat.UsrCod,
true,true);
TL_TOP_MESSAGE_COMMENTED,Gbl.Usrs.Me.UsrDat.UsrCod,
true,true);
}
/***** Free image *****/
@ -3782,8 +3785,8 @@ static void TL_RequestRemovalNote (void)
/* Show note */
TL_WriteNote (&SocNot,
TL_TOP_MESSAGE_NONE,-1L,
false,true);
TL_TOP_MESSAGE_NONE,-1L,
false,true);
/* End alert */
Gbl.Timeline.NotCod = SocNot.NotCod; // Note to be removed

View File

@ -35,9 +35,8 @@
// Number of recent publishings got and shown the first time, before refreshing
#define TL_MAX_NEW_PUBS_TO_GET_AND_SHOW 10000 // Unlimited
#define TL_MAX_REC_PUBS_TO_GET_AND_SHOW 10 // Recent publishings to show (first time)
#define TL_MAX_OLD_PUBS_TO_GET_AND_SHOW 10 // Old publishings are retrieved in packs of this size
// This constant is also used in JavaScript function readOldTimelineData
#define TL_MAX_REC_PUBS_TO_GET_AND_SHOW 10 // Recent publishings to show (first time)
#define TL_MAX_OLD_PUBS_TO_GET_AND_SHOW 20 // Old publishings are retrieved in packs of this size
/*****************************************************************************/
/******************************** Public types *******************************/