From f6d1022757919755356edd3f19d26dd663e0fe20 Mon Sep 17 00:00:00 2001 From: James Feng Cao Date: Fri, 16 Dec 2022 17:48:23 +0800 Subject: [PATCH] enhance config.js --- en/searchurl/config.js | 33 ++++++++++++++++++++------------- index.html | 11 +---------- zh/searchurl/config.js | 31 +++++++++++++++++++------------ 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/en/searchurl/config.js b/en/searchurl/config.js index 6845b85..edf4f02 100644 --- a/en/searchurl/config.js +++ b/en/searchurl/config.js @@ -1,12 +1,7 @@ let labels = ["Default font","Cursive","Fantasy","Fixed","Sans-Serif","Serif"]; let names = ["font","cursive","fantasy","fixed","sansserif","serif"]; -let text; let d=document; -if(d.body) - text = d.body.innerHTML; -else - text = "\n".repeat(labels.length-1); let sa = [` @@ -24,15 +19,27 @@ let sa = [` '&'+ f.fixed.value + '&'+ f.sansserif.value + '&'+ f.serif.value + -':https://fastly.jsdelivr.net/gh/torappinfo/uwebzh/searchurl/template/config.html';return false;" accept-charset=utf-8 >`]; +':https://fastly.jsdelivr.net/gh/torappinfo/uweb/searchurl/template/config.html';return false;" accept-charset=utf-8 >`]; +function gen(text) { + let strs = text.split('\n'); + let i=0; + for (i = 0; i < labels.length; i++){ + sa.push(""); + } -let strs = text.split('\n'); -let i=0; -for (i = 0; i < labels.length; i++){ - sa.push(""); + sa.push(''); + let r = sa.join('
'); + d.documentElement.innerHTML = r; } -sa.push(''); -let r = sa.join('
'); -d.documentElement.innerHTML = r; +if(d.body){ + fetch(location.href) + .then(res => res.text()) + .then(text => { + gen(text); + }); +}else { + let text = "\n".repeat(labels.length-1); + gen(text); +} diff --git a/index.html b/index.html index 33185bf..db7d507 100644 --- a/index.html +++ b/index.html @@ -1,10 +1 @@ - - - - en/ - - - - - - + diff --git a/zh/searchurl/config.js b/zh/searchurl/config.js index 39651e8..3579477 100644 --- a/zh/searchurl/config.js +++ b/zh/searchurl/config.js @@ -1,12 +1,7 @@ let labels = ["网页默认字体族","cursive字体族","Fantasy字体族","Fixed字体族","Sans-Serif字体族","Serif字体族"]; let names = ["font","cursive","fantasy","fixed","sansserif","serif"]; -let text; let d=document; -if(d.body) - text = d.body.innerHTML; -else - text = "\n".repeat(labels.length-1); let sa = [` @@ -26,13 +21,25 @@ let sa = [` '&'+ f.serif.value + ':https://fastly.jsdelivr.net/gh/torappinfo/uweb/searchurl/template/config.html';return false;" accept-charset=utf-8 >`]; +function gen(text) { + let strs = text.split('\n'); + let i=0; + for (i = 0; i < labels.length; i++){ + sa.push(""); + } -let strs = text.split('\n'); -let i=0; -for (i = 0; i < labels.length; i++){ - sa.push(""); + sa.push(''); + let r = sa.join('
'); + d.documentElement.innerHTML = r; } -sa.push(''); -let r = sa.join('
'); -d.documentElement.innerHTML = r; +if(d.body){ + fetch(location.href) + .then(res => res.text()) + .then(text => { + gen(text); + }); +}else { + let text = "\n".repeat(labels.length-1); + gen(text); +}