changeset 2398:37b2acb15a40

Remove javascript from the non-JS HTML maps.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 09 Nov 2021 02:46:48 +0200
parents b76c25ad1b99
children 6a29605d1e2d
files src/colormap.c world/Makefile.inc
diffstat 2 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/colormap.c	Tue Nov 09 02:23:25 2021 +0200
+++ b/src/colormap.c	Tue Nov 09 02:46:48 2021 +0200
@@ -40,7 +40,8 @@
         optCheatMode = FALSE,
         optNoHeaders = FALSE,
         optPosGlue = FALSE,
-        optCityFormat = FALSE;
+        optCityFormat = FALSE,
+        optUseJS = FALSE;
 
 int     optOutputFormat = 0,
         optBackColor = 0;
@@ -64,6 +65,7 @@
     { 12,'P', "pos-glue",       "Generate JavaScript, etc. for posglue", OPT_NONE },
     { 13,'c', "city-format",    "Input is a city map", OPT_NONE },
     { 14,'u', "urchin-file",    "Specify urchin file", OPT_ARGREQ },
+    { 15,'J', "use-js",         "Include javascript bits", OPT_NONE },
 };
 
 static const int optListN = sizeof(optList) / sizeof(optList[0]);
@@ -211,8 +213,13 @@
 {
     char buf[32];
 
+    if (optUseJS)
+    {
+        fprintf(outFile,
+        " <script type=\"text/javascript\" src=\"util.js\"></script>\n");
+    }
+
     fprintf(outFile,
-    " <script type=\"text/javascript\" src=\"util.js\"></script>\n"
     " <style type=\"text/css\">\n"
     "  <!--\n"
     "  %s." XHTML_LOCLABEL " { background: white; color: black; %s}\n"
@@ -301,8 +308,18 @@
     }
 
     fprintf(outFile,
-    "</head>\n"
+    "</head>\n");
+
+    if (optUseJS)
+    {
+    fprintf(outFile,
     "<body onload=\"mapOnLoad();\">\n");
+    }
+    else
+    {
+    fprintf(outFile,
+    "<body>\n");
+    }
 
     if (!optPosGlue)
     {
@@ -688,6 +705,11 @@
         THMSG(2, "Urchin filename set to '%s'.\n", optUrchinFile);
         break;
 
+    case 15:
+        optUseJS = TRUE;
+        THMSG(2, "Including Javascript bits.\n");
+        break;
+
     default:
         THERR("Unknown option '%s'.\n", currArg);
         return FALSE;
--- a/world/Makefile.inc	Tue Nov 09 02:23:25 2021 +0200
+++ b/world/Makefile.inc	Tue Nov 09 02:46:48 2021 +0200
@@ -30,7 +30,7 @@
 	$(COLORMAP_BIN) $(COLORMAP_OPTS) $(COLORMAP_HTML) $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp,%.desc,$<)`" -o $@ $<
 
 %.html: %.tmp2 %.desc %.tmp3 $(COLORMAP_BIN)
-	$(COLORMAP_BIN) $(COLORMAP_OPTS) $(COLORMAP_HTML) -P $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp2,%.desc,$<)`" $< | \
+	$(COLORMAP_BIN) $(COLORMAP_OPTS) -J $(COLORMAP_HTML) -P $(COLORMAP_EXTRA) -t "`cat $(patsubst %.tmp2,%.desc,$<)`" $< | \
 	sed -e "/@LOCATIONS@/r $(patsubst %.tmp2,%.tmp3,$<)" -e "s/@LOCATIONS@//g" > $@