af730d9e24c0642fe39657f890bc117ed015ccbf galt Wed Feb 15 01:12:26 2017 -0800 CSP code cleanup. Using new var-args versions of functions jsInlineF and jsOnEventByIdF to avoid using lots of fixed-size local javascript strings. diff --git src/hg/hgCustom/hgCustom.c src/hg/hgCustom/hgCustom.c index 50cbbea..0caef77 100644 --- src/hg/hgCustom/hgCustom.c +++ src/hg/hgCustom/hgCustom.c @@ -562,34 +562,32 @@ printf("%s:", hgTracksName(), cartSidUrlString(cart),pos, pos, chrom); else puts(" "); } else puts(" "); } if (errCt) { if (ct->networkErrMsg) { char id[256]; safef(id, sizeof id, "_%d", butCount); printf("\nShow\n", id); - char javascript[1024]; - safef(javascript, sizeof javascript, "alert('%s');return false;", + jsOnEventByIdF("click", id, "alert('%s');return false;", javaScriptLiteralEncode(ct->networkErrMsg)); - jsOnEventById("click", id, javascript); } else puts(" "); } /* Delete checkboxes */ printf("", showAllButtons ? 2 : 1); safef(buf, sizeof(buf), "%s_%s", hgCtDeletePrefix, ct->tdb->track); cgiMakeCheckBoxJS(buf, setAllDelete, "class='deleteCheckbox'"); puts(""); /* Update checkboxes */ if (updateCt) { printf("", showAllButtons ? 2 : 1); @@ -781,39 +779,37 @@ { pos = ctInitialPosition(ctList); if (!pos) pos = ctFirstItemPos(ctList); } puts(""); makeOtherCgiForm(pos); puts(""); /* button to add custom tracks */ puts(""); printf("\n", "add custom tracks"); -char javascript[1024]; -safef(javascript, sizeof javascript, +// This submits mainForm with a hidden input that tells hgCustom to show add tracks page: +jsOnEventByIdF("click", "addTracksButton", "var $form = $(\"form[name='mainForm']\"); " "$form.append(\"\"); " "$form.submit();" , hgCtDoAdd); -// This submits mainForm with a hidden input that tells hgCustom to show add tracks page: -jsOnEventById("click", "addTracksButton", javascript); puts(""); puts(""); puts(""); cgiTableRowEnd(); cgiTableEnd(); // This vertically aligns the 'add tracks' button with the other-CGI select jsInline( "function fitUnder($el1, $el2) { " " var off1 = $el1.offset(); " " var off2 = $el2.offset(); " " off2.left = off1.left; "