better email/share functionality
This commit is contained in:
parent
733ddd7cfc
commit
032eaba7de
2 changed files with 19 additions and 19 deletions
|
|
@ -15,6 +15,9 @@ ${header}
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
print([[
|
print([[
|
||||||
|
<a onclick="window.share(this)" href="mailto:friend@your.org?subject=${util.getURL()}&body=check%20this%20on%20your%20XR%20headset">
|
||||||
|
<img src="img/share.svg" class="icon share"/>
|
||||||
|
</a>
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
<hr style="margin-top:0"/>
|
<hr style="margin-top:0"/>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,19 @@
|
||||||
print('<meta http-equiv="refresh" content="0;url=${opts.plugin_diskscan_dirname}">')
|
print('<meta http-equiv="refresh" content="0;url=${opts.plugin_diskscan_dirname}">')
|
||||||
end}
|
end}
|
||||||
</noscript>
|
</noscript>
|
||||||
|
<script>
|
||||||
|
window.share = (btn,e) => {
|
||||||
|
if( window.navigator.share ){
|
||||||
|
btn.setAttribute('href', '') // override mailto:
|
||||||
|
const title = "]] .. (item and item.title or opts.plugin_global_title) .. [["
|
||||||
|
window.navigator.share({title, url: document.location.href})
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// perform the mailto:
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body background="#000000" class="${page}">
|
<body background="#000000" class="${page}">
|
||||||
${opts.plugin_global_body_html}
|
${opts.plugin_global_body_html}
|
||||||
|
|
@ -44,7 +57,7 @@
|
||||||
{if true then
|
{if true then
|
||||||
print( app.opts.plugin_global_topmenu_html:gsub("\n"," ") )
|
print( app.opts.plugin_global_topmenu_html:gsub("\n"," ") )
|
||||||
end}
|
end}
|
||||||
{if template == "page/dir.html" then
|
{if template == "page/dir.html" and not defined(item) then
|
||||||
local url = urlpath
|
local url = urlpath
|
||||||
if not urlpath:match(app.opts.plugin_diskscan_dirname) then
|
if not urlpath:match(app.opts.plugin_diskscan_dirname) then
|
||||||
-- janusweb workaround (it does not support '/' url somehow)
|
-- janusweb workaround (it does not support '/' url somehow)
|
||||||
|
|
@ -56,27 +69,11 @@
|
||||||
print([[<div class="btn XR"><a class="border secondary" href="${urlpath}?view=3D">3D</a></div> ]])
|
print([[<div class="btn XR"><a class="border secondary" href="${urlpath}?view=3D">3D</a></div> ]])
|
||||||
end
|
end
|
||||||
end}
|
end}
|
||||||
{if template == "page/index.html" then
|
{if template == "page/index.html" or defined(item) then
|
||||||
local sharedata = {
|
|
||||||
title = (item and item.title or opts.plugin_global_title)
|
|
||||||
}
|
|
||||||
print([[
|
print([[
|
||||||
<a id="share" href="mailto:friend@your.org?subject=${util.getURL()}&body=check%20this%20on%20your%20XR%20headset">
|
<a onclick="window.share(this)" href="mailto:friend@your.org?subject=${util.getURL()}&body=check%20this%20on%20your%20XR%20headset">
|
||||||
<img src="img/share.svg" class="icon share"/>
|
<img src="img/share.svg" class="icon share"/>
|
||||||
</a>
|
</a>
|
||||||
<script>
|
|
||||||
if( navigator.share ){
|
|
||||||
const sharebtn = document.querySelector('#share')
|
|
||||||
const title = "]] .. (item and item.title or opts.plugin_global_title) .. [["
|
|
||||||
sharebtn.setAttribute('href', '') // override mailto:
|
|
||||||
sharebtn.addEventListener('click', (e) => {
|
|
||||||
navigator.share({title, url: document.location.href})
|
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
]])
|
]])
|
||||||
end}
|
end}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue