uweb/en/searchurl/config.js

50 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-04-12 00:07:52 +00:00
let labels = ["Global redirect url","Default font","Cursive","Fantasy","Fixed","Sans-Serif","Serif"];
2023-04-11 23:40:52 +00:00
let names = ["redirecturl","font","cursive","fantasy","fixed","sansserif","serif"];
let d=document;
2023-04-11 23:40:52 +00:00
let sa = [`<head><meta charset="utf-8"><meta name="viewport" content="width=device-width" /></head><style>input{height:40px;width:100%;border-radius:50px;}</style>
<datalist id="family">
<option value="sans-serif">
<option value="sans-serif-condensed">
<option value="sans-serif-smallcaps">
<option value="serif">
<option value="serif-monospace">
<option value="monospace">
<option value="cursive">
</datalist>
2023-04-11 23:40:52 +00:00
<form onsubmit="let d=document;let f=d.forms[0];d.location.href='i:0i/data/data/info.torapp.uweb/files/config.html:'
+f.redirecturl.value+
'&'+ f.font.value+
'&'+ f.cursive.value +
'&'+ f.fantasy.value +
'&'+ f.fixed.value +
'&'+ f.sansserif.value +
'&'+ f.serif.value +
2023-04-11 23:40:52 +00:00
':https://fastly.jsdelivr.net/gh/torappinfo/uweb/zh/searchurl/template/config.html';return false;" accept-charset=utf-8 >`];
2022-12-16 09:48:23 +00:00
function gen(text) {
let strs = text.split('\n');
let i=0;
2023-04-11 23:40:52 +00:00
sa.push("<label>"+labels[i]+"<input type='text' name='"+names[i]+"' value='"+strs[i]+"'/></label>");
for (i = 1; i < labels.length; i++){
2022-12-16 09:48:23 +00:00
sa.push("<label>"+labels[i]+"<input list='family' type='text' name='"+names[i]+"' value='"+strs[i]+"'/></label>");
}
2022-12-16 09:48:23 +00:00
sa.push('<input type="submit" value="Save"></form>');
let r = sa.join('<br>');
2023-04-11 23:40:52 +00:00
d.write(r);
d.close();
}
2022-12-16 09:48:23 +00:00
if(d.body){
fetch(location.href)
.then(res => res.text())
.then(text => {
gen(text);
});
}else {
let text = "\n".repeat(labels.length-1);
gen(text);
}