5db18ae05a21e122258f156fb5e62c15cfdf98f9
kent
  Mon Dec 9 11:28:37 2013 -0800
Removing jsonGlabalsHash from library routines.  Now it is restricted to hgTrackUi.
diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c
index 62f05fe..d6f6198 100644
--- src/hg/hgTrackUi/hgTrackUi.c
+++ src/hg/hgTrackUi/hgTrackUi.c
@@ -2791,42 +2791,65 @@
 static void findSuperChildrenAndSettings(struct trackDb *tdbList, struct trackDb *super)
 /* Find the tracks that have super as a parent and stuff references to them on
  * super's children list. Also do some visibility and parentName futzing. */
 {
 struct trackDb *tdb;
 for (tdb = tdbList; tdb != NULL; tdb = tdb->next)
     {
     if (tdb->parent == super)
         {
 	trackDbSuperMemberSettings(tdb);  /* This adds tdb to tdb->parent->children. */
 	}
     }
 }
 #endif /* UNUSED */
 
+struct jsonElement *jsonGlobalsHash = NULL; 
+
+void jsonPrintGlobals(boolean wrapWithScriptTags)
+// prints out the "common" globals json hash
+// This hash is the one utils.js and therefore all CGIs know about
+{
+if (jsonGlobalsHash != NULL)
+    {
+    if (wrapWithScriptTags)
+        printf("<script type='text/javascript'>\n");
+    jsonPrint(jsonGlobalsHash, "common", 0);
+    if (wrapWithScriptTags)
+        printf("</script>\n");
+    }
+}
+
+void jsonObjectAddGlobal(char *name, struct jsonElement *ele)
+/* Add json object to global hash */
+{
+if (jsonGlobalsHash == NULL)
+    jsonGlobalsHash = newJsonObject(newHash(5));
+jsonObjectAdd(jsonGlobalsHash, name, ele);
+}
 
 void trackUi(struct trackDb *tdb, struct trackDb *tdbList, struct customTrack *ct, boolean ajax)
 /* Put up track-specific user interface. */
 {
 if (!ajax)
     {
     jsIncludeFile("jquery.js", NULL);
     webIncludeResourceFile("jquery-ui.css");
     jsIncludeFile("jquery-ui.js", NULL);
     jsIncludeFile("utils.js",NULL);
-    jsonObjectAdd(NULL, "track", newJsonString(tdb->track));
-    jsonObjectAdd(NULL, "db", newJsonString(database));
+    jsonObjectAddGlobal("track", newJsonString(tdb->track));
+    jsonObjectAddGlobal("db", newJsonString(database));
     }
 #define RESET_TO_DEFAULTS "defaults"
 char setting[128];
 
 // NOTE: Currently only composite multi-view tracks because
 // reset relies upon all cart vars following naming convention:
 //   {track}.{varName}...  ( One exception supported: {track}_sel ).
 
 if (trackDbLocalSetting(tdb, "container"))
     {
     /* For the moment, be a composite... */
     tdbMarkAsComposite(tdb);
     }
 if (ajax && cartOptionalString(cart, "descriptionOnly"))
     {