mirror of https://github.com/acanas/swad-core.git
Version 21.59: Nov 22, 2021 Code refactoring in timeline.
This commit is contained in:
parent
0c2299160f
commit
534f147a3c
|
@ -3444,7 +3444,7 @@ table.CELLS_PAD_10 > tbody > tr > td {padding:10px;}
|
|||
}
|
||||
|
||||
/********************************* Timeline **********************************/
|
||||
#view_new_posts_container,#view_old_posts_container
|
||||
#view_new_container,#view_old_pubs_container
|
||||
{
|
||||
display:table-cell;
|
||||
height:50px;
|
|
@ -26,7 +26,7 @@
|
|||
var Gbl_HTMLContent;
|
||||
|
||||
// Global variable used to call SWAD via AJAX
|
||||
var ActionAJAX;
|
||||
var actionAJAX;
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Handle match keystrokes **************************/
|
||||
|
@ -493,20 +493,22 @@ var objXMLHttpReqCon = false;
|
|||
function refreshConnected () {
|
||||
objXMLHttpReqCon = AJAXCreateObject();
|
||||
if (objXMLHttpReqCon) {
|
||||
var RefreshParams = RefreshParamNxtActCon + '&' +
|
||||
RefreshParamIdSes + '&' +
|
||||
RefreshParamCrsCod;
|
||||
var refreshParams = refreshParamNxtActCon + '&' +
|
||||
refreshParamIdSes + '&' +
|
||||
refreshParamCrsCod;
|
||||
|
||||
objXMLHttpReqCon.onreadystatechange = readConnUsrsData; // onreadystatechange must be lowercase
|
||||
objXMLHttpReqCon.open('POST',ActionAJAX,true);
|
||||
objXMLHttpReqCon.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqCon.send(RefreshParams);
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttpReqCon.onreadystatechange = readConnUsrsData;
|
||||
objXMLHttpReqCon.open('POST',actionAJAX,true);
|
||||
objXMLHttpReqCon.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqCon.send(refreshParams);
|
||||
}
|
||||
}
|
||||
|
||||
// Receive and show connected users data
|
||||
function readConnUsrsData () {
|
||||
if (objXMLHttpReqCon.readyState == 4) { // Check if data have been received
|
||||
if (objXMLHttpReqCon.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttpReqCon.status == 200) {
|
||||
var endOfDelay = objXMLHttpReqCon.responseText.indexOf('|',0); // Get separator position
|
||||
var endOfNotif = objXMLHttpReqCon.responseText.indexOf('|',endOfDelay + 1); // Get separator position
|
||||
|
@ -548,7 +550,6 @@ function readConnUsrsData () {
|
|||
if (delay >= 60000) // If refresh slower than 1 time each 60 seconds, do refresh; else abort
|
||||
setTimeout('refreshConnected()',delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -590,8 +591,9 @@ function updateExamPrint (idDiv,idInput,nameInput,Params,Language) {
|
|||
objXMLHttp = AJAXCreateObject ();
|
||||
if (objXMLHttp) {
|
||||
/* Send request to server */
|
||||
objXMLHttp.onreadystatechange = function() { // onreadystatechange must be lowercase
|
||||
if (objXMLHttp.readyState == 4) { // Check if data have been received
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttp.onreadystatechange = function() {
|
||||
if (objXMLHttp.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttp.status == 200) {
|
||||
// Response received
|
||||
clearTimeout (xmlHttpTimeout); // Clear timeout
|
||||
|
@ -603,13 +605,11 @@ function updateExamPrint (idDiv,idInput,nameInput,Params,Language) {
|
|||
// Scripts in div got via AJAX are not executed ==> execute them
|
||||
evalScriptsInElem (div);
|
||||
|
||||
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
// MathJax.Hub.Queue(["Typeset",MathJax.Hub,div]); // old versions
|
||||
// Process maths; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
MathJax.typeset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var inputElem = document.getElementById(idInput);
|
||||
|
@ -650,8 +650,9 @@ function updateExamPrint (idDiv,idInput,nameInput,Params,Language) {
|
|||
|
||||
IHaveFinishedTxt = disableFinished (txtSaving[Language]); // Disable finished button on sending. When answer is saved and response received ==> the button will be reloaded
|
||||
|
||||
objXMLHttp.open('POST',ActionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttp.open('POST',actionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttp.send(Params);
|
||||
|
||||
/* Timeout to abort in 5 seconds.
|
||||
|
@ -756,19 +757,21 @@ var objXMLHttpReqMchStd = false;
|
|||
function refreshMatchStd () {
|
||||
objXMLHttpReqMchStd = AJAXCreateObject();
|
||||
if (objXMLHttpReqMchStd) {
|
||||
var RefreshParams = RefreshParamNxtActMch + '&' +
|
||||
RefreshParamMchCod + '&' +
|
||||
RefreshParamIdSes;
|
||||
var refreshParams = refreshParamNxtActMch + '&' +
|
||||
refreshParamMchCod + '&' +
|
||||
refreshParamIdSes;
|
||||
|
||||
objXMLHttpReqMchStd.onreadystatechange = readMatchStdData; // onreadystatechange must be lowercase
|
||||
objXMLHttpReqMchStd.open('POST',ActionAJAX,true);
|
||||
objXMLHttpReqMchStd.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
objXMLHttpReqMchStd.send(RefreshParams);
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttpReqMchStd.onreadystatechange = readMatchStdData;
|
||||
objXMLHttpReqMchStd.open('POST',actionAJAX,true);
|
||||
objXMLHttpReqMchStd.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqMchStd.send(refreshParams);
|
||||
}
|
||||
}
|
||||
|
||||
function readMatchStdData () {
|
||||
if (objXMLHttpReqMchStd.readyState == 4) { // Check if data have been received
|
||||
if (objXMLHttpReqMchStd.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttpReqMchStd.status == 200) {
|
||||
var htmlMatch = objXMLHttpReqMchStd.responseText; // Get HTML code
|
||||
|
||||
|
@ -778,7 +781,6 @@ function readMatchStdData () {
|
|||
// Global delay variable is set initially in swad-core
|
||||
setTimeout('refreshMatchStd()',delayMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -790,19 +792,21 @@ var objXMLHttpReqMchTch = false;
|
|||
function refreshMatchTch () {
|
||||
objXMLHttpReqMchTch = AJAXCreateObject();
|
||||
if (objXMLHttpReqMchTch) {
|
||||
var RefreshParams = RefreshParamNxtActMch + '&' +
|
||||
RefreshParamMchCod + '&' +
|
||||
RefreshParamIdSes;
|
||||
var refreshParams = refreshParamNxtActMch + '&' +
|
||||
refreshParamMchCod + '&' +
|
||||
refreshParamIdSes;
|
||||
|
||||
objXMLHttpReqMchTch.onreadystatechange = readMatchTchData; // onreadystatechange must be lowercase
|
||||
objXMLHttpReqMchTch.open('POST',ActionAJAX,true);
|
||||
objXMLHttpReqMchTch.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
objXMLHttpReqMchTch.send(RefreshParams);
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttpReqMchTch.onreadystatechange = readMatchTchData;
|
||||
objXMLHttpReqMchTch.open('POST',actionAJAX,true);
|
||||
objXMLHttpReqMchTch.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqMchTch.send(refreshParams);
|
||||
}
|
||||
}
|
||||
|
||||
function readMatchTchData () {
|
||||
if (objXMLHttpReqMchTch.readyState == 4) { // Check if data have been received
|
||||
if (objXMLHttpReqMchTch.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttpReqMchTch.status == 200) {
|
||||
var endOfId = objXMLHttpReqMchTch.responseText.indexOf('|',0 ); // Get separator position
|
||||
var endOfEv = objXMLHttpReqMchTch.responseText.indexOf('|',endOfId + 1); // Get separator position
|
||||
|
@ -819,8 +823,7 @@ function readMatchTchData () {
|
|||
// Scripts in div got via AJAX are not executed ==> execute them
|
||||
evalScriptsInElem (div);
|
||||
|
||||
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
// MathJax.Hub.Queue(["Typeset",MathJax.Hub,div]); // old versions
|
||||
// Process maths; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
MathJax.typeset();
|
||||
}
|
||||
}
|
||||
|
@ -828,7 +831,6 @@ function readMatchTchData () {
|
|||
// Global delay variable is set initially in swad-core
|
||||
setTimeout('refreshMatchTch()',delayMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -842,18 +844,19 @@ function updateMatchTch (id,Params) {
|
|||
objXMLHttp = AJAXCreateObject ();
|
||||
if (objXMLHttp) {
|
||||
/* Send request to server */
|
||||
objXMLHttp.onreadystatechange = function() { // onreadystatechange must be lowercase
|
||||
if (objXMLHttp.readyState == 4) { // Check if data have been received
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttp.onreadystatechange = function() {
|
||||
if (objXMLHttp.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttp.status == 200)
|
||||
if (id) {
|
||||
var div = document.getElementById(id); // Access to DIV
|
||||
if (div)
|
||||
div.innerHTML = objXMLHttp.responseText; // Update DIV content
|
||||
}
|
||||
}
|
||||
};
|
||||
objXMLHttp.open('POST',ActionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttp.open('POST',actionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttp.send(Params);
|
||||
}
|
||||
}
|
||||
|
@ -867,19 +870,21 @@ var objXMLHttpReqLog = false;
|
|||
function refreshLastClicks () {
|
||||
objXMLHttpReqLog = AJAXCreateObject();
|
||||
if (objXMLHttpReqLog) {
|
||||
var RefreshParams = RefreshParamNxtActLstClk + '&' +
|
||||
RefreshParamIdSes + '&' +
|
||||
RefreshParamCrsCod;
|
||||
var refreshParams = refreshParamNxtActLstClk + '&' +
|
||||
refreshParamIdSes + '&' +
|
||||
refreshParamCrsCod;
|
||||
|
||||
objXMLHttpReqLog.onreadystatechange = readLastClicksData; // onreadystatechange must be lowercase
|
||||
objXMLHttpReqLog.open('POST',ActionAJAX,true);
|
||||
objXMLHttpReqLog.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
objXMLHttpReqLog.send(RefreshParams);
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttpReqLog.onreadystatechange = readLastClicksData;
|
||||
objXMLHttpReqLog.open('POST',actionAJAX,true);
|
||||
objXMLHttpReqLog.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqLog.send(refreshParams);
|
||||
}
|
||||
}
|
||||
|
||||
function readLastClicksData () {
|
||||
if (objXMLHttpReqLog.readyState == 4) { // Check if data have been received
|
||||
if (objXMLHttpReqLog.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttpReqLog.status == 200) {
|
||||
var endOfDelay = objXMLHttpReqLog.responseText.indexOf('|',0); // Get separator position
|
||||
|
||||
|
@ -892,79 +897,82 @@ function readLastClicksData () {
|
|||
if (delay > 200) // If refresh slower than 1 time each 0.2 seconds, do refresh; else abort
|
||||
setTimeout('refreshLastClicks()',delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Automatically refresh new publications in social timeline using AJAX ****/
|
||||
/******* Automatically refresh new publications in timeline using AJAX *******/
|
||||
/*****************************************************************************/
|
||||
|
||||
// This function must be called from time to time
|
||||
var objXMLHttpReqNewTL = false;
|
||||
function refreshNewTL () {
|
||||
objXMLHttpReqNewTL = AJAXCreateObject();
|
||||
if (objXMLHttpReqNewTL) {
|
||||
var RefreshParams = RefreshParamNxtActNewPub + '&' +
|
||||
RefreshParamIdSes + '&' +
|
||||
RefreshParamWho;
|
||||
|
||||
objXMLHttpReqNewTL.onreadystatechange = readNewTimelineData; // onreadystatechange must be lowercase
|
||||
objXMLHttpReqNewTL.open('POST',ActionAJAX,true);
|
||||
objXMLHttpReqNewTL.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
objXMLHttpReqNewTL.send(RefreshParams);
|
||||
var objXMLHttpReqNewTml = false;
|
||||
|
||||
function refreshNewTimeline () {
|
||||
objXMLHttpReqNewTml = AJAXCreateObject();
|
||||
if (objXMLHttpReqNewTml) {
|
||||
var refreshParams = refreshParamNxtActNewPub + '&' +
|
||||
refreshParamIdSes + '&' +
|
||||
refreshParamWho;
|
||||
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttpReqNewTml.onreadystatechange = readNewTimelineData;
|
||||
objXMLHttpReqNewTml.open('POST',actionAJAX,true);
|
||||
objXMLHttpReqNewTml.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqNewTml.send(refreshParams);
|
||||
}
|
||||
}
|
||||
|
||||
// Receive and show new social timeline data
|
||||
function readNewTimelineData () {
|
||||
if (objXMLHttpReqNewTL.readyState == 4) { // Check if data have been received
|
||||
if (objXMLHttpReqNewTL.status == 200) {
|
||||
if (objXMLHttpReqNewTml.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttpReqNewTml.status == 200) {
|
||||
|
||||
var justNowTimeline = document.getElementById('just_now_timeline_list');// Access to UL for the just received timeline
|
||||
// Access to UL for just now timeline
|
||||
var justNowTimeline = document.getElementById('just_now_timeline_list');
|
||||
if (justNowTimeline) {
|
||||
justNowTimeline.innerHTML = objXMLHttpReqNewTL.responseText; // Update list of publications in just now timeline
|
||||
// Update list of publications in just now timeline
|
||||
justNowTimeline.innerHTML = objXMLHttpReqNewTml.responseText;
|
||||
|
||||
var numNotesJustGot = justNowTimeline.childNodes.length;
|
||||
if (numNotesJustGot) { // New notes just received
|
||||
// Scripts in timeline got via AJAX are not executed ==> execute them
|
||||
if (numNotesJustGot) { // New notes received
|
||||
// Scripts in timeline got via AJAX not executed ==> execute them
|
||||
evalScriptsInElem (justNowTimeline);
|
||||
|
||||
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
// MathJax.Hub.Queue(["Typeset",MathJax.Hub,justNowTimeline]); // old versions
|
||||
// Process maths; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
MathJax.typeset();
|
||||
|
||||
// Move just received timeline to top of new timeline
|
||||
// (move all the LI elements (notes) in UL 'just_now_timeline_list'...
|
||||
// ...to the top of UL 'new_timeline_list')
|
||||
var newTimeline = document.getElementById('new_timeline_list'); // Access to UL with the new timeline
|
||||
// Move all the LI elements (notes) in UL 'just_now_timeline_list'...
|
||||
// ...to the top of UL 'new_timeline_list'
|
||||
var newTimeline = document.getElementById('new_timeline_list');
|
||||
|
||||
for (var i=0; i<numNotesJustGot; i++) {
|
||||
// Move node from just now timeline to new timeline
|
||||
newTimeline.insertBefore(justNowTimeline.lastChild, newTimeline.firstChild);
|
||||
newTimeline.insertBefore(justNowTimeline.lastChild,newTimeline.firstChild);
|
||||
newTimeline.firstChild.className += " Tml_NEW_PUB";
|
||||
}
|
||||
|
||||
// Update number of new posts
|
||||
var viewNewPostsCount = document.getElementById('view_new_posts_count');
|
||||
viewNewPostsCount.innerHTML = newTimeline.childNodes.length;
|
||||
// Update number of notes in new timeline
|
||||
var viewNewCount = document.getElementById('view_new_count');
|
||||
viewNewCount.innerHTML = newTimeline.childNodes.length;
|
||||
|
||||
// Display message with new posts if hidden
|
||||
var viewNewPostsContainer = document.getElementById('view_new_posts_container');
|
||||
viewNewPostsContainer.style.display = '';
|
||||
// Unhide message with number of notes if hidden
|
||||
var viewNewContainer = document.getElementById('view_new_container');
|
||||
viewNewContainer.style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Global delay variable is set initially in swad-core
|
||||
delayNewTL += 1000; // Increase 1 second
|
||||
setTimeout('refreshNewTL()',delayNewTL);
|
||||
delayNewTml += 1000; // Increase one second on each call
|
||||
setTimeout('refreshNewTimeline()',delayNewTml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* View new publication in timeline by moving new timeline to top of timeline */
|
||||
/*** View new pubs. in timeline by moving new timeline to top of timeline ****/
|
||||
/*****************************************************************************/
|
||||
|
||||
// This function is called when user clicks in 'See new activity (n)'
|
||||
|
||||
function moveNewTimelineToTimeline () {
|
||||
// Move the LI elements (notes) in UL 'new_timeline_list'...
|
||||
// ...to the top of UL 'timeline_list', only if not repeated before
|
||||
|
@ -989,7 +997,7 @@ function moveNewTimelineToTimeline () {
|
|||
// Move or remove node from new timeline
|
||||
if (mostRecentOcurrenceOfNote) {
|
||||
// Move node from new timeline to timeline
|
||||
timeline.insertBefore(newTimeline.lastChild, timeline.firstChild);
|
||||
timeline.insertBefore(newTimeline.lastChild,timeline.firstChild);
|
||||
timeline.firstChild.className += " Tml_NEW_PUB";
|
||||
}
|
||||
else
|
||||
|
@ -998,74 +1006,80 @@ function moveNewTimelineToTimeline () {
|
|||
}
|
||||
}
|
||||
|
||||
// Reset number of new posts after moving
|
||||
var viewNewPostsCount = document.getElementById('view_new_posts_count');
|
||||
viewNewPostsCount.innerHTML = 0;
|
||||
// Reset number of new publications after moving
|
||||
var viewNewCount = document.getElementById('view_new_count');
|
||||
viewNewCount.innerHTML = 0;
|
||||
|
||||
// Hide link to view new posts after moving
|
||||
var viewNewPostsContainer = document.getElementById('view_new_posts_container');
|
||||
viewNewPostsContainer.style.display = 'none';
|
||||
// Hide link to view new publications after moving
|
||||
var viewNewContainer = document.getElementById('view_new_container');
|
||||
viewNewContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Refresh old publications in social timeline using AJAX ***********/
|
||||
/************* Refresh old publications in timeline using AJAX ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// This function is called when user clicks in link
|
||||
var objXMLHttpReqOldTL = false;
|
||||
// This function is called when user clicks in 'See more'
|
||||
|
||||
var objXMLHttpReqOldTml = false;
|
||||
|
||||
function refreshOldTimeline () {
|
||||
objXMLHttpReqOldTL = AJAXCreateObject ();
|
||||
if (objXMLHttpReqOldTL) {
|
||||
var RefreshParams = RefreshParamNxtActOldPub + '&' +
|
||||
RefreshParamIdSes;
|
||||
if (typeof RefreshParamUsr !== 'undefined') {
|
||||
if (RefreshParamUsr.length)
|
||||
RefreshParams += '&' + RefreshParamUsr;
|
||||
objXMLHttpReqOldTml = AJAXCreateObject ();
|
||||
if (objXMLHttpReqOldTml) {
|
||||
var refreshParams = refreshParamNxtActOldPub + '&' +
|
||||
refreshParamIdSes;
|
||||
if (typeof refreshParamUsr !== 'undefined') {
|
||||
if (refreshParamUsr.length)
|
||||
refreshParams += '&' + refreshParamUsr;
|
||||
}
|
||||
if (typeof RefreshParamWho !== 'undefined') {
|
||||
if (RefreshParamWho.length)
|
||||
RefreshParams += '&' + RefreshParamWho;
|
||||
if (typeof refreshParamWho !== 'undefined') {
|
||||
if (refreshParamWho.length)
|
||||
refreshParams += '&' + refreshParamWho;
|
||||
}
|
||||
|
||||
objXMLHttpReqOldTL.onreadystatechange = readOldTimelineData; // onreadystatechange must be lowercase
|
||||
objXMLHttpReqOldTL.open('POST',ActionAJAX,true);
|
||||
objXMLHttpReqOldTL.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqOldTL.send(RefreshParams);
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttpReqOldTml.onreadystatechange = readOldTimelineData;
|
||||
objXMLHttpReqOldTml.open('POST',actionAJAX,true);
|
||||
objXMLHttpReqOldTml.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttpReqOldTml.send(refreshParams);
|
||||
}
|
||||
}
|
||||
|
||||
// Receive and show old social timeline data
|
||||
function readOldTimelineData () {
|
||||
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 (objXMLHttpReqOldTml.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttpReqOldTml.status == 200) {
|
||||
// Access to UL with the old timeline
|
||||
var oldTimeline = document.getElementById('old_timeline_list');
|
||||
if (oldTimeline) {
|
||||
oldTimeline.innerHTML = objXMLHttpReqOldTL.responseText; // Fill list of publications in old timeline
|
||||
// Fill list of publications in old timeline
|
||||
oldTimeline.innerHTML = objXMLHttpReqOldTml.responseText;
|
||||
|
||||
var countOldTimeline = oldTimeline.childNodes.length;
|
||||
if (countOldTimeline) {
|
||||
// Scripts in timeline got via AJAX are not executed ==> execute them
|
||||
// Scripts in timeline got via AJAX not executed ==> execute them
|
||||
evalScriptsInElem (oldTimeline);
|
||||
|
||||
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
// MathJax.Hub.Queue(["Typeset",MathJax.Hub,oldTimeline]); // old versions
|
||||
// Process maths; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
MathJax.typeset();
|
||||
|
||||
// Move all the LI elements in UL 'old_timeline_list' to the bottom of UL 'timeline_list'
|
||||
// Move all the LI elements in UL 'old_timeline_list'
|
||||
// to the bottom of UL 'timeline_list'
|
||||
var timeline = document.getElementById("timeline_list");
|
||||
for (var i=0; i<countOldTimeline; i++)
|
||||
timeline.appendChild(oldTimeline.firstChild);
|
||||
|
||||
// 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
|
||||
// Unhide icon to be hidden on click
|
||||
document.getElementById('get_old_timeline').style.display = '';
|
||||
// Hide icon to be shown on click
|
||||
document.getElementById('getting_old_timeline').style.display = 'none';
|
||||
}
|
||||
else // No old publications retrieved, so we have reached the oldest publication
|
||||
else // No old publications retrieved, so we have reached the oldest pub.
|
||||
// Hide container with link to get old publications
|
||||
document.getElementById("view_old_posts_container").style.display = 'none';
|
||||
document.getElementById("view_old_pubs_container").style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1093,8 +1107,9 @@ function updateDivHiddenComments (form,Params) {
|
|||
objXMLHttp = AJAXCreateObject ();
|
||||
if (objXMLHttp) {
|
||||
/* Send request to server */
|
||||
objXMLHttp.onreadystatechange = function() { // onreadystatechange must be lowercase
|
||||
if (objXMLHttp.readyState == 4) { // Check if data have been received
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttp.onreadystatechange = function() {
|
||||
if (objXMLHttp.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttp.status == 200)
|
||||
if (id) {
|
||||
var div = document.getElementById(id); // Access to DIV
|
||||
|
@ -1104,15 +1119,14 @@ function updateDivHiddenComments (form,Params) {
|
|||
// Scripts in div got via AJAX are not executed ==> execute them
|
||||
evalScriptsInElem (div);
|
||||
|
||||
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
// MathJax.Hub.Queue(["Typeset",MathJax.Hub,div]); // old versions
|
||||
// Process maths; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||
MathJax.typeset();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
objXMLHttp.open('POST',ActionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttp.open('POST',actionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttp.send(Params);
|
||||
}
|
||||
}
|
||||
|
@ -1129,18 +1143,19 @@ function updateDivLockUnlockProject (form,Params) {
|
|||
objXMLHttp = AJAXCreateObject ();
|
||||
if (objXMLHttp) {
|
||||
/* Send request to server */
|
||||
objXMLHttp.onreadystatechange = function() { // onreadystatechange must be lowercase
|
||||
if (objXMLHttp.readyState == 4) { // Check if data have been received
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttp.onreadystatechange = function() {
|
||||
if (objXMLHttp.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttp.status == 200)
|
||||
if (id) {
|
||||
var div = document.getElementById(id); // Access to DIV
|
||||
if (div)
|
||||
div.innerHTML = objXMLHttp.responseText; // Update DIV content
|
||||
}
|
||||
}
|
||||
};
|
||||
objXMLHttp.open('POST',ActionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttp.open('POST',actionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttp.send(Params);
|
||||
}
|
||||
}
|
||||
|
@ -1157,18 +1172,19 @@ function updateDivFaversSharers (form,Params) {
|
|||
objXMLHttp = AJAXCreateObject ();
|
||||
if (objXMLHttp) {
|
||||
/* Send request to server */
|
||||
objXMLHttp.onreadystatechange = function() { // onreadystatechange must be lowercase
|
||||
if (objXMLHttp.readyState == 4) { // Check if data have been received
|
||||
// onreadystatechange must be lowercase
|
||||
objXMLHttp.onreadystatechange = function() {
|
||||
if (objXMLHttp.readyState == 4) // Check if data have been received
|
||||
if (objXMLHttp.status == 200)
|
||||
if (id) {
|
||||
var div = document.getElementById(id); // Access to DIV
|
||||
if (div)
|
||||
div.innerHTML = objXMLHttp.responseText; // Update DIV content
|
||||
}
|
||||
}
|
||||
};
|
||||
objXMLHttp.open('POST',ActionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
objXMLHttp.open('POST',actionAJAX,true);
|
||||
objXMLHttp.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
objXMLHttp.send(Params);
|
||||
}
|
||||
}
|
|
@ -13551,7 +13551,8 @@ SELECT tml_pubs.PubCod,
|
|||
"tml_pubs.PubType" // row[3]
|
||||
" FROM tml_pubs%s"
|
||||
" WHERE tml_pubs.PublisherCod=fol_tmp_me_and_followed.UsrCod
|
||||
AND "
|
||||
AND tml_pubs.PubCod>Bottom AND "
|
||||
AND tml_pubs.PubCod<Top AND "
|
||||
" ORDER BY tml_pubs.PubCod DESC"
|
||||
" LIMIT 1",
|
||||
SubQueries->Publishers.Table,
|
||||
|
@ -13559,4 +13560,9 @@ SELECT tml_pubs.PubCod,
|
|||
SubQueries->RangeTop,
|
||||
SubQueries->Publishers.SubQuery,
|
||||
SubQueries->AlreadyExists);
|
||||
|
||||
|
||||
SELECT MAX(PstCod) AS NewestPstCod FROM for_posts GROUP BY ThrCod ORDER BY NewestPstCod DESC LIMIT 10;
|
||||
|
||||
SELECT PstCod FROM for_posts ORDER BY PstCod DESC LIMIT 1;
|
||||
|
||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.58.2 (2021-11-21)"
|
||||
#define CSS_FILE "swad21.57.css"
|
||||
#define JS_FILE "swad21.58.js"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.59 (2021-11-22)"
|
||||
#define CSS_FILE "swad21.59.css"
|
||||
#define JS_FILE "swad21.59.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 21.59: Nov 22, 2021 Code refactoring in timeline. (319149 lines)
|
||||
Version 21.58.2: Nov 21, 2021 Code refactoring in timeline. (319135 lines)
|
||||
Version 21.58.1: Nov 21, 2021 Code refactoring in timeline. (319131 lines)
|
||||
Version 21.58: Nov 21, 2021 Code refactoring in timeline. (319140 lines)
|
||||
|
|
|
@ -2013,7 +2013,7 @@ static void Fig_GetAndShowTestsStats (void)
|
|||
/***** Get the stats about test questions from this location *****/
|
||||
Qst_GetTestStats (AnsType,&Stats);
|
||||
|
||||
/***** Write number of assignments *****/
|
||||
/***** Write stats *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
HTM_TD_Begin ("class=\"DAT LM\"");
|
||||
|
@ -2062,7 +2062,7 @@ static void Fig_GetAndShowTestsStats (void)
|
|||
/***** Get the stats about test questions from this location *****/
|
||||
Qst_GetTestStats (Qst_ANS_UNKNOWN,&Stats);
|
||||
|
||||
/***** Write number of assignments *****/
|
||||
/***** Write stats *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\"");
|
||||
|
|
|
@ -795,33 +795,33 @@ static void Lay_WriteScriptInit (void)
|
|||
Dat_WriteScriptMonths ();
|
||||
|
||||
if (RefreshNewTimeline) // Refresh new timeline via AJAX
|
||||
HTM_TxtF ("\tvar delayNewTL = %lu;\n",Cfg_TIME_TO_REFRESH_TIMELINE);
|
||||
HTM_TxtF ("\tvar delayNewTml = %lu;\n",Cfg_TIME_TO_REFRESH_TIMELINE);
|
||||
else if (RefreshMatchStd) // Refresh match via AJAX
|
||||
HTM_TxtF ("\tvar delayMatch = %lu;\n",Cfg_TIME_TO_REFRESH_MATCH_STD);
|
||||
else if (RefreshMatchTch) // Refresh match via AJAX
|
||||
HTM_TxtF ("\tvar delayMatch = %lu;\n",Cfg_TIME_TO_REFRESH_MATCH_TCH);
|
||||
|
||||
/***** Function init () ******/
|
||||
HTM_Txt ("function init(){\n");
|
||||
HTM_Txt ("function init() {\n");
|
||||
|
||||
HTM_TxtF ("\tActionAJAX = \"%s\";\n",Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
HTM_TxtF ("\tactionAJAX = \"%s\";\n",Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
|
||||
if (RefreshConnected) // Refresh connected users via AJAX
|
||||
{
|
||||
Con_WriteScriptClockConnected ();
|
||||
HTM_TxtF ("\tsetTimeout(\"refreshConnected()\",%lu);\n",
|
||||
HTM_TxtF ("\tsetTimeout('refreshConnected()',%lu);\n",
|
||||
Gbl.Usrs.Connected.TimeToRefreshInMs);
|
||||
}
|
||||
|
||||
if (RefreshLastClicks) // Refresh last clicks via AJAX
|
||||
HTM_TxtF ("\tsetTimeout(\"refreshLastClicks()\",%lu);\n",
|
||||
HTM_TxtF ("\tsetTimeout('refreshLastClicks()',%lu);\n",
|
||||
Cfg_TIME_TO_REFRESH_LAST_CLICKS);
|
||||
else if (RefreshNewTimeline) // Refresh timeline via AJAX
|
||||
HTM_Txt ("\tsetTimeout(\"refreshNewTL()\",delayNewTL);\n");
|
||||
HTM_Txt ("\tsetTimeout('refreshNewTimeline()',delayNewTml);\n");
|
||||
else if (RefreshMatchStd) // Refresh match for a student via AJAX
|
||||
HTM_Txt ("\tsetTimeout(\"refreshMatchStd()\",delayMatch);\n");
|
||||
HTM_Txt ("\tsetTimeout('refreshMatchStd()',delayMatch);\n");
|
||||
else if (RefreshMatchTch) // Refresh match for a teacher via AJAX
|
||||
HTM_Txt ("\tsetTimeout(\"refreshMatchTch()\",delayMatch);\n");
|
||||
HTM_Txt ("\tsetTimeout('refreshMatchTch()',delayMatch);\n");
|
||||
|
||||
HTM_Txt ("}\n");
|
||||
|
||||
|
@ -839,15 +839,15 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
|
||||
/***** Parameters with code of session and current course code *****/
|
||||
// Refresh parameters
|
||||
HTM_TxtF ("var RefreshParamIdSes = \"ses=%s\";\n"
|
||||
"var RefreshParamCrsCod = \"crs=%ld\";\n",
|
||||
HTM_TxtF ("var refreshParamIdSes = \"ses=%s\";\n"
|
||||
"var refreshParamCrsCod = \"crs=%ld\";\n",
|
||||
Gbl.Session.Id,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Parameter to refresh connected users *****/
|
||||
if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
|
||||
// Refresh parameter
|
||||
HTM_TxtF ("var RefreshParamNxtActCon = \"act=%ld\";\n",
|
||||
HTM_TxtF ("var refreshParamNxtActCon = \"act=%ld\";\n",
|
||||
Act_GetActCod (ActRefCon));
|
||||
|
||||
/***** Parameters related with expanding/contracting folders in file browsers *****/
|
||||
|
@ -855,8 +855,8 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
/* In all actions related to file browsers ==>
|
||||
put parameters used by AJAX */
|
||||
// Refresh parameters
|
||||
HTM_TxtF ("var RefreshParamExpand = \"act=%ld\";\n"
|
||||
"var RefreshParamContract = \"act=%ld\";\n",
|
||||
HTM_TxtF ("var refreshParamExpand = \"act=%ld\";\n"
|
||||
"var refreshParamContract = \"act=%ld\";\n",
|
||||
Act_GetActCod (Brw_GetActionExpand ()),
|
||||
Act_GetActCod (Brw_GetActionContract ()));
|
||||
|
||||
|
@ -874,9 +874,9 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
/* In all actions related to view or editing global timeline ==>
|
||||
put parameters used by AJAX */
|
||||
// Refresh parameters
|
||||
HTM_TxtF ("var RefreshParamNxtActNewPub = \"act=%ld\";\n"
|
||||
"var RefreshParamNxtActOldPub = \"act=%ld\";\n"
|
||||
"var RefreshParamWho = \"Who=%u\";\n",
|
||||
HTM_TxtF ("var refreshParamNxtActNewPub = \"act=%ld\";\n"
|
||||
"var refreshParamNxtActOldPub = \"act=%ld\";\n"
|
||||
"var refreshParamWho = \"Who=%u\";\n",
|
||||
Act_GetActCod (ActRefNewPubGblTL),
|
||||
Act_GetActCod (ActRefOldPubGblTL),
|
||||
(unsigned) Tml_Who_GetGlobalWho ()); // Global variable got in a priori function
|
||||
|
@ -894,8 +894,8 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0)
|
||||
Usr_GetParamOtherUsrCodEncrypted (&Gbl.Usrs.Other.UsrDat);
|
||||
// Refresh parameters
|
||||
HTM_TxtF ("var RefreshParamNxtActOldPub = \"act=%ld\";\n"
|
||||
"var RefreshParamUsr = \"OtherUsrCod=%s\";\n",
|
||||
HTM_TxtF ("var refreshParamNxtActOldPub = \"act=%ld\";\n"
|
||||
"var refreshParamUsr = \"OtherUsrCod=%s\";\n",
|
||||
Act_GetActCod (ActRefOldPubUsrTL),
|
||||
Gbl.Usrs.Other.UsrDat.EnUsrCod);
|
||||
break;
|
||||
|
@ -905,8 +905,8 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
case ActRemMchAnsQstStd:
|
||||
case ActAnsMchQstStd:
|
||||
// Refresh parameters
|
||||
HTM_TxtF ("var RefreshParamNxtActMch = \"act=%ld\";\n"
|
||||
"var RefreshParamMchCod = \"MchCod=%ld\";\n",
|
||||
HTM_TxtF ("var refreshParamNxtActMch = \"act=%ld\";\n"
|
||||
"var refreshParamMchCod = \"MchCod=%ld\";\n",
|
||||
Act_GetActCod (ActRefMchStd),
|
||||
Mch_GetMchCodBeingPlayed ());
|
||||
break;
|
||||
|
@ -922,15 +922,15 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
// Handle keys in keyboard/presenter
|
||||
HTM_Txt ("document.addEventListener(\"keydown\",handleMatchKeys);\n");
|
||||
// Refresh parameters
|
||||
HTM_TxtF ("var RefreshParamNxtActMch = \"act=%ld\";\n"
|
||||
"var RefreshParamMchCod = \"MchCod=%ld\";\n",
|
||||
HTM_TxtF ("var refreshParamNxtActMch = \"act=%ld\";\n"
|
||||
"var refreshParamMchCod = \"MchCod=%ld\";\n",
|
||||
Act_GetActCod (ActRefMchTch),
|
||||
Mch_GetMchCodBeingPlayed ());
|
||||
break;
|
||||
/* Parameter related with clicks refreshing */
|
||||
case ActLstClk:
|
||||
// Refresh parameter
|
||||
HTM_TxtF ("var RefreshParamNxtActLstClk = \"act=%ld\";\n",
|
||||
HTM_TxtF ("var refreshParamNxtActLstClk = \"act=%ld\";\n",
|
||||
Act_GetActCod (ActRefLstClk));
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -381,9 +381,9 @@ static void Tml_GetAndShowOldTimeline (struct Tml_Timeline *Timeline)
|
|||
Hidden < __v__
|
||||
| |_____| new_timeline_list (Posts retrieved but hidden.
|
||||
| |_____| When user clicks to view them,
|
||||
| |_____| they are transferred
|
||||
\ |_____| to visible timeline_list.)
|
||||
|
|
||||
| |_____| the most recent of each note is
|
||||
\ |_____| is transferred
|
||||
| to visible timeline_list.)
|
||||
__v__
|
||||
/ |_____| timeline_list (Posts visible on page)
|
||||
| |_____|
|
||||
|
@ -424,14 +424,14 @@ static void Tml_ShowTimeline (struct Tml_Timeline *Timeline,
|
|||
/***** New publications refreshed dynamically via AJAX *****/
|
||||
if (GlobalTimeline)
|
||||
{
|
||||
/* Link to view new publications via AJAX */
|
||||
Tml_Pub_PutLinkToViewNewPubs ();
|
||||
|
||||
/* Hidden lists to insert publications received via AJAX:
|
||||
1. just received (not visible) publications
|
||||
2. new (not visible) publications */
|
||||
Tml_PutHiddenList ("just_now_timeline_list");
|
||||
Tml_PutHiddenList ("new_timeline_list");
|
||||
|
||||
/* Link to view new publications via AJAX */
|
||||
Tml_Pub_PutLinkToViewNewPubs ();
|
||||
}
|
||||
|
||||
/***** List recent publications in timeline.
|
||||
|
|
|
@ -121,10 +121,10 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
|
|||
|______| / |______| ->|______| ______
|
||||
|______| / |______| / |______| ->|______|
|
||||
|_Next_|-- |______| / |______| // |______|
|
||||
|_Next_|-- |______| // |______|
|
||||
more recent |_Next_|-- |______| // |______|
|
||||
______ |_Next_|--/ |______|
|
||||
|______|---------------------------------------------- |_NULL_|
|
||||
|
||||
older
|
||||
Timeline->Pubs.Bottom
|
||||
|
||||
*/
|
||||
|
@ -147,7 +147,8 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
|
|||
SELECT MAX(PubCod) AS NewestPubCod
|
||||
FROM tml_pubs ...
|
||||
GROUP BY NotCod
|
||||
ORDER BY NewestPubCod DESC LIMIT ...
|
||||
ORDER BY NewestPubCod DESC
|
||||
LIMIT 10
|
||||
but this query is slow (several seconds) with a big table.
|
||||
*/
|
||||
for (NumPub = 0;
|
||||
|
@ -462,8 +463,8 @@ void Tml_Pub_PutLinkToViewNewPubs (void)
|
|||
|
||||
/***** Link to view (show hidden) new publications *****/
|
||||
/* Begin container */
|
||||
// div is hidden. When new posts arrive to the client via AJAX, div is shown
|
||||
HTM_DIV_Begin ("id=\"view_new_posts_container\""
|
||||
// div is hidden. When new notes arrive to the client via AJAX, div is shown
|
||||
HTM_DIV_Begin ("id=\"view_new_container\""
|
||||
" class=\"Tml_WIDTH Tml_SEP VERY_LIGHT_BLUE\""
|
||||
" style=\"display:none;\"");
|
||||
|
||||
|
@ -474,7 +475,7 @@ void Tml_Pub_PutLinkToViewNewPubs (void)
|
|||
|
||||
/* Text */
|
||||
HTM_TxtF ("%s (",Txt_See_new_activity);
|
||||
HTM_SPAN_Begin ("id=\"view_new_posts_count\"");
|
||||
HTM_SPAN_Begin ("id=\"view_new_count\"");
|
||||
HTM_Unsigned (0);
|
||||
HTM_SPAN_End ();
|
||||
HTM_Txt (")");
|
||||
|
@ -497,7 +498,7 @@ void Tml_Pub_PutLinkToViewOldPubs (void)
|
|||
|
||||
/***** Animated link to view old publications *****/
|
||||
/* Begin container */
|
||||
HTM_DIV_Begin ("id=\"view_old_posts_container\""
|
||||
HTM_DIV_Begin ("id=\"view_old_pubs_container\""
|
||||
" class=\"Tml_WIDTH Tml_SEP VERY_LIGHT_BLUE\"");
|
||||
|
||||
/* Begin anchor */
|
||||
|
|
Loading…
Reference in New Issue