# HG changeset patch # User Matti Hamalainen # Date 1485269070 -7200 # Node ID 50d005dd22d84462332d1709f467434878ffb2af # Parent 2d7d5940ec4794d932167c2cbccf8432c1a0caf2# Parent 82ecea33c4770f5f47c371482c9be4b7fffda033 Merged. diff -r 2d7d5940ec47 -r 50d005dd22d8 admin.js --- a/admin.js Tue Jan 24 15:49:54 2017 +0200 +++ b/admin.js Tue Jan 24 16:44:30 2017 +0200 @@ -65,7 +65,15 @@ { // Set active tab and refresh contents activeTabs[tabset] = id; - setTimeout("refreshDispatch"+ tabset +"('"+ id +"');", 10); + setTimeout(function(qtabset, qid) { + switch (qtabset) + { + case "CM": refreshDispatchCM(qid); break; + case "CC": refreshDispatchCC(qid); break; + case "CS": refreshDispatchCS(qid); break; + default: jsMessageBox("Invalid tabset value: '"+ qtabset +"'."); + } + }, 10, tabset, id); jsCancelUploadCBS(); } else @@ -223,6 +231,7 @@ case "InfoSys" : jsRefreshItems("tabContCCInfoSys", "infoMain", ""); break; case "Settings" : jsRefreshPanels("CS", "tabContCCSettings", "settingslist", "*"); break; case "Entries" : jsRefreshPanels("CM", "tabContCCEntries", "compolist", ""); break; + default : alert("Invalid id: '"+ id +"'.'"); } } @@ -249,7 +258,7 @@ var msuccess = function(txt) { - setTimeout("refreshDispatchCC('News');", 50); + setTimeout(function () { refreshDispatchCC("News"); }, 50); } if (args != "") @@ -261,7 +270,7 @@ function deleteNews(id) { - jsDeleteItem(id, "news", "news", "refreshDispatchCC('News');", "news item"); + jsDeleteItem(id, "news", "news", function() { refreshDispatchCC("News"); }, "news item"); } @@ -288,7 +297,7 @@ var msuccess = function(txt) { - setTimeout("refreshDispatchCC('Attendees');", 50); + setTimeout(function() { refreshDispatchCC("Attendees"); }, 50); } if (args != "") @@ -300,7 +309,7 @@ function deleteAttendee(id) { - jsDeleteItem(id, "attendee", "attendees", "refreshDispatchCC('Attendees');", "attendee"); + jsDeleteItem(id, "attendee", "attendees", function () { refreshDispatchCC("Attendees"); }, "attendee"); } @@ -365,7 +374,7 @@ var msuccess = function(txt) { - setTimeout("refreshDispatchCC('Compos');", 50); + setTimeout(function () { refreshDispatchCC("Compos"); }, 50); } if (args != "") @@ -412,7 +421,7 @@ function deleteCompo(id) { - jsDeleteItem(id, "compo", "compo", "refreshDispatchCC('Compos');", 0, + jsDeleteItem(id, "compo", "compo", function () { refreshDispatchCC("Compos"); }, 0, "Are you ABSOLUTELY sure you want to delete compo #"+id+"? "+ "This will delete all votes AND entries related to it!"); } @@ -423,7 +432,7 @@ // function refreshEntryCompos() { - setTimeout("refreshDispatchCC('Entries');", 50); + setTimeout(function () { refreshDispatchCC("Entries"); }, 50); } @@ -475,7 +484,7 @@ var msuccess = function(txt) { - setTimeout("refreshDispatchCM("+ id +");", 50); + setTimeout(function (q) { refreshDispatchCM(qid); }, 50, id); refreshEntryCompos(); } @@ -540,7 +549,7 @@ function deleteEntry(cid, id) { jsCancelUploadCBS(); - jsDeleteItem(id, "entry", "entries", "refreshDispatchCM("+ cid +");refreshEntryCompos();", "entry"); + jsDeleteItem(id, "entry", "entries", function() { refreshDispatchCM(cid); refreshEntryCompos(); }, "entry"); } diff -r 2d7d5940ec47 -r 50d005dd22d8 ajax.js --- a/ajax.js Tue Jan 24 15:49:54 2017 +0200 +++ b/ajax.js Tue Jan 24 16:44:30 2017 +0200 @@ -345,12 +345,12 @@ case 200: if (fileCallback) { - var tid = setTimeout(function() + var tid = setTimeout(function(qtid) { - jsRemoveUploadCB(tid); + jsRemoveUploadCB(qtid); setTimeout(fileCallback, 10); //jsTitleMessageBox("File upload", req.responseText); - }, 10); + }, 10, qtid); jsUploadCBS.push(tid); } break; diff -r 2d7d5940ec47 -r 50d005dd22d8 show.js --- a/show.js Tue Jan 24 15:49:54 2017 +0200 +++ b/show.js Tue Jan 24 16:44:30 2017 +0200 @@ -49,11 +49,19 @@ } +function setTickUpdate(qtime) +{ + if (!timeOutSet) + { + timeOutSet = true; + setTimeout(function() { tickMain(); }, qtime); + } +} + + // // Main tick function, check for updates from server // -var timeOutSet = false; - function tickMain() { timeOutSet = false; @@ -64,11 +72,7 @@ if (txt == "changed") { viewChanged(); - if (!timeOutSet) - { - setTimeout("tickMain();", 250); - timeOutSet = true; - } + setTickUpdate(250); } else if (txt == "reload") @@ -77,26 +81,19 @@ } else { - if (!timeOutSet) - { - setTimeout("tickMain();", 500); - timeOutSet = true; - } + setTickUpdate(500); } } var mfail = function(txt) { displayError(); - if (!timeOutSet) - { - setTimeout("tickMain();", 5000); - timeOutSet = true; - } + setTickUpdate(5000); } jsSendPOSTRequest("action=check&lastUpdate="+lastUpdate, msuccess, mfail); } -setTimeout("tickMain();", 100); +var timeOutSet = false; +setTickUpdate(100); viewChanged();