From 1b813dc1a05da9f64c307873d60e44216ec2fdc9 Mon Sep 17 00:00:00 2001 From: "Rune K. Svendsen" Date: Mon, 11 Nov 2024 13:40:57 +0100 Subject: [PATCH] Fix 655e6211764dc205636f04a0ab2d67e50abb3760 This commit in question was meant to revert only setting maxCount=100000, levels=1000 and defaultLimit = 100000. But it accidentally also reverted another useful change: giving the SVG graph an ID so other SVG elements on the page don't interfere with the functionality of the "open graph in new window"-button. --- src/server/Server/Pages/Search.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/server/Server/Pages/Search.hs b/src/server/Server/Pages/Search.hs index 233fe49..0d81ce5 100644 --- a/src/server/Server/Pages/Search.hs +++ b/src/server/Server/Pages/Search.hs @@ -193,11 +193,13 @@ page cfg (SearchEnv graph lookupVertex) srcTxt dstTxt maxCount' mNoGraph = do resultGraphE pure $ do h3_ "Result graph" + let addSvgElemId = T.replace " svgGraphId <> "\" ") -- hacky way to add an "id" attribute to the SVG graph + svgGraphId = "graph" either (const $ mkErrorText "Failed to render result graph") - toHtmlRaw -- 'toHtmlRaw' because 'resultGraph' contains tags we don't want escaped + (toHtmlRaw . addSvgElemId) -- 'toHtmlRaw' because 'resultGraph' contains tags we don't want escaped resultGraphE - openSvgInNewWindowBtn + openSvgInNewWindowBtn svgGraphId noResultsText :: (FunGraph.FullyQualifiedType, FunGraph.FullyQualifiedType) -> Html () noResultsText (src, dst) = @@ -283,8 +285,8 @@ page cfg (SearchEnv graph lookupVertex) srcTxt dstTxt maxCount' mNoGraph = do mkResultAttribute :: T.Text -> Attribute mkResultAttribute = data_ "result-number" -openSvgInNewWindowBtn :: Html () -openSvgInNewWindowBtn = do +openSvgInNewWindowBtn :: T.Text -> Html () +openSvgInNewWindowBtn svgGraphId = do button_ [ id_ btnId , style_ "visibility:hidden; display:none;" -- Hide the button if JS is disabled @@ -299,7 +301,7 @@ openSvgInNewWindowBtn = do , " btnElem.style.visibility = \"visible\";" , " // open SVG in new window on click" , " btnElem.onclick = (evt) => {" - , " const svg = document.querySelector(\"svg\");" + , " const svg = document.getElementById(\"" <> svgGraphId <> "\");" , " const as_text = new XMLSerializer().serializeToString(svg);" , " const blob = new Blob([as_text], { type: \"image/svg+xml\" });" , " const url = URL.createObjectURL(blob);"