diff admin.js @ 1067:82ecea33c477

Various cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 24 Jan 2017 16:43:58 +0200
parents fb5a468e647d
children
line wrap: on
line diff
--- a/admin.js	Tue Jan 24 13:13:48 2017 +0200
+++ b/admin.js	Tue Jan 24 16:43:58 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");
 }