瀏覽代碼

Added mouseover for FSX data messages.

root 4 年之前
父節點
當前提交
6a37d5a61a
共有 4 個文件被更改,包括 44 次插入8 次删除
  1. 26 1
      messages.py
  2. 0 0
      static/js/vendor/easyTooltip.min.js
  3. 7 6
      templates/base.html
  4. 11 1
      templates/message.html

+ 26 - 1
messages.py

@@ -8,6 +8,18 @@ import base64
 import os
 import textwrap
 import sys
+import re
+
+def rot47(s):
+    x = ''
+    for c in s:
+        j = ord(c)
+        if j >= 33 and j <= 126:
+            x += chr(33+ ((j+14) % 94))
+        else:
+            x += c
+    return x
+
 
 base_path = "/messagebase"
 
@@ -46,6 +58,7 @@ bases = {
     "FSXNET-Magicka": "fsx_mag",
     "FSXNET-Mystic": "fsx_mys",
     "FSXNET-Enigma": "fsx_eng",
+    "FSXNET-Data": "fsx_dat",
     # "HappyNet-General": "msgs/hpy_gen",
 }
 
@@ -78,6 +91,8 @@ def bbs_get_messages(area):
     return messages
 
 
+MATCH1 = re.compile(">>> BEGIN(.*)>>> END", re.DOTALL)
+
 def bbs_message(area, msgno):
     global dbc
 
@@ -89,7 +104,8 @@ def bbs_message(area, msgno):
     )
     row = dbc.fetchone()
     stamp = pendulum.parse(row[4]).timestamp()
-    return {
+
+    data = {
         "MsgNum": row[0],
         "number": row[0],
         "to": row[1],
@@ -105,6 +121,15 @@ def bbs_message(area, msgno):
         # // processed
     }
 
+    if (area == 'fsx_dat') and ('>>> BEGIN' in row[5]):
+        body = row[5] + "\n"
+        result = MATCH1.search(body)
+        if result:
+            data['rot47'] = rot47(result.group(1)).lstrip("\n").replace("\n", "<br />")
+
+    return data
+
+
 
 # bases = {"FSX_BOT": "fsx_bot"}
 

文件差異過大導致無法顯示
+ 0 - 0
static/js/vendor/easyTooltip.min.js


+ 7 - 6
templates/base.html

@@ -8,7 +8,12 @@
     <link rel="stylesheet" href="{{ url_for( 'static', filename='css/foundation.css') }}">
     <link rel="stylesheet" href="{{ url_for( 'static', filename='css/app.css') }}">
     <link rel="stylesheet" href="{{ url_for( 'static', filename='style.css') }}">
-  </head>
+    <script src="{{ url_for( 'static', filename='js/vendor/jquery-3.5.1.min.js') }}"></script>
+    <script src="{{ url_for( 'static', filename='js/vendor/easyTooltip.min.js') }}"></script>
+    <script src="{{ url_for( 'static', filename='js/vendor/what-input.js') }}"></script>
+    <script src="{{ url_for( 'static', filename='js/vendor/foundation.min.js') }}"></script>
+    <script src="{{ url_for( 'static', filename='js/app.js') }}"></script>
+   </head>
   <body>
     <div class="grid-container">
       <div class="grid-x grid-padding-x">
@@ -18,11 +23,7 @@
       </div>  
 {% block content %}{% endblock %}
     </div>
-    <script src="{{ url_for( 'static', filename='js/vendor/jquery-3.5.1.min.js') }}"></script>
-    <script src="{{ url_for( 'static', filename='js/vendor/what-input.js') }}"></script>
-    <script src="{{ url_for( 'static', filename='js/vendor/foundation.min.js') }}"></script>
-    <script src="{{ url_for( 'static', filename='js/app.js') }}"></script>
-    <footer class="large-12 callout">
+   <footer class="large-12 callout">
     BZ&amp;BZ BBS
     </footer>
   </body>

+ 11 - 1
templates/message.html

@@ -44,7 +44,17 @@
 <div class="small-12 medium-2 large-2 cell">Text:</div>
 <div class="small-12 medium-10 large-10 cell">{% if message.png is defined %}
   <img alt="Message {{ message.MsgNum }}" src="{{ url_for('display_ansi', area=area, msgno=message.MsgNum ) }}">{% else %}
-  <pre class="oldstyle">{{ message.text }}</pre>{% endif %}
+  <pre id="messagetext" class="oldstyle">{{ message.text }}</pre>
+  {% if message.rot47 is defined %}
+  <script>
+  $("#messagetext").easyTooltip({
+  content: "{{ message.rot47|safe }}",
+  tooltipBgColor: "rgba(200,200,200,1)",
+  tooltipOpacity: 1,
+});
+  </script>
+  {% endif %}
+  {% endif %}
 </div>
 
 </div>

部分文件因文件數量過多而無法顯示