From 54c6d47c9f079ef8a74cba5eadecbef08773894b Mon Sep 17 00:00:00 2001
From: Saad bin Abid <abid@fortiss.org>
Date: Thu, 28 May 2020 16:53:17 +0200
Subject: [PATCH] added separate js and remove the redundant scripts from MIRA
 Requirements htmls.

Issue-Ref: 4007
Issue-Url: https://af3-developer.fortiss.org/issues/4007

Signed-off-by: Saad bin Abid <abid@fortiss.org>
---
 .../html/requirements/MIRA.glossary.html      | 22 +-----------------
 .../html/requirements/MIRA.requirements.html  | 22 +-----------------
 .../MIRA.requirements_analysis.html           | 23 +------------------
 .../html/requirements/jsscript/topBtn.js      | 20 ++++++++++++++++
 4 files changed, 23 insertions(+), 64 deletions(-)
 create mode 100644 org.fortiss.af3.rcp.help/html/requirements/jsscript/topBtn.js

diff --git a/org.fortiss.af3.rcp.help/html/requirements/MIRA.glossary.html b/org.fortiss.af3.rcp.help/html/requirements/MIRA.glossary.html
index 314ee3b..b6d99d2 100644
--- a/org.fortiss.af3.rcp.help/html/requirements/MIRA.glossary.html
+++ b/org.fortiss.af3.rcp.help/html/requirements/MIRA.glossary.html
@@ -91,27 +91,7 @@ When you add a picture it is copied into the <i>Images</i> folder in the project
 If you want to send the model file to someone else, you should also send the <i>Images</i> folder. </p>
 </div>
 
-<!-- TODO (SB): Move to separate .js file -->
-<script>
-//Get the button
-var upButton = document.getElementById("upBtn");
-
-// When the user scrolls down 20px from the top of the document, show the button
-window.onscroll = function() {scrollFunction()};
-
-function scrollFunction() {
-  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
-    upButton.style.display = "block";
-  } else {
-    upButton.style.display = "none";
-  }
-}
-
-// When the user clicks on the button, scroll to the top of the document
-function topFunction() {
-  document.body.scrollTop = 0;
-  document.documentElement.scrollTop = 0;
-}
+<script src="jsscript/topBtn.js">
 </script>
 </body>
 </html>
\ No newline at end of file
diff --git a/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements.html b/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements.html
index df9dbc8..e79442b 100644
--- a/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements.html
+++ b/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements.html
@@ -80,27 +80,7 @@
 
 </div>
 
-<!-- TODO (SB): Move to separate .js file -->
-<script>
-//Get the button
-var upButton = document.getElementById("upBtn");
-
-// When the user scrolls down 20px from the top of the document, show the button
-window.onscroll = function() {scrollFunction()};
-
-function scrollFunction() {
-  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
-    upButton.style.display = "block";
-  } else {
-    upButton.style.display = "none";
-  }
-}
-
-// When the user clicks on the button, scroll to the top of the document
-function topFunction() {
-  document.body.scrollTop = 0;
-  document.documentElement.scrollTop = 0;
-}
+<script src="jsscript/topBtn.js">
 </script>
 </body>
 </html>
\ No newline at end of file
diff --git a/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements_analysis.html b/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements_analysis.html
index 249728b..461096c 100644
--- a/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements_analysis.html
+++ b/org.fortiss.af3.rcp.help/html/requirements/MIRA.requirements_analysis.html
@@ -64,28 +64,7 @@
 	<p>The list of requirements can be sorted by clicking on the column headers of the overview list. 
 	You can filter the requirements by inserting filter text in the filter section. Double-clicking on a requirement opens the corresponding requirement.</p>
 </div>
-
-<!-- TODO (SB): Move to separate .js file -->
-<script>
-//Get the button
-var upButton = document.getElementById("upBtn");
-
-// When the user scrolls down 20px from the top of the document, show the button
-window.onscroll = function() {scrollFunction()};
-
-function scrollFunction() {
-  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
-    upButton.style.display = "block";
-  } else {
-    upButton.style.display = "none";
-  }
-}
-
-// When the user clicks on the button, scroll to the top of the document
-function topFunction() {
-  document.body.scrollTop = 0;
-  document.documentElement.scrollTop = 0;
-}
+<script src="jsscript/topBtn.js">
 </script>
 </body>
 </html>
\ No newline at end of file
diff --git a/org.fortiss.af3.rcp.help/html/requirements/jsscript/topBtn.js b/org.fortiss.af3.rcp.help/html/requirements/jsscript/topBtn.js
new file mode 100644
index 0000000..6226708
--- /dev/null
+++ b/org.fortiss.af3.rcp.help/html/requirements/jsscript/topBtn.js
@@ -0,0 +1,20 @@
+
+//Get the button
+var upButton = document.getElementById("upBtn");
+
+// When the user scrolls down 20px from the top of the document, show the button
+window.onscroll = function() {scrollFunction()};
+
+function scrollFunction() {
+  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
+    upButton.style.display = "block";
+  } else {
+    upButton.style.display = "none";
+  }
+}
+
+// When the user clicks on the button, scroll to the top of the document
+function topFunction() {
+  document.body.scrollTop = 0;
+  document.documentElement.scrollTop = 0;
+}
\ No newline at end of file
-- 
GitLab