Просмотр исходного кода

스킨 취소선 제거 기능 + 버그 수정

Surplus_Up (2DU) 7 лет назад
Родитель
Сommit
784f1b8b6e
2 измененных файлов с 74 добавлено и 1 удалено
  1. 4 1
      func.py
  2. 70 0
      views/neo_yousoro/js/main.js

+ 4 - 1
func.py

@@ -763,7 +763,10 @@ def rd_plus(title, sub, date):
         curs.execute("insert into rd (title, sub, date) values (?, ?, ?)", [title, sub, date])
 
 def history_plus(title, data, date, ip, send, leng):
-    curs.execute("insert into history (id, title, data, date, ip, send, leng, hide) values (?, ?, ?, ?, ?, ?, ?, '')", [str(int(id_data[0][0]) + 1), title, data, date, ip, send, leng])
+    curs.execute("select id from history where title = ? order by id + 0 desc limit 1", [title])
+    id_data = curs.fetchall()
+    
+    curs.execute("insert into history (id, title, data, date, ip, send, leng, hide) values (?, ?, ?, ?, ?, ?, ?, '')", [str(int(id_data[0][0]) + 1) if id_data else '1', title, data, date, ip, send, leng])
 
 def leng_check(first, second):
     if first < second:

+ 70 - 0
views/neo_yousoro/js/main.js

@@ -1,3 +1,37 @@
+// 쿠키 생성
+function setCookie(name, value, expiredays) {
+    var cookie = name + "=" + escape(value) + "; path=/;"
+    if (typeof expiredays != 'undefined') {
+        var todayDate = new Date();
+        todayDate.setDate(todayDate.getDate() + expiredays);
+        cookie += "expires=" + todayDate.toGMTString() + ";"
+    }
+    document.cookie = cookie;
+}
+ 
+// 쿠키 획득
+function getCookie(name) {
+    name += "=";
+    var cookie = document.cookie;
+    var startIdx = cookie.indexOf(name);
+    if (startIdx != -1) {
+        startIdx += name.length;
+        var endIdx = cookie.indexOf(";", startIdx);
+        if (endIdx == -1) {
+            endIdx = cookie.length;
+            return unescape(cookie.substring(startIdx, endIdx));
+        }
+    }
+    return null;
+}
+ 
+// 쿠키 삭제
+function deleteCookie(name) {
+    setCookie(name, "", -1);
+}
+
+// http://vip00112.tistory.com/33
+
 function opening(data) {
     var element = document.getElementById(data);
     if(element.style.display == 'none') {
@@ -5,4 +39,40 @@ function opening(data) {
     } else {
         element.style.display = 'none';
     }
+}
+
+function get_post() {
+    check = document.getElementById('strike');
+    if(check.checked == true) {
+        setCookie("set_strike", "1");
+    } else {
+        deleteCookie("set_strike");
+    }
+    
+    window.location.reload(true);
+}
+
+head_data = document.querySelector('head');
+if(getCookie("set_strike") == "1") {
+    head_data.innerHTML += '<style>s { display: none; }';
+}
+
+window.onload = function () {
+    if(window.location.pathname == '/skin_set') {
+        document.getElementById("main_top").innerHTML = '<h1>skin setting</h1>';
+        data = document.getElementById("main_data")
+        
+        set_data = {};
+        if(getCookie("set_strike") == "1") {
+            set_data["strike"] = "checked";
+        } 
+        
+        data.innerHTML =    `
+                            <input ` + set_data["strike"] + ` type="checkbox" id="strike" name="strike" value="strike"> remove strikethrough
+                            <hr>
+                            <button onclick="get_post();">Save</button>
+                            `;
+                            
+        document.title = document.title.replace(/.*(\- .*)$/, "skin setting $1");
+    }
 }