From cadcd37408317a77f65c648ca3569ec31674b336 Mon Sep 17 00:00:00 2001
From: adrien <adrien@malingrey.fr>
Date: Sun, 20 Oct 2024 13:49:04 +0200
Subject: [PATCH] export toast

---
 templates/cards.xsl         | 35 ++++-------------------------------
 templates/compact.xsl       | 37 +++++--------------------------------
 templates/servicesTable.xsl | 35 ++++-------------------------------
 3 files changed, 13 insertions(+), 94 deletions(-)

diff --git a/templates/cards.xsl b/templates/cards.xsl
index ec05bec..0284a97 100755
--- a/templates/cards.xsl
+++ b/templates/cards.xsl
@@ -6,6 +6,7 @@
 
     <xsl:import href="lib/parseCommand.xsl"/>
     <xsl:import href="lib/serviceLabel.xsl"/>
+    <xsl:import href="lib/toast.xsl"/>
 
     <xsl:output method="html" encoding="UTF-8"/>
     <xsl:output indent="yes"/>
@@ -130,37 +131,9 @@ Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254"/>
                 <script>
 $('.ui.dropdown').dropdown()
 
-<xsl:if test="runstats/finished/@summary">
-$.toast({
-    title      : '<xsl:value-of select="runstats/finished/@exit"/>',
-    message    : '<xsl:value-of select="runstats/finished/@summary"/>',
-    showIcon   : 'satellite dish',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
-<xsl:if test="runstats/finished/@errormsg">
-$.toast({
-    title      : '<xsl:value-of select="runstats/finished/@exit"/>',
-    message    : '<xsl:value-of select="runstats/finished/@errormsg"/>',
-    showIcon   : 'exclamation triangle',
-    class      : 'error',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
-<xsl:if test="$init">
-$.toast({
-    message    : 'Comparaison avec les résultats du <xsl:value-of select="$init/runstats/finished/@timestr"/>',
-    class      : 'info',
-    showIcon   : 'calendar',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
+<xsl:apply-templates select="runstats">
+    <xsl:with-param name="init" select="$init"/>
+</xsl:apply-templates>
 
 hiddenButton.onclick = function(event) {
     if (lanScanForm.checkValidity()) {
diff --git a/templates/compact.xsl b/templates/compact.xsl
index f881be4..6f94846 100755
--- a/templates/compact.xsl
+++ b/templates/compact.xsl
@@ -4,7 +4,8 @@
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     version="1.1">
 
-    <xsl:import href="lib/parseCommand.xsl"/> 
+    <xsl:import href="lib/parseCommand.xsl"/>
+    <xsl:import href="lib/toast.xsl"/> 
 
     <xsl:output method="html" encoding="UTF-8"/>
     <xsl:output indent="yes"/>
@@ -163,37 +164,9 @@ table.order([1, 'asc']).draw()
 
 $('.ui.dropdown').dropdown()
 
-<xsl:if test="runstats/finished/@summary">
-$.toast({
-    title      : '<xsl:value-of select="runstats/finished/@exit"/>',
-    message    : '<xsl:value-of select="runstats/finished/@summary"/>',
-    showIcon   : 'satellite dish',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
-<xsl:if test="runstats/finished/@errormsg">
-$.toast({
-    title      : '<xsl:value-of select="runstats/finished/@exit"/>',
-    message    : '<xsl:value-of select="runstats/finished/@errormsg"/>',
-    showIcon   : 'exclamation triangle',
-    class      : 'error',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
-<xsl:if test="$init">
-$.toast({
-    message    : 'Comparaison avec les résultats du <xsl:value-of select="$init/runstats/finished/@timestr"/>',
-    class      : 'info',
-    showIcon   : 'calendar',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
+<xsl:apply-templates select="runstats">
+    <xsl:with-param name="init" select="$init"/>
+</xsl:apply-templates>
 
 hiddenButton.onclick = function(event) {
     if (lanScanForm.checkValidity()) {
diff --git a/templates/servicesTable.xsl b/templates/servicesTable.xsl
index d7bdd70..db4ac45 100755
--- a/templates/servicesTable.xsl
+++ b/templates/servicesTable.xsl
@@ -5,6 +5,7 @@
     version="1.1">
 
     <xsl:import href="lib/parseCommand.xsl"/> 
+    <xsl:import href="lib/toast.xsl"/>
 
     <xsl:output method="html" encoding="UTF-8"/>
     <xsl:output indent="yes"/>
@@ -145,37 +146,9 @@ table.order([1, 'asc']).draw()
 
 $('.ui.dropdown').dropdown()
 
-<xsl:if test="runstats/finished/@summary">
-$.toast({
-    title      : '<xsl:value-of select="runstats/finished/@exit"/>',
-    message    : '<xsl:value-of select="runstats/finished/@summary"/>',
-    showIcon   : 'satellite dish',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
-<xsl:if test="runstats/finished/@errormsg">
-$.toast({
-    title      : '<xsl:value-of select="runstats/finished/@exit"/>',
-    message    : '<xsl:value-of select="runstats/finished/@errormsg"/>',
-    showIcon   : 'exclamation triangle',
-    class      : 'error',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
-<xsl:if test="$init">
-$.toast({
-    message    : 'Comparaison avec les résultats du <xsl:value-of select="$init/runstats/finished/@timestr"/>',
-    class      : 'info',
-    showIcon   : 'calendar',
-    displayTime: 0,
-    closeIcon  : true,
-    position   : 'bottom right',
-})
-</xsl:if>
+<xsl:apply-templates select="runstats">
+    <xsl:with-param name="init" select="$init"/>
+</xsl:apply-templates>
 
 hiddenButton.onclick = function(event) {
     if (lanScanForm.checkValidity()) {