mirror of
https://github.com/tgbot-collection/YYeTsBot.git
synced 2025-11-25 03:15:05 +08:00
clear cache checkbox
This commit is contained in:
8
.gitattributes
vendored
8
.gitattributes
vendored
@@ -1,7 +1,13 @@
|
||||
worker/public/css/* linguist-vendored
|
||||
worker/public/fonts/* linguist-vendored
|
||||
worker/public/img/* linguist-vendored
|
||||
worker/public/js/* linguist-vendored
|
||||
|
||||
worker/public/js/aYin.js linguist-vendored
|
||||
worker/public/js/bootstrap.min.js linguist-vendored
|
||||
worker/public/js/rrshare.js linguist-vendored
|
||||
worker/public/js/vue.js linguist-vendored
|
||||
worker/public/js/jquery* linguist-vendored
|
||||
|
||||
worker/public/404.html linguist-vendored
|
||||
worker/public/index.html linguist-vendored
|
||||
worker/public/resource.html linguist-vendored
|
||||
6
worker/public/index.html
vendored
6
worker/public/index.html
vendored
@@ -42,7 +42,10 @@
|
||||
<h2>在 <a style="text-decoration: none;color: deepskyblue" href="https://t.me/yyets_bot">这个 Telegram Bot</a>
|
||||
里去使用,或者使用下方搜索框</h2>
|
||||
<form action="search.html">
|
||||
<input name="kw" type="text">
|
||||
<label>
|
||||
<input name="kw" type="text">
|
||||
</label>
|
||||
<input type="checkbox" id="clear_cache" onclick="reloadIndex()"> <label for="clear_cache">清除缓存</label>
|
||||
<input type="submit" value="搜索">
|
||||
</form>
|
||||
<h2>有问题联系 <a style="text-decoration: none;color: green" href="https://t.me/BennyThink">Benny小可爱</a></h2>
|
||||
@@ -50,4 +53,5 @@
|
||||
src="img/200-wrangler-ferris.gif">
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/search.js"></script>
|
||||
</html>
|
||||
|
||||
60
worker/public/js/search.js
Normal file
60
worker/public/js/search.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const baseURL = "https://yyets.dmesg.app/";
|
||||
const resourceURL = baseURL + "resource.html?id=";
|
||||
const indexURL = baseURL + "?id=index";
|
||||
|
||||
// const indexURL = "css/index.json"
|
||||
|
||||
|
||||
function loadJSON(path, success, error) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
if (success)
|
||||
success(JSON.parse(xhr.responseText));
|
||||
} else {
|
||||
if (error)
|
||||
error(xhr);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.open("GET", path, true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
let search = document.getElementById("kw");
|
||||
if (kw !== "undefined") {
|
||||
search.value = kw;
|
||||
}
|
||||
|
||||
let data = JSON.parse(localStorage.getItem("index"));
|
||||
let div = document.getElementById("tv");
|
||||
let found = false
|
||||
for (let v in data) {
|
||||
if (v.toLowerCase().indexOf(kw) !== -1) {
|
||||
found = true
|
||||
let name = v.replace(/\n/g, " ")
|
||||
let id = data[v]
|
||||
let html = `<h3><a style="text-decoration: none;color: cornflowerblue" href="${resourceURL}${id}">${name}</a></h3>`;
|
||||
let backup = div.innerHTML;
|
||||
div.innerHTML = backup + html;
|
||||
}
|
||||
}
|
||||
if (found === false) {
|
||||
div.innerHTML = `<h2>没有搜索到结果 (ノへ ̄、)</h2>`
|
||||
}
|
||||
}
|
||||
|
||||
function reloadIndex() {
|
||||
loadJSON(indexURL,
|
||||
function (data) {
|
||||
let jsonText = JSON.stringify(data);
|
||||
localStorage.setItem("index", jsonText);
|
||||
|
||||
},
|
||||
function (xhr) {
|
||||
console.error(xhr);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -40,7 +40,10 @@
|
||||
<h2>在 <a style="text-decoration: none;color: deepskyblue" href="https://t.me/yyets_bot">这个 Telegram Bot</a>
|
||||
里去使用,或者使用下方搜索框</h2>
|
||||
<form action="search.html">
|
||||
<input name="kw" id="kw" type="text">
|
||||
<label>
|
||||
<input name="kw" id="kw" type="text">
|
||||
</label>
|
||||
<input type="checkbox" id="clear_cache" onclick="reloadIndex()"> <label for="clear_cache">清除缓存</label>
|
||||
<input type="submit" value="搜索">
|
||||
</form>
|
||||
|
||||
@@ -51,54 +54,8 @@
|
||||
<h2>有问题请联系 <a style="text-decoration: none;color: green" href="https://t.me/BennyThink">Benny小可爱</a></h2>
|
||||
</div>
|
||||
</body>
|
||||
<script src="js/search.js"></script>
|
||||
<script>
|
||||
function loadJSON(path, success, error) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
if (success)
|
||||
success(JSON.parse(xhr.responseText));
|
||||
} else {
|
||||
if (error)
|
||||
error(xhr);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.open("GET", path, true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
function doSearch() {
|
||||
let search = document.getElementById("kw");
|
||||
if (kw !== "undefined") {
|
||||
search.value = kw;
|
||||
}
|
||||
|
||||
let data = JSON.parse(localStorage.getItem("index"));
|
||||
let div = document.getElementById("tv");
|
||||
let found = false
|
||||
for (let v in data) {
|
||||
if (v.toLowerCase().indexOf(kw) !== -1) {
|
||||
found = true
|
||||
let name = v.replace(/\n/g, " ")
|
||||
let id = data[v]
|
||||
let html = `<h3><a style="text-decoration: none;color: cornflowerblue" href="${resourceURL}${id}">${name}</a></h3>`;
|
||||
let backup = div.innerHTML;
|
||||
div.innerHTML = backup + html;
|
||||
}
|
||||
}
|
||||
if (found === false) {
|
||||
div.innerHTML = `<h2>没有搜索到结果 (ノへ ̄、)</h2>`
|
||||
}
|
||||
}
|
||||
|
||||
const baseURL = "https://yyets.dmesg.app/";
|
||||
const resourceURL = baseURL + "resource.html?id=";
|
||||
const indexURL = baseURL + "?id=index";
|
||||
// const indexURL = "css/index.json"
|
||||
|
||||
let kwe = document.URL.split("kw=")[1];
|
||||
let kw = decodeURI(kwe).toLowerCase().replace(" ", "");
|
||||
|
||||
@@ -121,6 +78,5 @@
|
||||
doSearch()
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user