Implemented URL sharing
This commit is contained in:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user