2b30b55d6a5b71648296873b570b9d68b4901b6a
galt
  Wed Feb 15 02:21:56 2017 -0800
CSP code cleanup. Using jsInlineF where needed for compact and efficient code, not using fixed-size local javascript strings which could overflow.

diff --git src/hg/hgVai/hgVai.c src/hg/hgVai/hgVai.c
index de80f63..09d7605 100644
--- src/hg/hgVai/hgVai.c
+++ src/hg/hgVai/hgVai.c
@@ -315,72 +315,66 @@
 if (!selHash || hashLookup(selHash, "All"))
     selected = " selected";
 printf("<option%s>All</option>", selected);
 struct slName *option;
 for (option = optionList;  option != NULL;  option = option->next)
     {
     selected = "";
     if (selHash && hashLookup(selHash, option->name))
 	selected = " selected";
     printf("<option%s>%s</option>", selected, option->name);
     }
 printf("</select>\n");
 char shadowVar[1024];
 safef(shadowVar, sizeof(shadowVar), "%s%s", cgiMultListShadowPrefix(), cartVar);
 cgiMakeHiddenVar(shadowVar, "1");
-//
-char javascript[1024];
-safef(javascript, sizeof javascript,
-    "$(document).ready(function(){ ddcl.setup($('#%s')[0]); });\n", cartVar);
-jsInline(javascript);
+jsInlineF("$(document).ready(function(){ ddcl.setup($('#%s')[0]); });\n", cartVar);
 }
 
 void printFilterOptions(struct trackDb *tdb)
 /* Print a collapsible filter section for tdb, with controls depending on tdb->type. */
 {
 char sectionName[512], cartVar[512];
 safef(sectionName, sizeof(sectionName), "%s_filter", tdb->track);
 if (sameString(tdb->type, "factorSource"))
     {
     puts("<TABLE>");
     startSmallCollapsibleSection(sectionName, "filter items", FALSE);
     struct slName *factorOptions = NULL, *cellTypeOptions = NULL, *treatmentOptions = NULL;
     factorSourceListInputProperties(tdb, &factorOptions, &cellTypeOptions,
 				    &treatmentOptions);
     printMultiselect(tdb->track, "factor", "name", factorOptions);
     printMultiselect(tdb->track, "cell type", "cellType", cellTypeOptions);
     printMultiselect(tdb->track, "treatment", "treatment", treatmentOptions);
     puts("<BR>");
     puts("minimum peak score [0-1000]: ");
     safef(cartVar, sizeof(cartVar), "hgva_filter_%s_score", tdb->track);
     char *defaultScore = cartUsualString(cart, cartVar, "0");
     printf("<input type=text name=\"%s\" size=12 value=\"%s\"><BR>",
 	   cartVar, defaultScore);
     // The dimensions of ui-dropdownchecklist multiselects are not correct when
     // the item is hidden.  So, when this filter section is made visible, reinit them.
-    char javascript[1024];
-    safef(javascript, sizeof javascript,
+    jsInlineF(
 	   "$(function(){\n"
 	   "$('tr[id^=\"%s-\"]').bind('show',\n"
 	   "  function(jqev) { \n"
 	   "    var $multisels = $(jqev.target).find('.filterBy');\n"
 	   "    var multiselElList = $multisels.each(function(ix, el){ return el; });\n"
 	   "    ddcl.reinit(multiselElList);"
 	   "  });\n"
 	   "});\n"
 	   , sectionName);
-    jsInline(javascript);
     puts("</TABLE>");
     endCollapsibleSection();
     }
 if (startsWith("bed 5", tdb->type)) //#*** TODO: detect bed# properly
     {
     puts("<TABLE>");
     startSmallCollapsibleSection(sectionName, "filter items", FALSE);
     //#*** Also watch out for noScoreFilter or whatever it's called
     puts("minimum peak score [0-1000]: ");
     safef(cartVar, sizeof(cartVar), "hgva_filter_%s_score", tdb->track);
     char *defaultScore = cartUsualString(cart, cartVar, "0");
     printf("<input type=text name=\"%s\" size=12 value=\"%s\"><BR>",
 	   cartVar, defaultScore);
     puts("</TABLE>");
     endCollapsibleSection();
@@ -1297,35 +1291,33 @@
  *
  * Eventually, we might want a FormatVep that produces structs that are passed
  * forward to multiple output writers... I would want to send it lots of gratorData
  * like a formatter, but it would produce rows like an annoGrator.
  * Maybe annoGrators should accept a bunch of input rows like formatters?
  * or would this grator wrap all the input grators inside?
  */
 
 void doMainPage()
 /* Print out initial HTML of control page. */
 {
 jsInit();
 webIncludeResourceFile("jquery-ui.css");
 webIncludeResourceFile("ui.dropdownchecklist.css");
 boolean alreadyAgreed = cartUsualBoolean(cart, "hgva_agreedToDisclaimer", FALSE);
-char javascript[1024];
-safef(javascript, sizeof javascript,
+jsInlineF(
     "$(document).ready(function() { hgva.disclaimer.init(%s, hgva.userClickedAgree); });\n"
     , alreadyAgreed ? "true" : "false");
-jsInline(javascript);
 addSomeCss();
 printAssemblySection();
 
 puts("<BR>");
 // Make wrapper table for collapsible sections:
 selectVariants();
 char *geneTrack = selectGenes();
 if (geneTrack != NULL)
     {
     selectRegulatory();
     selectAnnotations(geneTrack);
     selectFilters();
     selectOutput();
     submitAndDisclaimer();
     }