forked from tombfix/patch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcutkey.quickCapture.js
47 lines (38 loc) · 1.13 KB
/
shortcutkey.quickCapture.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
shortcutkeys['PAUSE'] = {
description : 'Quick Capture',
execute : function(e){
cancel(e);
var MODEL_NAME = 'Local'; // Tumblr Flickr Gyazo HatenaFotolife Local
var CAPTURE_TYPE = 'View' // View Page
var TAGS = [] // ['capture', 'web']
var win = getMostRecentWindow().document.getElementById('content').contentWindow;
var doc = win.document;
var ctx = {
document : doc,
window : win,
title : doc.title,
href : win.location.href,
captureType : CAPTURE_TYPE,
}
succeed().addCallback(function(){
// Flash!
return withWindow(win, function(){
return flashView();
})
}).addCallback(function(){
// Capture!!
var exts = Tombloo.Service.extractors;
return exts.extract(ctx, exts['Photo - Capture']);
}).addCallback(function(ps){
// Post!!!
return models[MODEL_NAME].post(update(ps, {
tags : TAGS,
description : MODEL_NAME=='Tumblr'? '' : joinText([ps.page, ps.pageUrl], '\n'),
// private : true,
}));
}).addErrback(function(msg){
// Error!!!!
Tombloo.Service.alertError(msg, ctx.title, ctx.href);
});
}
}