-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpocket.js
More file actions
48 lines (43 loc) · 1.13 KB
/
pocket.js
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
48
Plugins.oneclickpocket = {
shareArticleToPocket: function(id, btn) {
try {
var d = new Date();
var ts = d.getTime();
Notify.progress("Saving to Pocket…", true);
xhrPost("backend.php",
{
op: "pluginhandler",
plugin: "oneclickpocket",
method: "getInfo",
id: encodeURIComponent(id)
},
(transport) => {
var ti = JSON.parse(transport.responseText);
if (ti.status=="1") {
Notify.info("Saved to Pocket:<br/><em>" + ti.title + "</em>");
btn.src='plugins/oneclickpocket/pocket.png';
btn.title='Saved to Pocket';
}
else {
Notify.error("<strong>Error saving to Pocket!</strong><br/>("+ti.status+")");
}
}
);
} catch (e) {
App.Error.report(e);
}
}
};
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function () {
PluginHost.register(PluginHost.HOOK_INIT_COMPLETE, () => {
App.hotkey_actions['pock_it'] = function() {
if (Article.getActive()) {
var artid = "ocp"+Article.getActive();
Plugins.oneclickpocket.shareArticleToPocket(Article.getActive(), document.getElementById(artid));
return;
}
};
});
});
});