mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
ebrowser 1.0.26
This commit is contained in:
parent
e29bf0538d
commit
17932d8843
7 changed files with 26 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
|||
{"version":"1.0.24",
|
||||
{"version":"1.0.26",
|
||||
"name": "ebrowser",
|
||||
"description": "The keyboard-friendly minimal suckless web browser",
|
||||
"main": "webview.js",
|
||||
|
|
|
@ -365,8 +365,7 @@ function topMenu(){
|
|||
addrCommand(":update");
|
||||
}},
|
||||
{ label: 'Help', accelerator: 'F1', click: ()=>{
|
||||
let js="tabs.children[iTab].src='file://'+__dirname+'/README.md'";
|
||||
win.webContents.executeJavaScript(js,false)
|
||||
help();
|
||||
}},
|
||||
{ label: 'Stop', accelerator: 'Ctrl+C', click: ()=>{
|
||||
let js="tabs.children[iTab].stop()"
|
||||
|
@ -534,7 +533,7 @@ async function updateApp(url){//url must ending with "/"
|
|||
msg = "remote package.json corrupted"
|
||||
break;
|
||||
}
|
||||
iV = iV + 11;
|
||||
iV = iV + 10;
|
||||
let iE = head.indexOf('"',iV+4);
|
||||
let iS = head.lastIndexOf('.',iE-1);
|
||||
let nLatestVer = parseInt(head.substring(iS+1,iE));
|
||||
|
@ -587,3 +586,19 @@ async function writeFile(filename, str){
|
|||
});
|
||||
});
|
||||
}
|
||||
function help(){
|
||||
const readme = "README.md";
|
||||
const htmlFN = path.join(__dirname,readme+".html");
|
||||
if(!fs.existsSync(htmlFN)){
|
||||
const readmeP = path.join(__dirname,readme);
|
||||
try {
|
||||
fs.copyFileSync(readmeP, htmlFN);
|
||||
const postscript ="<script src='https://cdn.jsdelivr.net/npm/marked@12.0.2/marked.min.js'></script><script>var d=document;var b=d.body;var t=b.textContent;t=t.slice(0,t.length-253);b.innerHTML=marked.parse(t);d.title=d.title||b.firstElementChild.innerText.trim();</script>";
|
||||
fs.appendFileSync(htmlFN,postscript);
|
||||
}catch(e){
|
||||
htmlFN = readmeP;
|
||||
}
|
||||
}
|
||||
let js=`tabs.children[iTab].src="file://${htmlFN}"`;
|
||||
win.webContents.executeJavaScript(js,false)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue