Skip to content

Commit

Permalink
add search result count to nap room
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanb10 committed May 19, 2021
1 parent c967d49 commit 42f7751
Show file tree
Hide file tree
Showing 27 changed files with 31 additions and 18 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ PRs and other ideas are welcome.
## Changes ##

**May 2021**
#### 2.4.1
- show number of search results in the nap room
- misc ui related fixes

#### 2.4.0
- Edit Snoozz times for sleeping tabs 🎉
- Snooze Again for awoken tabs
Expand Down
Binary file removed external_assets/listing-1.jpg
Binary file not shown.
Binary file removed external_assets/listing-1.png
Binary file not shown.
Binary file removed external_assets/listing-2.png
Binary file not shown.
Binary file removed external_assets/listing-3-edge.png
Binary file not shown.
Binary file removed external_assets/listing-3-ff.png
Binary file not shown.
Binary file removed external_assets/listing-3.png
Binary file not shown.
Binary file removed external_assets/listing-4.png
Binary file not shown.
Binary file removed external_assets/logo-hd.png
Binary file not shown.
Binary file removed external_assets/safari-logo.png
Binary file not shown.
Binary file removed external_assets/snoozz.png
Binary file not shown.
Binary file removed external_assets/thumb-lg.jpg
Binary file not shown.
Binary file removed external_assets/thumb-lg.png
Binary file not shown.
Binary file removed external_assets/thumb-md.jpg
Binary file not shown.
Binary file removed external_assets/thumb-md.png
Binary file not shown.
Binary file removed external_assets/thumb-sm.jpg
Binary file not shown.
Binary file removed external_assets/thumb-sm.png
Binary file not shown.
2 changes: 1 addition & 1 deletion html/nap-room.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
</div>
<div id="time-container"></div>
<div id="no-tabs" class="hidden">
<span>No tabs found :(</span>
<div class="contain-clock">
<div class="face-1">
<div class="hour"></div>
Expand All @@ -52,6 +51,7 @@
<div class="bell"></div>
<div class="bell bell-2"></div>
</div>
<span>No tabs found :(</span>
</div>
<p id="api-message" class="hidden">Like most people, tabs may take 10 minutes to get out of bed. Mainly due to API restrictions, but also, laziness.</p>
<p id="history-message">Tabs in your Snoozz history are removed <a id="historyHref" href="./settings.html#history">-</a> after they wake up.</p>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions html/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ <h4>Snoozz tabs using the right-click (context) menu</h4>
</div>
<div tabindex="0" class="btn"><div></div></div>
<div id="contextMenu" class="choice-list">
<div><input type="checkbox" id="startup"><label for="today-morning">On Browser Launch</label></div>
<div><input type="checkbox" id="in-an-hour"><label for="today-morning">In One Hour</label></div>
<div><input type="checkbox" id="startup"><label for="startup">On Browser Launch</label></div>
<div><input type="checkbox" id="in-an-hour"><label for="in-an-hour">In One Hour</label></div>
<div><input type="checkbox" id="today-morning"><label for="today-morning">This Morning</label></div>
<div><input type="checkbox" id="today-evening"><label for="today-evening">This Evening</label></div>
<div><input type="checkbox" id="tom-morning"><label for="tom-morning">Tomorrow Morning</label></div>
Expand Down
5 changes: 0 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,5 @@
"month": {
"description": "Snooze till one month from now"
}
},
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
}
}
6 changes: 3 additions & 3 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function createNotification(id, title, imgUrl, message) {
await chrome.notifications.create(id, {type: 'basic', iconUrl: chrome.extension.getURL(imgUrl), title, message});
}
async function createWindow(tabId) {
return new Promise(r => chrome.windows.create({url: `/html/rise_and_shine.html#${tabId}`}, r));
return new Promise(r => chrome.windows.create({url: `/html/rise-and-shine.html#${tabId}`}, r));
}

