Allow setting a default account
[tt-rss-micropub.git] / settings.js
1 /**
2  * Delete a given account
3  */
4 function micropubDeleteIdentity(accountUrl)
5 {
6     new Ajax.Request('backend.php', {
7         parameters: {
8             'op':     'pluginhandler',
9             'plugin': 'micropub',
10             'method': 'action',
11             'mode':   'deleteIdentity',
12             'me':     accountUrl,
13         },
14         onSuccess: function(transport) {
15             notify_info('Account removed');
16             var elems = dojo.query('tr[data-url="' + accountUrl + '"]');
17             if (elems.length > 0) {
18                 elems.first().remove();
19             }
20         },
21         onFailure: function(transport) {
22             notify_error(transport.responseText);
23         }
24     });
25 }
26
27 /**
28  * Mark account as the default account
29  */
30 function micropubMakeDefault(accountUrl, checkbox)
31 {
32     if (!checkbox.checked) {
33         return;
34     }
35
36     new Ajax.Request('backend.php', {
37         parameters: {
38             'op':     'pluginhandler',
39             'plugin': 'micropub',
40             'method': 'action',
41             'mode':   'setDefaultIdentity',
42             'me':     accountUrl,
43         },
44         onSuccess: function(transport) {
45             notify_info('Default account changed');
46         },
47         onFailure: function(transport) {
48             notify_error(transport.responseText);
49         }
50     });
51 }