Skip to content

Commit ebadb1f

Browse files
committed
Photos: prep for JS-based uploading
1 parent 9846dd9 commit ebadb1f

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

sites/Google_Photos/app.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/*eslint eqeqeq:0, quotes:0, space-infix-ops:0, curly:0*/
44
"use strict";
55

6-
var photos = {url: 'https://photos.google.com'};
6+
var photosTab, photos = {url: 'https://photos.google.com'};
77

88
var delegate = {}; // our delegate to receive events from the webview app
99

1010
function search(query) {
11-
$.browser.tabSelected = new $.WebView({url: "https://photos.google.com/search/"+query});
11+
$.browser.tabSelected = photosTab = new $.WebView({url: "https://photos.google.com/search/"+query}); // FIXME: do this in JS
1212
}
1313

1414
delegate.launchURL = function(url) {
@@ -17,7 +17,12 @@ delegate.launchURL = function(url) {
1717
scheme = comps.shift(),
1818
addr = comps.shift();
1919
switch (scheme + ':') {
20+
case 'file:':
21+
// prompt to do upload
22+
photosTab.evalJS('confirm("Upload '+addr+'?");');
23+
break;
2024
case 'googlephotos:':
25+
case 'gphotos:':
2126
search(addr);
2227
break;
2328
default:
@@ -31,13 +36,26 @@ delegate.handleUserInputtedInvalidURL = function(query) {
3136
return true; // tell MacPin to stop validating the URL
3237
};
3338

39+
// handles all URLs drag-and-dropped into NON-html5 parts of Photos and Dock icon.
40+
delegate.handleDragAndDroppedURLs = function(urls) {
41+
console.log(urls);
42+
for (var url of urls) {
43+
this.launchURL(url);
44+
//$.browser.tabSelected = new $.WebView({url: url});
45+
}
46+
//return true;
47+
}
48+
3449
delegate.AppFinishedLaunching = function() {
35-
$.app.registerURLScheme('googlephotos');
50+
$.app.registerURLScheme('googlephotos'); //IOS?
51+
$.app.registerURLScheme('gphotos');
52+
$.browser.addShortcut('Google Photos', photos);
53+
$.browser.addShortcut('Picasa Web Albums', 'http://picasaweb.google.com/lh/myphotos?noredirect=1');
54+
3655
if ($.launchedWithURL != '') { // app was launched with a feed url
3756
this.launchURL($.launchedWithURL);
3857
$.launchedWithURL = '';
3958
} else {
40-
$.browser.addShortcut('Google Photos', photos);
4159
$.browser.tabSelected = new $.WebView(photos);
4260
}
4361
};

0 commit comments

Comments
 (0)