Sfoglia il codice sorgente

저장할 땐 안 뜨게

Surplus_Up (2DU) 6 anni fa
parent
commit
16e4d10c98
4 ha cambiato i file con 20 aggiunte e 7 eliminazioni
  1. 3 3
      route/edit.py
  2. 5 2
      route/tool/func.py
  3. 2 1
      views/main_css/css/main.css
  4. 10 1
      views/main_css/js/do_stop_exit.js

+ 3 - 3
route/edit.py

@@ -115,15 +115,15 @@ def edit_2(conn, name):
             imp = [name, wiki_set(), custom(), other2([' (' + load_lang('edit') + ')', 0])],
             data =  get_name + '''
                 <form method="post">
-                    <script>do_stop_exit()</script>
+                    <script>do_stop_exit();</script>
                     ''' + edit_button() + '''
                     <textarea rows="25" id="content" name="content">''' + html.escape(re.sub('\n$', '', data)) + '''</textarea>
-                    <textarea style="display: none;" name="otent">''' + html.escape(re.sub('\n$', '', data_old)) + '''</textarea>
+                    <textarea id="origin" name="otent">''' + html.escape(re.sub('\n$', '', data_old)) + '''</textarea>
                     <hr class=\"main_hr\">
                     <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
                     <hr class=\"main_hr\">
                     ''' + captcha_get() + ip_warring() + '''
-                    <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                    <button id="save" type="submit" onclick="go_save_zone = 1;">''' + load_lang('save') + '''</button>
                     <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
                 </form>
                 ''' + b_text + '''

+ 5 - 2
route/tool/func.py

@@ -384,7 +384,9 @@ def next_fix(link, num, page, end = 50):
 def other2(data):
     req_list = ''
     
-    css_filter = {}
+    css_filter = {
+        'main.css' : '2'
+    }
     for i_data in os.listdir(os.path.join("views", "main_css", "css")):
         if i_data in css_filter:
             req_list += '<link rel="stylesheet" href="/views/main_css/css/' + i_data + '?ver=' + css_filter[i_data] + '">'
@@ -396,7 +398,8 @@ def other2(data):
         'render_html.js' : '2',
         'do_open_foot.js' : '4',
         'topic_main_load.js' : '2',
-        'topic_plus_load.js' : '2'
+        'topic_plus_load.js' : '2',
+        'do_stop_exit.js' : '2'
     }
     for i_data in os.listdir(os.path.join("views", "main_css", "js")):
         if i_data in js_filter:

+ 2 - 1
views/main_css/css/main.css

@@ -41,4 +41,5 @@ blockquote { background-image: url(/views/acme/img/quote.png); background-positi
 @media (max-width: 768px) { table { min-width: 100%; }}
 @media (max-width: 400px) { .foot_plus { width: 80%; right: calc(100% - 92%); }}
 @media (max-height: 400px) { .foot_plus { height: 80%; top: calc(100% - 92%); }}
-.foot_in { overflow-y: scroll; height: calc(100% - 20px); }
+.foot_in { overflow-y: scroll; height: calc(100% - 20px); }
+#origin { display: none; }

+ 10 - 1
views/main_css/js/do_stop_exit.js

@@ -1,3 +1,12 @@
+var go_save_zone = 0;
+
 function do_stop_exit() {
-    window.onbeforeunload = function(){ return ''; }
+    window.onbeforeunload = function() {
+        console.log(go_save_zone);
+        data = document.getElementById('content').value;
+        origin = document.getElementById('origin').value;
+        if(data !== origin && go_save_zone != 1) {
+            return ''; 
+        }
+    }
 }