733819dd56c3d6d3b945236e0c3a06633f6484e3
galt
Wed Feb 15 22:41:29 2017 -0800
CSP - adding name as id for cgiMakeButton. Adding event parameter to event function so it will be available to functions that need it. refs #18538
diff --git src/lib/cheapcgi.c src/lib/cheapcgi.c
index 53d6914..45dbfd9 100644
--- src/lib/cheapcgi.c
+++ src/lib/cheapcgi.c
@@ -202,42 +202,42 @@
}
void checkValidEvent(char *event)
/* check if it is lowercase and a known valid event name */
{
char *temp = cloneString(event);
tolowers(temp);
if (!sameString(temp, event))
warn("jsInline: javascript event %s should be given in lower-case", event);
event = temp;
if (!findJsEvent(event))
warn("jsInline: unknown javascript event %s", event);
freeMem (event);
}
-void jsOnEventById(char *event, char *idText, char *jsText)
+void jsOnEventById(char *eventName, char *idText, char *jsText)
/* Add js mapping for inline event */
{
-checkValidEvent(event);
-jsInlineF("document.getElementById('%s').on%s = function() {%s};\n", idText, event, jsText);
+checkValidEvent(eventName);
+jsInlineF("document.getElementById('%s').on%s = function(event) {%s};\n", idText, eventName, jsText);
}
-void jsOnEventByIdF(char *event, char *idText, char *format, ...)
+void jsOnEventByIdF(char *eventName, char *idText, char *format, ...)
/* Add js mapping for inline event */
{
-checkValidEvent(event);
-jsInlineF("document.getElementById('%s').on%s = function() {", idText, event);
+checkValidEvent(eventName);
+jsInlineF("document.getElementById('%s').on%s = function(event) {", idText, eventName);
va_list args;
va_start(args, format);
dyStringVaPrintf(jsInlineLines, format, args);
va_end(args);
jsInlineF("};\n");
}
//============ END of javascript inline-separation routines ===============
/* These three variables hold the parsed version of cgi variables. */
static char *inputString = NULL;
static unsigned long inputSize;
static struct hash *inputHash = NULL;
@@ -1495,32 +1495,32 @@
void cgiMakeClearButton(char *form, char *field)
/* Make button to clear a text field. */
{
char id[256];
safef(id, sizeof id, "%s_clickBut", form);
char javascript[1024];
safef(javascript, sizeof(javascript),
"document.%s.%s.value = ''; document.%s.submit();", form, field, form);
cgiMakeOnClickButton(id, javascript, " Clear ");
}
void cgiMakeButtonWithMsg(char *name, char *value, char *msg)
/* Make 'submit' type button. Display msg on mouseover, if present*/
{
-printf("");
}
void cgiMakeButtonWithOnClick(char *name, char *value, char *msg, char *onClick)
/* Make 'submit' type button, with onclick javascript */
{
printf("");
jsOnEventById("click", name, onClick);