/* CONFIGURE */
Expand Down Expand Up @@ -151,14 +151,14 @@ async function openTab(tab, windowId, automatic = false) {
async function openWindow(t, automatic = false) {
var targetWindowID, currentWindow = await getTabsInWindow();
if (currentWindow.length && currentWindow.filter(isDefault).length === currentWindow.length) {
await openExtensionTab(`/html/rise_and_shine.html#${t.id}`);
await openExtensionTab(`/html/rise-and-shine.html#${t.id}`);
targetWindowID = currentWindow[0].windowId;
} else {
var window = await createWindow(t.id);
targetWindowID = window.id;
}

// send message to map browser tabs to tab-list in rise_and_shine.html
// send message to map browser tabs to tab-list in rise-and-shine.html
var loadingCount = 0;
chrome.tabs.onUpdated.addListener(async function cleanTabsAfterLoad(id, state, title) {
if (loadingCount > t.tabs.length) {
Expand Down
8 changes: 8 additions & 0 deletions scripts/nap_room.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function search(t, query) {
// categories
if (matchQuery(query, getTimeGroup(t, 'wakeUpTime', true).map(tg => tg.replace(/_/g, ' ')))) return true;
if (matchQuery(query, getTimeGroup(t, 'timeCreated', true).map(tg => tg.replace(/_/g, ' ')))) return true;
if (matchQuery(query, getTimeGroup(t, 'modifiedTime', true).map(tg => tg.replace(/_/g, ' ')))) return true;
// absolute time
if ( t.opened && matchQuery(query, dayjs(t.opened).format('dddd DD MMMM A'))) return true;
if (!t.opened && t.wakeUpTime && matchQuery(query, dayjs(t.wakeUpTime).format('dddd DD MMMM A'))) return true;
Expand All @@ -191,6 +192,13 @@ function performSearch(searchQuery = '') {
var tabs = document.querySelectorAll('.tab');
if (tabs) tabs.forEach(t => t.classList.toggle('hidden', !search((CACHED_TABS).find(ct => ct.id == t.id), searchQuery)));
updateTimeGroups();
countSearchItems();
}

function countSearchItems() {
var all = document.querySelectorAll('.time-group .tab').length;
var visible = document.querySelectorAll('.time-group .tab:not(.hidden)').length;
document.querySelector('.search-container').setAttribute('data-search', `Showing ${visible} out of ${all} items`);
}

function buildTabActions(t, tabDiv) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function initialize() {
document.querySelector('code').addEventListener('click', _ => {
clipboard('about:addons')
document.querySelector('body > .copied').classList.add('toast');
setTimeout(_ => document.querySelector('body > .copied').remove('toast'), 4000)
setTimeout(_ => document.querySelector('body > .copied').classList.remove('toast'), 4000)
});

if (getBrowser() === 'safari') await chrome.runtime.getBackgroundPage(async bg => {await bg.wakeUpTask()});
Expand Down
14 changes: 10 additions & 4 deletions styles/nap-room.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ body {
touch-action: none;
transition: opacity .3s ease-in-out;
}
#no-tabs span {
display: inline-block;
margin-top: 5em;
}
#no-tabs.hidden, .search-container.hidden, .instructions.hidden {
opacity: 0;
pointer-events: none;
Expand Down Expand Up @@ -369,15 +373,17 @@ body:not(.dark) p {
background-size: 202%;
background-position: right;
}
.search-container:not(.valid-search):focus-within:before {
.search-container.valid-search:after, .search-container:not(.valid-search):focus-within:before {
content: '3 characters minimum';
position: absolute;
left: 0;
top: 120%;
top: 150%;
width: 100%;
text-align: center;
font-size: .9em;
color: #BBB;
color: var(--color);
}
.search-container.valid-search:after {
content: attr(data-search);
}
.input-wrapper:after {
content: '';
Expand Down
2 changes: 1 addition & 1 deletion styles/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ img {
}

a {
color: #000;
color: var(--color);
}

h3 {
Expand Down
2 changes: 1 addition & 1 deletion styles/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ kbd {
code {
cursor: pointer;
font-size: 1.2em;
background-color: #ddd;
background-color: #999;
border-radius: .25em;
padding: .1em .2em;
user-select: none;
Expand Down

0 comments on commit 42f7751

Please sign in to comment.