فهرست منبع

show, and hide purple numbers works

Juan 3 ماه پیش
والد
کامیت
93ae397b88
2فایلهای تغییر یافته به همراه141 افزوده شده و 4 حذف شده
  1. 37 0
      src/style.css
  2. 104 4
      src/templates/html.rs

+ 37 - 0
src/style.css

@@ -463,3 +463,40 @@ script {
     width: 50px; /* Adjust the width as needed */
 }
 
+/* Style for the pop-up */
+.popup {
+    display: none;
+    position: fixed;
+    left: 50%;
+    top: 50%;
+    transform: translate(-50%, -50%);
+    border: 1px solid #000;
+    background-color: #fff;
+    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
+    z-index: 10;
+    padding: 20px;
+    width: 300px;
+}
+
+.popup-header {
+    font-weight: bold;
+    margin-bottom: 10px;
+}
+
+.popup-content {
+    margin-bottom: 10px;
+}
+
+.popup-content input {
+    margin-right: 10px;
+}
+
+.popup-close {
+    cursor: pointer;
+    color: red;
+    font-weight: bold;
+}
+
+.transparent {
+    color: transparent;
+}

+ 104 - 4
src/templates/html.rs

@@ -26,7 +26,9 @@ fn header(title: &str, css_path: &str) -> String {
         <meta name="description" content="{title}"/>
         </head>
         <body>
-        <div>
+        <div id="button-container">
+            <!-- class 2 buttons will appear here -->
+        </div>
             <button onclick="window.location.href='../../index.html'">Home</button>
              <input name="" type="button" value="Jump Item:">
              <input type="text" name="textfield" id="textfield" />
@@ -39,7 +41,10 @@ fn header(title: &str, css_path: &str) -> String {
                     <a href="#option3">Turbo Augment</a>
                 </div>
             </div>
+            <!-- Viewspecs button -->
+        <button class="viewspecs-button" onclick="openNewWindow()">Viewspecs</button>
         </div>
+    </div>
 
         <div>
             <b>sort by</b> [<a href='../../authors.html'>author</a>] [<a href='../../dates.html'>dates</a>] [<a href='../../subjects.html'>subjects</a>]
@@ -54,7 +59,25 @@ const FOOTER: &str = r#"
 </html>
 "#;
 
-const JS_SCRIPT_VIEWSPECS: &str = r#"
+fn generate_popup_js() -> String {
+    r#"
+        function toggleNumbering() {
+            const numberingCheckbox = document.getElementById('numbering');
+            const purplenumbers = window.opener.document.querySelectorAll('.purplenumber');
+            purplenumbers.forEach(element => {
+                element.classList.toggle('transparent', !numberingCheckbox.checked);
+            });
+        }
+
+        document.addEventListener('DOMContentLoaded', function() {
+            const numberingCheckbox = document.getElementById('numbering');
+            numberingCheckbox.addEventListener('change', toggleNumbering);
+        });
+    "#.to_string()
+}
+
+
+const JS_SCRIPT_VIEWSPECS: &str = r##"
 <script>
     function showElement(body_id, summary_id){
         const summaries = document.querySelectorAll('.message-meta');
@@ -112,9 +135,10 @@ const JS_SCRIPT_VIEWSPECS: &str = r#"
             const id = document.getElementById('textfield').value;
             if (id) {
                 window.location.href = `#${id}`;
-            }
+                }
         }
 
+
         document.addEventListener('DOMContentLoaded', function() {
             const textfield = document.getElementById('textfield');
             textfield.addEventListener('keydown', function(event) {
@@ -122,9 +146,85 @@ const JS_SCRIPT_VIEWSPECS: &str = r#"
                     jumpToItem();
                 }
             });
+
+        const jumpButton = document.querySelector('input[type="button"][value="Jump Item:"]');
+        jumpButton.addEventListener('click', jumpToItem);
         });
+
+    function openNewWindow() {
+        const popupJs = `
+            function toggleNumbering() {
+                const numberingCheckbox = document.getElementById('numbering');
+                const purplenumbers = window.opener.document.querySelectorAll('.purplenumber');
+                purplenumbers.forEach(element => {
+                    element.classList.toggle('transparent', !numberingCheckbox.checked);
+                });
+            }
+
+            document.addEventListener('DOMContentLoaded', function() {
+                const numberingCheckbox = document.getElementById('numbering');
+                numberingCheckbox.addEventListener('change', toggleNumbering);
+            });
+        `;
+
+        const newWindow = window.open('', '', 'width=400,height=300');
+        newWindow.document.write(`
+            <html>
+            <head>
+                <title>Viewspecs</title>
+                <style>
+                    .popup-content {
+                        font-family: Arial, sans-serif;
+                        font-size: 14px;
+                        margin: 20px;
+                    }
+                    .popup-content fieldset {
+                        border: 1px solid #000;
+                        padding: 10px;
+                    }
+                    .popup-content legend {
+                        padding: 0 10px;
+                        font-weight: bold;
+                    }
+                    .popup-content label {
+                        display: block;
+                        margin-bottom: 5px;
+                    }
+                    .popup-content input {
+                        margin-right: 5px;
+                    }
+                    .accept-button {
+                        margin-top: 10px;
+                        padding: 5px 10px;
+                        font-size: 14px;
+                        cursor: pointer;
+                    }
+                    .transparent {
+                        color: transparent !important;
+                    }
+                </style>
+            </head>
+            <body>
+                <div class="popup-content">
+                    <fieldset>
+                        <legend>Show</legend>
+                        <label><input type="checkbox" id="blankLines"> y z Blank lines</label>
+                        <label><input type="checkbox" id="numbering" checked> m n Numbering</label>
+                        <label><input type="checkbox" id="statementSignatures"> K L Statement signatures</label>
+                    </fieldset>
+                    <button class="accept-button" onclick="window.close()">Accept</button>
+                </div>
+                <script>${popupJs}<\/script>
+            </body>
+            </html>
+        `);
+        newWindow.document.close();
+    }
+
+
+
 </script>
-"#;
+"##;
 
 impl Lists {
     pub fn to_html(&self) -> String {