Parcourir la source

id로 잘못 쓰던 부분 class로 변경

Surplus_Up (2DU) il y a 6 ans
Parent
commit
c0f1b15943

+ 1 - 1
route/list_please.py

@@ -14,7 +14,7 @@ def list_please_2(conn):
     curs.execute(db_change("select distinct title from back where type = 'no' order by title asc limit ?, 50"), [sql_num])
     data_list = curs.fetchall()
     for data in data_list:
-        div += '<li><a id="not_thing" href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
+        div += '<li><a class="not_thing" href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
 
     div += '</ul>' + next_fix('/please?num=', num, data_list)
 

+ 1 - 1
route/search_deep.py

@@ -21,7 +21,7 @@ def search_deep_2(conn, name):
     if curs.fetchall():
         link_id = ''
     else:
-        link_id = 'id="not_thing"'
+        link_id = 'class="not_thing"'
 
     div =   '''
             <ul>

+ 1 - 1
route/tool/func.py

@@ -620,7 +620,7 @@ def ip_pas(raw_ip, type_d = 0):
             if curs.fetchall():
                 ip = '<a href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
             else:
-                ip = '<a id="not_thing" href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
+                ip = '<a class="not_thing" href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
 
             if admin_check('all', None, raw_ip) == 1:
                 ip = '<b>' + ip + '</b>'

+ 3 - 3
route/tool/set_mark/namumark.py

@@ -533,7 +533,7 @@ def namumark(conn, data, title, main_num, include_num):
 
                 plus_data += '<script>load_include("' + include_link + '", "include_' + str(i) + '", ' + str(include_plus_data) + ');</script>'
             else:
-                data = include_re.sub('<a id="not_thing" href="/w/' + tool.url_pas(include_link) + '">[' + include_link + ']</a>', data, 1)
+                data = include_re.sub('<a class="not_thing" href="/w/' + tool.url_pas(include_link) + '">[' + include_link + ']</a>', data, 1)
         else:
             break
 
@@ -972,7 +972,7 @@ def namumark(conn, data, title, main_num, include_num):
                 else:
                     data = re.sub(
                         '\[\[((?:(?!\[\[|\]\]).)+)\]\]',
-                        '<a id="not_thing" href="/upload?name=' + tool.url_pas(file_name) + '">' + file_alt + '</a>',
+                        '<a class="not_thing" href="/upload?name=' + tool.url_pas(file_name) + '">' + file_alt + '</a>',
                         data,
                         1
                     )
@@ -1053,7 +1053,7 @@ def namumark(conn, data, title, main_num, include_num):
                         if main_link != '':
                             curs.execute(tool.db_change("select title from data where title = ?"), [main_link])
                             if not curs.fetchall():
-                                link_id = 'id="not_thing"'
+                                link_id = 'class="not_thing"'
 
                                 backlink += [[title, main_link, 'no']]
                             else:

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

@@ -6,7 +6,7 @@ input { width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box
 table { border-collapse: collapse; }
 td { border: 1px solid; padding: 5px; }
 a { text-decoration: none; }
-#not_thing { color: red; }
+.not_thing { color: red; }
 #inside, #out_link, #open { color: green; }
 #out_link::before { background: green; color: white; content: "E"; }
 input[type="checkbox"] { width: auto; }

+ 87 - 10
views/main_css/js/render_namumark.js

@@ -12,6 +12,29 @@ function render_namumark(target) {
         '';
     }
 
+    function get_link_state(link_list, i) {
+        if(link_list[i]) {
+            get_link_state(link_list, i + 1);
+            
+            var xhr = new XMLHttpRequest();
+            xhr.open("GET", "/api/w/" + encodeURI(link_list[i][0]) + "?exist=1", true);
+            xhr.send(null);
+            
+            xhr.onreadystatechange = function() {
+                if(this.readyState === 4 && this.status === 200) {
+                    console.log(JSON.parse(this.responseText)['exist']);
+                    if(JSON.parse(this.responseText)['exist'] !== '1') {
+                        document.getElementById(link_list[i][1]).className = "not_thing";
+                    } else {
+                        document.getElementById(link_list[i][1]).className = "";
+                    }
+                } else {
+                    document.getElementById(link_list[i][1]).className = "not_thing";
+                }
+            }
+        }
+    }
+
     var data = '\n' + document.getElementById(target).innerHTML + '\n';
     var nowiki_list = [];
 
@@ -163,6 +186,29 @@ function render_namumark(target) {
     data = data.replace(/\^\^((?:(?!\^\^).)+)\^\^/g, '<sup>$1</sup>');
     data = data.replace(/,,((?:(?!,,).)+),,/g, '<sub>$1</sub>');
 
+    data = data.replace(/\n( {1,})\* ([^\n]+)/g, function(all, margin_data, in_data) {
+        return '<li style="margin-left: ' + String(margin_data.length * 20) + 'px;">' + in_data + '</li>'
+    });
+
+    data = data.replace(/\n( {1,})/g, function(all, margin_data) {
+        return '\n<span style="margin-left: ' + String(margin_data.length * 10) + 'px"></span>'
+    });
+
+    var link_list = [];
+    var link_num = 0;
+    data = data.replace(/\[\[((?:(?!]]).)+)]]/g, function(all, in_data) {
+        if(in_data.match(/^(?:[^|]+)\|(?:.+)$/)) {
+            return in_data.replace(/^([^|]+)\|([^|]+)$/, function(all, front_data, back_name) {
+                link_list.push([front_data, 'link_' + String(link_num)]);
+                link_num += 1;
+
+                return '<a id="link_' + String(link_num - 1) + '" href="/w/' + encodeURI(front_data) + '">' + back_name + '</a>'; 
+            });   
+        } else {
+            
+        }
+    });
+
     data = data.replace(/\[([^(\]]+)\(((?:(?!\)]).)+)\)]/g, function(all, name, in_data) {
         if(name.match(/^youtube|kakaotv|nicovideo$/i)) {
             var video_code = in_data.match(/^([^,]+)/);
@@ -294,7 +340,8 @@ function render_namumark(target) {
 
     var ref_num = 0;
     var ref_data = '<hr><ul id="footnote_data">';
-    data = data.replace(/(?:\[\* ([^\]]+)\]|\[(?:각주|footnote)])/g, function(all, in_data) {
+    var name_ref_data = {};
+    data = data.replace(/(?:\[\*([^ ]*)(?: ([^\]]+))?\]|\[(?:각주|footnote)])/g, function(all, name_data, in_data) {
         if(all.match(/^\[(?:각주|footnote)]$/i)) {
             var new_ref_data = ref_data;
             ref_data = '<hr><ul id="footnote_data">';
@@ -302,23 +349,53 @@ function render_namumark(target) {
             return new_ref_data + '</ul>';
         } else {
             ref_num += 1;
-            ref_data += '' +
-                '<li>' +
-                    '(' + String(ref_num) + ') ' + in_data +
-                '</li>' +
-            ''
+            if(name_data) {
+                if(in_data) {
+                    name_ref_data[name_data] = in_data;
+
+                    ref_data += '' +
+                        '<li>' +
+                            '<a id="fn-' + name_data + '" href="#rfn-' + String(ref_num) + '">(' + name_data + ')</a> ' + in_data + ''
+                        '</li>' +
+                    ''    
+                } else {
+                    ref_data += '' +
+                        '<li>' +
+                            '<a href="#rfn-' + String(ref_num) + '">(' + name_data + ')</a>' +
+                        '</li>' +
+                    ''
+                }
+            } else {
+                ref_data += '' +
+                    '<li>' +
+                        '<a id="fn-' + String(ref_num) + '" href="#rfn-' + String(ref_num) + '">(' + String(ref_num) + ')</a> ' + in_data + ''
+                    '</li>' +
+                ''
+            }
 
-            return '' +
+            if(name_data) {
+                return '' +
+                    '<sup>' +
+                        '<a href="#fn-' + name_data + '" id="rfn-' + String(ref_num) + '" title="' + name_ref_data[name_data].replace(/<([^>]*)>/g, '') + '">' +
+                            '(' + name_data + ')' +
+                        '</a>' +
+                    '</sup>' +
+                '';
+            } else {
+                return '' +
                 '<sup>' +
-                    '<a href="#" title="' + in_data.replace(/<([^>]*)>/g, '') + '">' +
+                    '<a href="#fn-' + String(ref_num) + '" id="rfn-' + String(ref_num) + '" title="' + in_data.replace(/<([^>]*)>/g, '') + '">' +
                         '(' + String(ref_num) + ')' +
                     '</a>' +
                 '</sup>' +
             '';
+            }
         }
     });
 
-    data += ref_data;
+    if(ref_data !== '<hr><ul id="footnote_data">') {
+        data += ref_data + '</ul>';
+    }
 
     i = 0;
     while(1) {
@@ -342,7 +419,6 @@ function render_namumark(target) {
     var i = 0;
     while(1) {
         if(math_list[i]) {
-            console.log(i);
             try {
                 katex.render(math_list[i][1], document.getElementById(math_list[i][0]));
             } catch {
@@ -357,5 +433,6 @@ function render_namumark(target) {
         }
     }
 
+    get_link_state(link_list, 0);
     render_html("html_render_contect");    
 }