Compare commits
No commits in common. "145a0b279fb550aac4b9e3d5a49f09040b83318a" and "912dcfe3ca5d224ed048aa7d5c6b25e76823d083" have entirely different histories.
145a0b279f
...
912dcfe3ca
11
handler.php
11
handler.php
|
@ -35,6 +35,17 @@ else if (isset($_POST['action']))
|
|||
}
|
||||
break;
|
||||
|
||||
case 'title':
|
||||
$result = array();
|
||||
$str = file_get_contents($_POST['data']);
|
||||
if(strlen($str) > 0)
|
||||
{
|
||||
preg_match("/\<title\>(.*)\<\/title\>/", $str, $title);
|
||||
$result['title'] = $title[1];
|
||||
}
|
||||
echo json_encode($result);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo '{"error": "unknown action ' . $action . '"}';
|
||||
break;
|
||||
|
|
29
main.js
29
main.js
|
@ -34,6 +34,7 @@ var lastsaved = "";
|
|||
var pending = false;
|
||||
var settings = null;
|
||||
var tags = null;
|
||||
var titlemap = {};
|
||||
|
||||
var stat =
|
||||
{
|
||||
|
@ -772,7 +773,32 @@ function showlinkdialog(link)
|
|||
a.setAttribute("href", link);
|
||||
a.setAttribute("target", "_blank");
|
||||
div.onclick = removelinkdialog;
|
||||
a.innerText = link;
|
||||
|
||||
if (settings.sync)
|
||||
{
|
||||
if (titlemap[link])
|
||||
{
|
||||
a.innerHTML = titlemap[link];
|
||||
}
|
||||
else
|
||||
{
|
||||
a.innerText = link;
|
||||
queryremote({action: "title", data: link})
|
||||
.then(res =>
|
||||
{
|
||||
if (res.title)
|
||||
{
|
||||
a.innerHTML = res.title;
|
||||
titlemap[link] = res.title;
|
||||
localStorage.setItem("titlemap", JSON.stringify(titlemap));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
a.innerText = link;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1295,6 +1321,7 @@ function init()
|
|||
|
||||
if (settings.sync)
|
||||
{
|
||||
titlemap = JSON.parse(localStorage.getItem("titlemap")) || {};
|
||||
if (localStorage.getItem("pgpkeys") && localStorage.getItem("pgpkeys").startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----"))
|
||||
{
|
||||
queryremote({action: "fetch"})
|
||||
|
|
Loading…
Reference in New Issue