diff --git a/README.md b/README.md index 6fdf288..63caee8 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ Kopher's controls were inspired by old WAP browsers and partially Opera Mini. On - Open a bookmark: `# [num]` - Save to the homepage: `* *` - Save to a bookmark: `* [num]` +- Share the URL: `* Call` - Toggle light/dark theme: `4` - Toggle line wrapping: `6` - Version and page info: `# #` diff --git a/js/app.js b/js/app.js index 9632682..24a8e2f 100644 --- a/js/app.js +++ b/js/app.js @@ -15,6 +15,11 @@ function saveBlob(blob, fname, successCb, errorCb) { freeSpaceReq.onerror = errorCb } +function hi2gopher(hiurl) { + var parts = hiurl.split(':')[1].split('|') + return 'gopher://'+parts[2]+':'+parts[3]+'/'+parts[0]+parts[1] +} + function openURL(url, successCb, errorCb) { if(url.startsWith('about:')) { // handle about: pages first var pageName = url.split(':')[1], allowedPageNames = ['kopher', 'blank', 'help'] @@ -267,6 +272,23 @@ addEventListener('DOMContentLoaded', function() { if(currentUrl && confirm('Save current URL as the homepage?')) setBookmark(0, currentUrl) break + case '*Call': // share current URL as text in messages/email or via Bluetooth in vCard format + var hgoph = hi2gopher(currentUrl), htype = 'text/vcard', + btext = 'BEGIN:VCARD\r\nVERSION:2.1\r\nN:'+hgoph+'\r\nURL:'+hgoph+'\r\nEND:VCARD', + hblob = new Blob([btext], {type: htype}), + hname = hgoph.replace(/[\/:]+/g, '_') + '.vcf' + hblob.name = hname + new MozActivity({ + name: 'share', + data: { + type: 'url', + number: 1, + url: hgoph, + blobs: [hblob], + filenames: [hname] + } + }) + break case '#1': // load bookmark case '#2': case '#3': diff --git a/pages/help.txt b/pages/help.txt index 57761aa..0aab4d3 100644 --- a/pages/help.txt +++ b/pages/help.txt @@ -12,6 +12,7 @@ Kopher controls * Open bookmark: # [num] * Save to homepage: * * * Save bookmark: * [num] +* Share the URL: * Call * Toggle theme: 4 * Toggle line wrapping: 6 * Version+page info: # #