فهرست منبع

토론 작동 안하는 버그 수정

잉여개발기 (SPDV) 3 سال پیش
والد
کامیت
2ac94e3522
7فایلهای تغییر یافته به همراه46 افزوده شده و 19 حذف شده
  1. 9 1
      route/api_topic.py
  2. 1 3
      route/tool/func.py
  3. 1 1
      route/topic.py
  4. 3 8
      route/topic_list.py
  5. 1 1
      version.json
  6. 0 1
      views/main_css/js/func/insert_version_skin.js
  7. 31 4
      views/main_css/js/route/thread.js

+ 9 - 1
route/api_topic.py

@@ -20,7 +20,15 @@ def api_topic(topic_num = 1, tool = 'normal', num = ''):
                         "select id, data, date, ip, block, top from topic where code = ? order by id + 0 asc"
                         "select id, data, date, ip, block, top from topic where code = ? order by id + 0 asc"
                     ), [
                     ), [
                         topic_num
                         topic_num
-                    ]) 
+                    ])
+            elif tool == 'length':
+                curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
+                db_data = curs.fetchall()
+
+                if db_data:
+                    return flask.jsonify({ 'length' : db_data[0][0] })
+                else:
+                    return flask.jsonify({})
             else:
             else:
                 curs.execute(db_change(
                 curs.execute(db_change(
                     "select id, data, date, ip, block, top from topic where code = ? and top = 'O' order by id + 0 asc"
                     "select id, data, date, ip, block, top from topic where code = ? and top = 'O' order by id + 0 asc"

+ 1 - 3
route/tool/func.py

@@ -1031,9 +1031,7 @@ def wiki_css(data):
     
     
     # Route JS + Defer
     # Route JS + Defer
     data_css += '<script defer src="/views/main_css/js/route/edit.js?ver=' + data_css_ver + '"></script>'
     data_css += '<script defer src="/views/main_css/js/route/edit.js?ver=' + data_css_ver + '"></script>'
-    
-    # Route JS
-    data_css += '<script src="/views/main_css/js/route/thread.js?ver=' + data_css_ver + '"></script>'
+    data_css += '<script defer src="/views/main_css/js/route/thread.js?ver=' + data_css_ver + '"></script>'
     
     
     # 레거시 일반 JS
     # 레거시 일반 JS
     data_css += '<script src="/views/main_css/js/load_editor.js?ver=' + data_css_ver + '"></script>'
     data_css += '<script src="/views/main_css/js/load_editor.js?ver=' + data_css_ver + '"></script>'

+ 1 - 1
route/topic.py

@@ -153,7 +153,7 @@ def topic(topic_num = 0):
                     </form>
                     </form>
                     <hr class="main_hr">
                     <hr class="main_hr">
                     <div id="see_preview"></div>
                     <div id="see_preview"></div>
-                    <script>opennamu_do_thread_make("''' + topic_num + '''");</script>
+                    <!-- JS : opennamu_do_thread_make -->
                 ''',
                 ''',
                 menu = [['topic/' + url_pas(name), load_lang('list')]]
                 menu = [['topic/' + url_pas(name), load_lang('list')]]
             ))
             ))

+ 3 - 8
route/topic_list.py

@@ -37,14 +37,9 @@ def topic_list(name = 'Test'):
 
 
             div += '''
             div += '''
                 <h2><a href="/thread/''' + data[0] + '">' + data[0] + '. ' + html.escape(data[1]) + '''</a></h2>
                 <h2><a href="/thread/''' + data[0] + '">' + data[0] + '. ' + html.escape(data[1]) + '''</a></h2>
-                <div id="topic_pre_''' + data[0] + '''"></div>
-                <div id="topic_back_pre_''' + data[0] + '''"></div>
-                <script>
-                    opennamu_do_thread_make(''' + data[0] + ', "list", "/normal/1", "topic_pre_' + data[0] + '''");
-                    if(''' + t_data[0][0] + ''' !== 1) {
-                        opennamu_do_thread_make(''' + data[0] + ', "list", "/normal/' + t_data[0][0] + '", "topic_back_pre_' + data[0] + '''");
-                    }
-                </script>
+                <div class="topic_pre" id="opennamu_thread_''' + data[0] + '''"></div>
+                <div class="topic_back_pre" id="opennamu_thread_back_''' + data[0] + '''"></div>
+                <!-- JS : opennamu_do_thread_make -->
             '''
             '''
 
 
         if div == '':
         if div == '':

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
 {
     "beta" : {
     "beta" : {
-        "r_ver" : "v3.4.5 (stable2) (beta3) (dev44)",
+        "r_ver" : "v3.4.5 (stable2) (beta3) (dev45)",
         "c_ver" : "3500113",
         "c_ver" : "3500113",
         "s_ver" : "3500110"
         "s_ver" : "3500110"
     }
     }

+ 0 - 1
views/main_css/js/func/insert_version_skin.js

@@ -26,6 +26,5 @@ let opennamu_do_insert_version_skin_url = [
     '/manager'
     '/manager'
 ];
 ];
 if(opennamu_do_insert_version_skin_url.includes(window.location.pathname)) {
 if(opennamu_do_insert_version_skin_url.includes(window.location.pathname)) {
-    console.log('t')
     opennamu_do_insert_version_skin('ver_send_3');
     opennamu_do_insert_version_skin('ver_send_3');
 }
 }

+ 31 - 4
views/main_css/js/route/thread.js

@@ -11,8 +11,8 @@ function opennamu_do_thread_make(topic_num, type_do = 'top', some = '', where =
     }
     }
 
 
     let xhr = new XMLHttpRequest();
     let xhr = new XMLHttpRequest();
-    xhr.open("GET", url, true);
-    xhr.send(null);
+    xhr.open("GET", url);
+    xhr.send();
 
 
     xhr.onreadystatechange = function() {
     xhr.onreadystatechange = function() {
         if(this.readyState === 4 && this.status === 200) {
         if(this.readyState === 4 && this.status === 200) {
@@ -112,6 +112,7 @@ function opennamu_do_thread_make(topic_num, type_do = 'top', some = '', where =
                     '<hr class="main_hr">' + 
                     '<hr class="main_hr">' + 
                 ''
                 ''
 
 
+                console.log(where);
                 document.getElementById(where).innerHTML += data_a;
                 document.getElementById(where).innerHTML += data_a;
                 
                 
                 count += 1;
                 count += 1;
@@ -154,10 +155,36 @@ function opennamu_do_thread_make(topic_num, type_do = 'top', some = '', where =
 }
 }
 
 
 function opennamu_do_open_comment(key) {
 function opennamu_do_open_comment(key) {
-    let elementState = document.getElementById('opennamu_comment_data_' + key).style.display;
-    if(!elementState || elementState === 'none') {
+    let element_state = document.getElementById('opennamu_comment_data_' + key).style.display;
+    if(!element_state || element_state === 'none') {
         document.getElementById('opennamu_comment_data_' + key).style.display = 'block';
         document.getElementById('opennamu_comment_data_' + key).style.display = 'block';
     } else {
     } else {
         document.getElementById('opennamu_comment_data_' + key).style.display = 'none';
         document.getElementById('opennamu_comment_data_' + key).style.display = 'none';
     }
     }
+}
+
+if(window.location.pathname.match(/^\/thread\//)) {
+    let thread_num = window.location.pathname.match(/^\/thread\/([0-9]+)/)[1];
+
+    opennamu_do_thread_make(thread_num);
+} else if(window.location.pathname.match(/^\/topic\//)) {
+    for(let for_a = 0; document.getElementsByClassName('topic_pre')[for_a]; for_a++) {
+        let thread_num = document.getElementsByClassName('topic_pre')[for_a].id;
+        thread_num = thread_num.match(/^opennamu_thread_([0-9]+)/)[1];
+
+        opennamu_do_thread_make(thread_num, "list", "/normal/1", "opennamu_thread_" + thread_num);
+
+        let xhr = new XMLHttpRequest();
+        xhr.open("GET", "/api/thread/" + thread_num + "/length");
+        xhr.send();
+
+        xhr.onreadystatechange = function() {
+            if(this.readyState === 4 && this.status === 200) {
+                let thread_length = JSON.parse(this.responseText)['length'];
+                if(thread_length !== '1') {
+                    opennamu_do_thread_make(thread_num, "list", "/normal/" + thread_length, "opennamu_thread_back_" + thread_num);
+                }
+            }
+        }
+    }
 }
 }