mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
add command bookmarks
This commit is contained in:
parent
c408fd8407
commit
a79d00b323
10 changed files with 225 additions and 37 deletions
|
@ -117,14 +117,8 @@ Enable selection</description>
|
|||
|
||||
<guid>/en/bookmark/</guid>
|
||||
<description>Wait for url from other devices
|
||||
Templates Click following links to install bookmark templates, bookmarks saved to the template have corresponding features enabled.
|
||||
&quot;novel.html&quot;: auto reader's mode
|
||||
Termux The following bookmarks need termux. Clicking to run is only allowed from local pages.
|
||||
GNU bc (basic calculator)
|
||||
bc with all extensions
|
||||
Science Physics Feynman lectures
|
||||
Chemistry chemspider
|
||||
molecule SMILES</description>
|
||||
Commands Clicking to run is only allowed from local pages for bookmarks in this section. Users need to either save the bookmarks to local or long press the link =&gt; &quot;open in new tab&quot; to execute.
|
||||
To save the bookmarks to local, users firstly need to install &quot;bookmark&quot; menu by clicking corresponding link in the url services page, then long press the bookmark link =&gt; &quot;open in new tab&quot; =&gt; &quot;Commands&quot; =&gt; &quot;bookmark&quot; to save the bookmark.</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
|
|
|
@ -53,9 +53,7 @@ output;plot %25s'%0A">GNUPlot plot (2D function), needs uweb adapted termux &
|
|||
output;splot %25s'%0A">GNUPlot plot (3D function), needs uweb adapted termux & gnuplot</a></p>
|
||||
<h4 id="shell-command-mode">Shell command mode</h4>
|
||||
<p>Click the following links to make commands appear in address bar, then press "enter" to execute:<br>
|
||||
<a href="i:15cd;toybox mkdir -p /sdcard/Download/app;toybox ln -s /sdcard/Download/app">symbolic link "app" folder to be under the "Download" folder</a></p>
|
||||
<p><a href="i:15cd;cd ../..;toybox cp -r files /sdcard/Download/uweb;toybox rm -rf files;toybox ln -s /sdcard/Download/uweb files">symbolic link configuration folder to "/sdcard/Download/uweb"</a></p>
|
||||
<p><a href="i:15cd /data/data/com.termux/files/home;ln -s ../../../info.torapp.uweb/files uweb">Make uweb configuration folder accessible by file managers with termux installed</a><br>
|
||||
<a href="i:15cd /data/data/com.termux/files/home;ln -s ../../../info.torapp.uweb/files uweb">Make uweb configuration folder accessible by file managers with termux installed</a><br>
|
||||
(<a href="https://wiki.termux.com/wiki/Internal_and_external_storage">File manager list at end of the page</a>)</p>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -48,13 +48,19 @@
|
|||
|
||||
</ul>
|
||||
<p><a href="i:1c">Wait for url from other devices</a></p>
|
||||
<h3 id="commands">Commands</h3>
|
||||
<p>Clicking to run is only allowed from local pages for bookmarks in this section. Users need to either save the bookmarks to local or long press the link => "open in new tab" to execute.</p>
|
||||
<p>To save the bookmarks to local, users firstly need to install "bookmark" menu by clicking corresponding link in the <a href="../urls/index.html">url services</a> page, then long press the bookmark link => "open in new tab" => "Commands" => "bookmark" to save the bookmark.</p>
|
||||
<p><a href="d:mkdir -p /sdcard/Download/uweb;cd /data/data/info.torapp.uweb;cp -r files /sdcard/Download/uweb;rm -rf files;ln -s /sdcard/Download/uweb files:">symbolic link configuration folder to "/sdcard/Download/uweb"</a></p>
|
||||
<p><a href="d:cd /data/data/com.termux/files/home;ln -s ../../../info.torapp.uweb/files uweb:">Make uweb configuration folder accessible by file managers with termux installed</a><br>
|
||||
(<a href="https://wiki.termux.com/wiki/Internal_and_external_storage">File manager list at end of the page</a>)</p>
|
||||
<h4 id="termux">Termux</h4>
|
||||
<p>The following bookmarks need termux.<br>
|
||||
<a href="c:bc -l">GNU bc (basic calculator)</a><br>
|
||||
<a href="c:bc -l *.bc">bc with all extensions</a></p>
|
||||
<h3 id="templates">Templates</h3>
|
||||
<p>Click following links to install bookmark templates, bookmarks saved to the template have corresponding features enabled.<br>
|
||||
<a href="i:0hbookmark/novel.html:https://fastly.jsdelivr.net/gh/torappinfo/uweb/zh/searchurl/bookmark/novel.html">"novel.html": auto reader's mode</a></p>
|
||||
<h3 id="termux">Termux</h3>
|
||||
<p>The following bookmarks need termux. Clicking to run is only allowed from local pages.<br>
|
||||
<a href="c:bc -l">GNU bc (basic calculator)</a><br>
|
||||
<a href="c:bc -l *.bc">bc with all extensions</a></p>
|
||||
<h3 id="science">Science</h3>
|
||||
<h4 id="physics">Physics</h4>
|
||||
<p><a href="https://www.feynmanlectures.caltech.edu/">Feynman lectures</a></p>
|
||||
|
|
|
@ -90,7 +90,7 @@ Click to install the following html5 apps:<br>
|
|||
</ul>
|
||||
<h4 id="mdict-dictionary-lookup-search-engines">mdict dictionary lookup search engines:</h4>
|
||||
<p>Note: the following two mdict.html files are different.<br>
|
||||
i:5ifile:///....../xxx.mdx,xxx.mdd?app=https://uwebzh.netlify.app/en/searchurl/mdict/mdict.html#word=%s</p>
|
||||
i:5ifile:///....../xxx.mdx,xxx.mdd?app=https://cdn.jsdelivr.net/gh/torappinfo/uweb/en/searchurl/mdict/mdict.html#word=%s</p>
|
||||
<p>in which "/.../xxx.mdx,xxx.mdd" is the full path for the mdict dictionary files.</p>
|
||||
<p>i:5ihttps://uwebzh.netlify.app/zh/searchurl/txt/mdict.html?file=mdict/xxx.mdx,mdict/xxx.mdd#word=%s</p>
|
||||
<p>In the above mdict search engine string, the dictionary files (mdx, mdd) must locate in the "app" subfolder under the configuration folder. In above example, the files "xxx.mdx" and "xxx.mdd" locate in the folder ".../app/mdict".</p>
|
||||
|
|
10
en/index.xml
10
en/index.xml
|
@ -232,14 +232,8 @@ Remote javascript is defined in default.rjs. Click the following link to install
|
|||
|
||||
<guid>/en/bookmark/</guid>
|
||||
<description>Wait for url from other devices
|
||||
Templates Click following links to install bookmark templates, bookmarks saved to the template have corresponding features enabled.
|
||||
&quot;novel.html&quot;: auto reader's mode
|
||||
Termux The following bookmarks need termux. Clicking to run is only allowed from local pages.
|
||||
GNU bc (basic calculator)
|
||||
bc with all extensions
|
||||
Science Physics Feynman lectures
|
||||
Chemistry chemspider
|
||||
molecule SMILES</description>
|
||||
Commands Clicking to run is only allowed from local pages for bookmarks in this section. Users need to either save the bookmarks to local or long press the link =&gt; &quot;open in new tab&quot; to execute.
|
||||
To save the bookmarks to local, users firstly need to install &quot;bookmark&quot; menu by clicking corresponding link in the url services page, then long press the bookmark link =&gt; &quot;open in new tab&quot; =&gt; &quot;Commands&quot; =&gt; &quot;bookmark&quot; to save the bookmark.</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
|
|
205
en/searchurl/mdict/mdictt.html~
Normal file
205
en/searchurl/mdict/mdictt.html~
Normal file
|
@ -0,0 +1,205 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>mdict</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/torappinfo/uweb/en/searchurl/mdict/selectize.default.css" media="screen">
|
||||
<style>
|
||||
#btnLookup {
|
||||
border: none;
|
||||
height: 36px;
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
vertical-align: top;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#btnLookup:not([disabled]) {
|
||||
background: #1A4FDD;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#word + .selectize-control {
|
||||
display: inline-block;
|
||||
min-width: 18em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/fengdh/mdict-js/selectize.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/nodeca/pako/dist/pako_inflate.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/bluebird@3.7.2/js/browser/bluebird.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/torappinfo/uweb/en/searchurl/mdict/ripemd128.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/torappinfo/uweb/en/searchurl/mdict/mdict-common.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/torappinfo/uweb/en/searchurl/mdict/mdict-parser.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/torappinfo/uweb/en/searchurl/mdict/mdict-renderer.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Choose a dictionary file (*.mdx + optional *.mdd): <input id="dictfile" type="file" multiple>
|
||||
<p>
|
||||
<input id="word" type="text" value="">
|
||||
<input id="btnLookup" type="button" value="look up" disabled="false">
|
||||
<div id="definition">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
//file:///...mdictstem?app=....html#word=
|
||||
var dictinput = document.getElementById('dictfile');
|
||||
var wordinput = document.getElementById('word');
|
||||
var btnLookup = document.getElementById('btnLookup');
|
||||
var definition = document.getElementById('definition');
|
||||
|
||||
window.onhashchange = function() {
|
||||
let v = location.hash.substring(6);
|
||||
if(v.length>0){
|
||||
wordinput.value = v;
|
||||
//wordinput.dispatchEvent(new Event('change', {'bubbles': true}));
|
||||
btnLookup.click();
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
let v = decodeURIComponent(location.hash.substring(6));
|
||||
wordinput.value = v;
|
||||
}
|
||||
|
||||
$(wordinput).selectize({maxItems: 1});
|
||||
function accept(e) {
|
||||
var fileList = $(e.target).prop('files');
|
||||
$(btnLookup).attr('disabled', true);
|
||||
if (fileList.length > 0) {
|
||||
$(btnLookup).addClass('stripes');
|
||||
$(wordinput).on('keyup', function(e) { e.which === 13
|
||||
&& $(btnLookup).click(); });
|
||||
MParser(fileList).then(function(resources) {
|
||||
var mdict = MRenderer(resources);
|
||||
function doSearch(phrase, offset) {
|
||||
console.log(phrase + '');
|
||||
mdict.lookup(phrase, offset).then(function($content) {
|
||||
$(definition).empty().append($content.contents());
|
||||
console.log('--');
|
||||
});
|
||||
}
|
||||
|
||||
$(btnLookup)
|
||||
.attr('disabled', false)
|
||||
.off('.#mdict')
|
||||
.on('click.#mdict', function() {
|
||||
doSearch($(wordinput).val());
|
||||
}).click();
|
||||
|
||||
$(wordinput)[0].selectize.destroy();
|
||||
|
||||
$(wordinput).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);
|
||||
$(wordinput).val(value);
|
||||
} else {
|
||||
$(definition).empty();
|
||||
}
|
||||
},
|
||||
});
|
||||
}).catch(err => alert(err)) ;
|
||||
} else {
|
||||
$(btnLookup).attr('disabled', false);
|
||||
}
|
||||
|
||||
// jump to word with link started with "entry://"
|
||||
// TODO: have to ignore in-page jump
|
||||
$(definition).on('click', 'a', function(e) {
|
||||
var href = $(this).attr('href');
|
||||
if (href && href.substring(0, 8) === 'entry://') {
|
||||
var word = href.substring(8);
|
||||
// TODO: remove '#' to get jump target
|
||||
if (word.charAt(0) !== '#') {
|
||||
word = word.replace(/(^[/\\])|([/]$)/, '');
|
||||
|
||||
$(wordinput).val(word);
|
||||
$(btnLookup).click();
|
||||
} else {
|
||||
var currentUrl = location.href;
|
||||
location.href = word; //Go to the target element.
|
||||
history.replaceState(null,null,currentUrl);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
$(dictinput).on('change', accept);
|
||||
|
||||
{
|
||||
let path = location.pathname;
|
||||
let iSlash = path.lastIndexOf('/');
|
||||
let filenames=path.substring(iSlash+1);
|
||||
{
|
||||
let iDot = filenames.indexOf('.');
|
||||
document.getElementsByTagName("link")[0].href =
|
||||
filenames.substring(0,iDot+1)+"css";
|
||||
}
|
||||
window.onload = function(){
|
||||
if(filenames.length>0){
|
||||
let clickurl = "i:5fdictinput.click():"+filenames;
|
||||
location.href=clickurl;
|
||||
|
||||
var callbackTimer = setInterval(function() {
|
||||
let files = dictinput.files;
|
||||
if(files.length>0){
|
||||
if(!btnLookup.disabled){
|
||||
clearInterval(callbackTimer);
|
||||
return;
|
||||
}
|
||||
}else
|
||||
location.href=clickurl;
|
||||
dictinput.dispatchEvent(new Event('change', {'bubbles': true}));
|
||||
}, 100);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue