mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-21 15:26:17 -04:00
Add basic ShareTarget handler
This commit is contained in:
parent
59ec78c520
commit
13243093ae
3 changed files with 32 additions and 3 deletions
|
@ -18,12 +18,20 @@
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},{
|
},{
|
||||||
"src": "images/logo_transparent_white_512x512.png",
|
"src": "images/logo_transparent_512x512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}],
|
}],
|
||||||
"background_color": "#3367d6",
|
"background_color": "#3367d6",
|
||||||
"start_url": "/",
|
"start_url": "/",
|
||||||
"display": "minimal-ui",
|
"display": "minimal-ui",
|
||||||
"theme_color": "#3367d6"
|
"theme_color": "#3367d6",
|
||||||
|
"share_target": {
|
||||||
|
"action": "/share-target/",
|
||||||
|
"params": {
|
||||||
|
"title": "title",
|
||||||
|
"text": "text",
|
||||||
|
"url": "url"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -276,10 +276,17 @@ class SendTextDialog extends Dialog {
|
||||||
|
|
||||||
_onRecipient(recipient) {
|
_onRecipient(recipient) {
|
||||||
this._recipient = recipient;
|
this._recipient = recipient;
|
||||||
|
this._handleShareTargetText();
|
||||||
this.show();
|
this.show();
|
||||||
this.$text.setSelectionRange(0, this.$text.value.length)
|
this.$text.setSelectionRange(0, this.$text.value.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleShareTargetText(){
|
||||||
|
if(!window.shareTargetText) return;
|
||||||
|
this.$text.value = window.shareTargetText;
|
||||||
|
window.shareTargetText = '';
|
||||||
|
}
|
||||||
|
|
||||||
_send(e) {
|
_send(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
Events.fire('send-text', {
|
Events.fire('send-text', {
|
||||||
|
@ -439,6 +446,20 @@ class NetworkStatusUI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WebShareTargetUI {
|
||||||
|
constructor() {
|
||||||
|
const parsedUrl = new URL(window.location);
|
||||||
|
const title = parsedUrl.searchParams.get('title');
|
||||||
|
const text = parsedUrl.searchParams.get('text');
|
||||||
|
const url = parsedUrl.searchParams.get('url');
|
||||||
|
|
||||||
|
let shareTargetText = title ? title : '';
|
||||||
|
shareTargetText += text ? shareTargetText ? ' ' + text : text : '';
|
||||||
|
shareTargetText += url ? shareTargetText ? ' ' + url : url : '';
|
||||||
|
window.shareTargetText = shareTargetText;
|
||||||
|
console.log('Shared Target Text:', '"' + shareTargetText + '"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Snapdrop {
|
class Snapdrop {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var CACHE_NAME = 'snapdrop-cache-v1.02';
|
var CACHE_NAME = 'snapdrop-cache-v1.03';
|
||||||
var urlsToCache = [
|
var urlsToCache = [
|
||||||
'/',
|
'/',
|
||||||
'/styles.css',
|
'/styles.css',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue