This commit is contained in:
Joseph Cheung 2023-03-01 15:04:24 +08:00
parent 6bd2dea7ba
commit 17373b6392
2 changed files with 18 additions and 18 deletions

View file

@ -857,6 +857,7 @@ def search():
} }
gpt = json.dumps({'data':gpt_data, 'url_pair':url_pair, 'url_proxy':url_proxy, 'raws': raws}) gpt = json.dumps({'data':gpt_data, 'url_pair':url_pair, 'url_proxy':url_proxy, 'raws': raws})
gpt = '<div id="chat_intro"></div><div id="chat"></div>' + r''' gpt = '<div id="chat_intro"></div><div id="chat"></div>' + r'''
<div id="chat_talk"></div>
<div id="modal" class="modal"> <div id="modal" class="modal">
<div id="modal-title" class="modal-title">网页速览<span> <div id="modal-title" class="modal-title">网页速览<span>
<a id="closebtn" href="javascript:void(0);" class="close-modal closebtn"></a></span> <a id="closebtn" href="javascript:void(0);" class="close-modal closebtn"></a></span>
@ -865,7 +866,7 @@ def search():
<div id="iframe-wrapper"> <div id="iframe-wrapper">
<iframe ></iframe> <iframe ></iframe>
# <div id='readability-reader'></div> <div id='readability-reader' style='display:none'></div>
</div> </div>
</div> </div>
</div> </div>
@ -1191,8 +1192,8 @@ function proxify()
} }
function modal_open(url, num) function modal_open(url, num)
{ {
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat_talk').innerHTML;
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_question">'+'打开链接'+'<a class="footnote">'+ String(num) +'</a>'+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_question">'+'打开链接'+'<a class="footnote">'+ String(num) +'</a>'+"</div>";
modal.style.display = 'block'; modal.style.display = 'block';
document.querySelector("#readability-reader").innerHTML = ''; document.querySelector("#readability-reader").innerHTML = '';
var iframePromise = new Promise((resolve, reject) => { var iframePromise = new Promise((resolve, reject) => {
@ -1266,7 +1267,6 @@ function modal_open(url, num)
chatTemp = "" chatTemp = ""
text_offset = -1; text_offset = -1;
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat').innerHTML;
prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>";
fetch("https://search.kg/completions", options) fetch("https://search.kg/completions", options)
.then((response) => { .then((response) => {
@ -1300,7 +1300,7 @@ function modal_open(url, num)
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
markdownToHtml(beautify(chatTemp), document.querySelector("#prompt")) markdownToHtml(beautify(chatTemp), document.querySelector("#prompt"))
proxify() proxify()
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>";
}) })
return reader.read().then(processText); return reader.read().then(processText);
@ -1602,7 +1602,7 @@ proxify()
chatTextRaw = "提问:" + word + "\n回答:"; chatTextRaw = "提问:" + word + "\n回答:";
chatTemp = "" chatTemp = ""
text_offset = -1; text_offset = -1;
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat_talk').innerHTML;
prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>"; prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>";
@ -1639,7 +1639,7 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
markdownToHtml(beautify(chatTemp), document.querySelector("#prompt")) markdownToHtml(beautify(chatTemp), document.querySelector("#prompt"))
proxify() proxify()
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>";
}) })
return reader.read().then(processText); return reader.read().then(processText);
@ -1696,7 +1696,7 @@ proxify()
chatTextRaw = "提问:" + word + "\n回答:"; chatTextRaw = "提问:" + word + "\n回答:";
chatTemp = "" chatTemp = ""
text_offset = -1; text_offset = -1;
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat_talk').innerHTML;
prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>"; prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>";
@ -1733,7 +1733,7 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
markdownToHtml(beautify(chatTemp), document.querySelector("#prompt")) markdownToHtml(beautify(chatTemp), document.querySelector("#prompt"))
proxify() proxify()
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>";
}) })
return reader.read().then(processText); return reader.read().then(processText);

View file

@ -857,6 +857,7 @@ def search():
} }
gpt = json.dumps({'data':gpt_data, 'url_pair':url_pair, 'url_proxy':url_proxy, 'raws': raws}) gpt = json.dumps({'data':gpt_data, 'url_pair':url_pair, 'url_proxy':url_proxy, 'raws': raws})
gpt = '<div id="chat_intro"></div><div id="chat"></div>' + r''' gpt = '<div id="chat_intro"></div><div id="chat"></div>' + r'''
<div id="chat_talk"></div>
<div id="modal" class="modal"> <div id="modal" class="modal">
<div id="modal-title" class="modal-title">网页速览<span> <div id="modal-title" class="modal-title">网页速览<span>
<a id="closebtn" href="javascript:void(0);" class="close-modal closebtn"></a></span> <a id="closebtn" href="javascript:void(0);" class="close-modal closebtn"></a></span>
@ -865,7 +866,7 @@ def search():
<div id="iframe-wrapper"> <div id="iframe-wrapper">
<iframe ></iframe> <iframe ></iframe>
# <div id='readability-reader'></div> <div id='readability-reader' style='display:none'></div>
</div> </div>
</div> </div>
</div> </div>
@ -1191,8 +1192,8 @@ function proxify()
} }
function modal_open(url, num) function modal_open(url, num)
{ {
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat_talk').innerHTML;
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_question">'+'打开链接'+'<a class="footnote">'+ String(num) +'</a>'+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_question">'+'打开链接'+'<a class="footnote">'+ String(num) +'</a>'+"</div>";
modal.style.display = 'block'; modal.style.display = 'block';
document.querySelector("#readability-reader").innerHTML = ''; document.querySelector("#readability-reader").innerHTML = '';
var iframePromise = new Promise((resolve, reject) => { var iframePromise = new Promise((resolve, reject) => {
@ -1266,7 +1267,6 @@ function modal_open(url, num)
chatTemp = "" chatTemp = ""
text_offset = -1; text_offset = -1;
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat').innerHTML;
prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>";
fetch("https://search.kg/completions", options) fetch("https://search.kg/completions", options)
.then((response) => { .then((response) => {
@ -1300,7 +1300,7 @@ function modal_open(url, num)
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
markdownToHtml(beautify(chatTemp), document.querySelector("#prompt")) markdownToHtml(beautify(chatTemp), document.querySelector("#prompt"))
proxify() proxify()
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>";
}) })
return reader.read().then(processText); return reader.read().then(processText);
@ -1602,7 +1602,7 @@ proxify()
chatTextRaw = "提问:" + word + "\n回答:"; chatTextRaw = "提问:" + word + "\n回答:";
chatTemp = "" chatTemp = ""
text_offset = -1; text_offset = -1;
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat_talk').innerHTML;
prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>"; prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>";
@ -1639,7 +1639,7 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
markdownToHtml(beautify(chatTemp), document.querySelector("#prompt")) markdownToHtml(beautify(chatTemp), document.querySelector("#prompt"))
proxify() proxify()
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>";
}) })
return reader.read().then(processText); return reader.read().then(processText);
@ -1696,7 +1696,7 @@ proxify()
chatTextRaw = "提问:" + word + "\n回答:"; chatTextRaw = "提问:" + word + "\n回答:";
chatTemp = "" chatTemp = ""
text_offset = -1; text_offset = -1;
prev_chat = document.getElementById('chat').innerHTML; prev_chat = document.getElementById('chat_talk').innerHTML;
prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>"; prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#prompt").innerHTML+"</div>";
@ -1733,7 +1733,7 @@ prev_chat = prev_chat+'<div class="chat_question">'+document.querySelector("#pro
document.querySelector("#prompt").innerHTML=""; document.querySelector("#prompt").innerHTML="";
markdownToHtml(beautify(chatTemp), document.querySelector("#prompt")) markdownToHtml(beautify(chatTemp), document.querySelector("#prompt"))
proxify() proxify()
document.getElementById('chat').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>"; document.getElementById('chat_talk').innerHTML = prev_chat+'<div class="chat_answer">'+document.querySelector("#prompt").innerHTML+"</div>";
}) })
return reader.read().then(processText); return reader.read().then(processText);