Skip to content

Commit b19a83f

Browse files
committed
add text input
1 parent c8e2b4c commit b19a83f

File tree

11 files changed

+63
-8
lines changed

11 files changed

+63
-8
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ Quick Add was a Google Calendar feature that enabled creating calendar events fr
1212
2. Parses the input to find date info
1313
3. Returns a Google Calendar URL for adding the event to your calendar.
1414

15+
Events can be created by either highlighting date information and selecting the extension in the context menu or by clicking the extension icon and entering event info into the text field.
16+
1517
## Usage
1618

1719
### Chrome Extension
1820
Install the Chrome extension from [Chrome Web Store][webstore].
1921

2022
### Web App
21-
Alternatively, I have a running implementation [on my website][max].
23+
Alternatively, I have a running implementation [on my website][max]. This is useful when you're on a device without Chrome extensions, like a phone.
2224

2325
#### Local
2426
If you want to run the webapp locally:
@@ -40,5 +42,4 @@ Max Timkovich
4042
[docs]: https://github.com/InteractionDesignFoundation/add-event-to-calendar-docs/blob/main/services/google.md#google
4143
[max]: https://timkovi.ch/rip_quick_add
4244
[chrono]: https://github.com/wanasit/chrono
43-
[rip]: https://joshdance.medium.com/i-miss-google-cal-quick-add-d4beee62fd27
4445
[webstore]: https://chrome.google.com/webstore/detail/rip-quick-add/einookkhlkagdckkngcebldmicpilpmk

chrome/background.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ chrome.runtime.onInstalled.addListener(() => {
2727
});
2828

2929
chrome.contextMenus.onClicked.addListener(quickAdd);
30+
31+
// chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
32+
// if (request.type === 'add') {
33+
// quickAdd(request.data);
34+
// }
35+
// return true;
36+
// });

chrome/manifest.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Rip Quick Add",
33
"description": "Quickly create Google calendar events from natural language.",
4-
"version": "1.0",
4+
"version": "1.2",
55
"manifest_version": 3,
66
"permissions": [
77
"contextMenus"
@@ -13,9 +13,17 @@
1313
"service_worker": "background.js"
1414
},
1515
"icons": {
16-
"16": "icon_16.png",
17-
"32": "icon_32.png",
18-
"48": "icon_48.png",
19-
"128": "icon_128.png"
16+
"16": "images/icon_16.png",
17+
"32": "images/icon_32.png",
18+
"48": "images/icon_48.png",
19+
"128": "images/icon_128.png"
20+
},
21+
"action": {
22+
"default_icon": {
23+
"16": "images/icon_16.png",
24+
"32": "images/icon_32.png"
25+
},
26+
"default_title": "Quick Add",
27+
"default_popup": "popup.html"
2028
}
2129
}

chrome/popup.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<textarea id="input" rows="6" cols="30"></textarea>
5+
<br>
6+
<button type="button" id="add">Add</button>
7+
<div id="error" style="color: red"></div>
8+
9+
<script src="popup.js"></script>
10+
</body>
11+
</html>

chrome/popup.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Same thing but synchronous because we love javascript so much.
2+
function quickAdd(text) {
3+
const endpoint = 'https://timkovi.ch/rip_quick_add_api';
4+
5+
let url = null;
6+
fetch(endpoint, {
7+
method: 'POST',
8+
headers: {
9+
'Accept': 'application/json',
10+
'Content-Type': 'application/json',
11+
},
12+
body: JSON.stringify({text})
13+
})
14+
.then(x => x.json())
15+
.then(data => {
16+
const url = data.url;
17+
if (url) {
18+
chrome.tabs.create({url});
19+
} else {
20+
document.getElementById('error').textContent = 'Could not parse time data from input';
21+
}
22+
});
23+
}
24+
25+
document.getElementById('add').addEventListener('click', (e) => {
26+
const input = document.getElementById('input').value;
27+
quickAdd(input);
28+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
},
88
"type": "module",
99
"scripts": {
10-
"start": "node app.js"
10+
"start": "node server.js"
1111
}
1212
}

0 commit comments

Comments
 (0)