mirror of https://github.com/perkeep/perkeep.git
separated out the upload functions of clip-it-good
This commit is contained in:
parent
69e839efbb
commit
10b8cc9f82
|
@ -77,7 +77,7 @@
|
|||
contexts: ['image'],
|
||||
onclick: function(data, tab) {
|
||||
return handleMenuClick(
|
||||
albumDict.name, albumDict.id, data, tab)
|
||||
albumType, albumDict.name, albumDict.id, data, tab)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -85,7 +85,33 @@
|
|||
});
|
||||
}
|
||||
|
||||
function handleMenuClick(albumName, albumId, data, tab) {
|
||||
// Upload actions
|
||||
var ALBUM_TYPE_UPLOAD_FUNC = {
|
||||
|
||||
'picasa': function(albumId, albumName, dataSrcUrl, dataBlob, xhrDone) {
|
||||
OAUTH.authorize(function() {
|
||||
OAUTH.sendSignedRequest(
|
||||
'http://picasaweb.google.com/data/feed/api/' +
|
||||
'user/default/albumid/' + albumId,
|
||||
xhrDone,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'image/png',
|
||||
'Slug': dataSrcUrl
|
||||
},
|
||||
parameters: {
|
||||
alt: 'json'
|
||||
},
|
||||
body: dataBlob
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function handleMenuClick(albumType, albumName, albumId, data, tab) {
|
||||
chrome.pageAction.setTitle({
|
||||
tabId: tab.id,
|
||||
title: 'Clip It Good: Uploading (' + data.srcUrl.substr(0, 100) + ')'
|
||||
|
@ -113,24 +139,9 @@
|
|||
}
|
||||
} // end complete
|
||||
|
||||
OAUTH.authorize(function() {
|
||||
OAUTH.sendSignedRequest(
|
||||
'http://picasaweb.google.com/data/feed/api/' +
|
||||
'user/default/albumid/' + albumId,
|
||||
complete,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'image/png',
|
||||
'Slug': data.srcUrl
|
||||
},
|
||||
parameters: {
|
||||
alt: 'json'
|
||||
},
|
||||
body: builder.getBlob('image/png')
|
||||
}
|
||||
);
|
||||
});
|
||||
var uploadFunc = ALBUM_TYPE_UPLOAD_FUNC[albumType];
|
||||
uploadFunc(albumId, albumName, data.srcUrl,
|
||||
builder.getBlob('image/png'), complete);
|
||||
} // end onload
|
||||
|
||||
img.src = data.srcUrl;
|
||||
|
|
Loading…
Reference in New Issue