Total Complexity | 4 |
Complexity/F | 1 |
Lines of Code | 32 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | /* eslint-env browser, jquery, webextensions */ |
||
3 | const $sendButton = $('<a id="send-to-omnifocus">Send to OmniFocus »</a>'); |
||
4 | |||
5 | $(() => { |
||
6 | // creates an OF task using the supplied ticket info |
||
7 | function createTaskForTicket(ticket) { |
||
|
|||
8 | const message = { |
||
9 | method: 'createTask', |
||
10 | params: { |
||
11 | name: `[${ticket.key}] ${ticket.summary}`, |
||
12 | note: `${window.location.href}\n\n${ticket.description}`, |
||
13 | }, |
||
14 | }; |
||
15 | |||
16 | chrome.runtime.sendMessage(message, (data) => { |
||
17 | $('<iframe style="display:none">') |
||
18 | .attr('src', data.url) |
||
19 | .appendTo('body'); |
||
20 | }); |
||
21 | } |
||
22 | |||
23 | $sendButton.prependTo('#viewissuesidebar'); |
||
24 | |||
25 | $sendButton.on('click', (evt) => { |
||
26 | evt.preventDefault(); |
||
27 | |||
28 | createTaskForTicket({ |
||
29 | key: $('#key-val').text(), |
||
30 | summary: $('#summary-val').text().replace(/\s+/, ' ').replace(/^\s*(\S.+\S)\s*$/, '$1'), |
||
31 | description: $('#description-val').html(), |
||
32 | }); |
||
33 | }); |
||
34 | }); |
||
35 |