mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
rebuilding site Tue Oct 19 03:31:45 PM CST 2021
This commit is contained in:
parent
79755bee5c
commit
72e3c9d151
4 changed files with 108 additions and 5 deletions
|
@ -25,7 +25,7 @@
|
|||
<li><a href="../tags/%e6%90%9c%e7%b4%a2">搜索</a> </li>
|
||||
|
||||
</ul>
|
||||
<p><a target="_self" href="i:0bhttp://cdn.jsdelivr.net/gh/torappinfo/searchurl/searchcat.tar.gz">点击本链接自动安装分类多引擎文件至"/sdcard/uweb/bookmark"目录下</a>。</p>
|
||||
<p><a target="_self" href="i:0bhttps://cdn.jsdelivr.net/gh/torappinfo/uwebzh/searchurl/searchcat.tar.gz">点击本链接自动安装分类多引擎文件至"/sdcard/uweb/bookmark"目录下</a>。</p>
|
||||
<p><a href="..">超微浏览器</a>中通过“设置”->“总目录”->“↑”->“Download”,点击后缀为.search的下载文件,超微浏览器将自动显示分类多引擎搜索。此时可按菜单键(或长按底部工具条后退按钮)选择“添加到桌面”方便以后访问。</p>
|
||||
<p>.search文件每行格式为如下几种:<br>
|
||||
[搜索引擎名]:[不含%s的url]<br>
|
||||
|
|
|
@ -183,6 +183,8 @@
|
|||
<a href="i:00有道词典:yddict://dict/query?q=">有道词典:yddict://dict/query?q=</a><br>
|
||||
<a href="i:00知乎:zhihu://search?q=">知乎:zhihu://search?q=</a><br>
|
||||
<a href="i:00应用商店:market://search?q=">应用商店:market://search?q=</a><br>
|
||||
<a href="i:00微博:sinaweibo://searchall?q=">微博:sinaweibo://searchall?q=</a><br>
|
||||
<a href="i:00bilibili:bilibili://search?keyword=">bilibili:bilibili://search?keyword=</a><br>
|
||||
</p><p>
|
||||
本地引擎(需安装定制termux及相应工具如bc,gnuplot等):<br>
|
||||
<a href="i:00计算器:d:text/html:echo \'%s\'|bc -l -q:">计算器:d:text/html:echo \'%s\'|bc -l -q:</a><br>
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="conf.js"></script>
|
||||
<script src="require.js" data-main="mdict"></script>
|
||||
</head>
|
||||
<body>
|
||||
<section class="main-content">
|
||||
|
@ -69,12 +70,112 @@
|
|||
<div id="dict-title"></div>
|
||||
<div id="definition">
|
||||
</div>
|
||||
<script type="text/javascript" src="conf.js"></script>
|
||||
<script src="require.js" data-main="mdict"></script>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
<script>
|
||||
function AbstractFile(url) {
|
||||
this.name=url;
|
||||
this.slice = async(offset, length) =>{
|
||||
const headers = new Headers();
|
||||
headers.append( 'Range', 'bytes=' + offset + '-' + ( offset + length ).toString() );
|
||||
|
||||
const opts = {
|
||||
credentials: 'include',
|
||||
headers : headers
|
||||
};
|
||||
|
||||
const resp = await fetch( this.name, opts );
|
||||
alert(resp.type);
|
||||
return await resp.blob();
|
||||
}
|
||||
}
|
||||
//?url=#word=
|
||||
let url = location.search.substring(5);
|
||||
let word = location.hash.substring(6);
|
||||
var fileList = [new AbstractFile(url)];
|
||||
|
||||
var mdict;
|
||||
define('mdict-parseXml', function() {
|
||||
return function (str) {
|
||||
return (new DOMParser()).parseFromString(str, 'text/xml');
|
||||
}
|
||||
});
|
||||
|
||||
require(['jquery', 'mdict-common', 'mdict-parser', 'mdict-renderer', 'selectize'], function($, MCommon, MParser, MRenderer, Selectize) {
|
||||
$('#btnLookup').addClass('stripes');
|
||||
$('#word').on('keyup', function(e) { e.which === 13 && $('#btnLookup').click(); });
|
||||
MParser(fileList).then(function(resources) {
|
||||
mdict = MRenderer(resources);
|
||||
|
||||
function doSearch(phrase, offset) {
|
||||
console.log(phrase + '');
|
||||
mdict.lookup(phrase, offset).then(function($content) {
|
||||
$('#definition').empty().append($content.contents());
|
||||
console.log('--');
|
||||
});
|
||||
}
|
||||
|
||||
$('#dict-title').html((resources['mdx'] || resources['mdd']).value().description || '** no description **');
|
||||
mdict.render($('#dict-title'));
|
||||
|
||||
$('#btnLookup')
|
||||
.attr('disabled', false)
|
||||
.off('.#mdict')
|
||||
.on('click.#mdict', function() {
|
||||
doSearch($('#word').val());
|
||||
}).click();
|
||||
$('#word')[0].selectize.destroy();
|
||||
|
||||
$('#word').selectize({
|
||||
plugins: ['restore_on_backspace'],
|
||||
maxItems: 1,
|
||||
maxOptions: 1 << 20,
|
||||
valueField: 'value',
|
||||
labelField: 'word',
|
||||
searchField: 'word',
|
||||
delimiter: '~~',
|
||||
loadThrottle: 10,
|
||||
create: function(v, callback) {
|
||||
return callback({word: v, value: v});
|
||||
},
|
||||
createOnBlur: true,
|
||||
closeAfterSelect: true,
|
||||
allowEmptyOption: true,
|
||||
score: function(search) {
|
||||
var score = this.getScoreFunction(search);
|
||||
return function(item) {return 1;};
|
||||
},
|
||||
load: function(query, callback) {
|
||||
var self = this;
|
||||
if (!query.length) {
|
||||
this.clearOptions();
|
||||
this.refreshOptions();
|
||||
return;
|
||||
};
|
||||
mdict.search({phrase: query, max: 5000}).then(function(list) {
|
||||
// console.log(list.join(', '));
|
||||
// TODO: filter candidate keyword starting with "_"
|
||||
list = list.map(function(v) {
|
||||
return {word: v, value: v.offset};
|
||||
});
|
||||
self.clearOptions();
|
||||
callback(list);
|
||||
});
|
||||
},
|
||||
onChange: function(value) {
|
||||
var item = this.options[value];
|
||||
if (item) {
|
||||
var value = item.word;
|
||||
doSearch(value, value.offset);
|
||||
$('#word').val(value);
|
||||
} else {
|
||||
$('#definition').empty();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
BIN
searchurl/txt/wl.mdx
Normal file
BIN
searchurl/txt/wl.mdx
Normal file
Binary file not shown.
Loading…
Reference in a new issue