src/lib/htmshell.c 1.47
1.47 2009/05/15 18:57:17 tdreszer
Handle html warnings as alerts
Index: src/lib/htmshell.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/htmshell.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -b -B -U 4 -r1.46 -r1.47
--- src/lib/htmshell.c 2 Dec 2008 01:34:56 -0000 1.46
+++ src/lib/htmshell.c 15 May 2009 18:57:17 -0000 1.47
@@ -203,14 +203,33 @@
/* Write an error message. */
{
va_list argscp;
va_copy(argscp, args);
+#define WARN_USE_ALERT
+#ifdef WARN_USE_ALERT
+static boolean noWarningsYet = TRUE;
+char warning[512];
+vsprintf(warning,format, args);
+if(noWarningsYet)
+ {
+ // This will only be put into the document once (DO NOT depend on jQuery!)
+ puts("<div id='allWarnings' style='display:none;'>Warnings:</div>");
+ puts("<script type='text/javascript'>function addWarning(warning) {docllument.getElementById('allWarnings').innerHTML += '\\n\\n'+warning;};</script>");
+ puts("<script type='text/javascript'>function warn() {setTimeout(\"alert(document.getElementById('allWarnings').innerHTML);\",50); return true;};onload=warn();</script>");
+ noWarningsYet=FALSE;
+ }
+strSwapChar(warning,'\n',' ');
+printf("%s", htmlWarnStartPattern());
+printf("<script type='text/javascript'>addWarning(\"%s\");</script>\n",warning);
+printf("%s", htmlWarnEndPattern());
+#else//ifndef WARN_USE_ALERT
htmlHorizontalLine();
printf("%s", htmlWarnStartPattern());
htmlVaParagraph(format,args);
printf("%s", htmlWarnEndPattern());
htmlHorizontalLine();
+#endif//ndef WARN_USE_ALERT
/* Log useful CGI info to stderr */
logCgiToStderr();