From 703bd3bbfe201d2d836a59ee5a41f2e597fc56e2 Mon Sep 17 00:00:00 2001 From: Cade Scroggins Date: Tue, 19 Jan 2021 13:19:37 +0530 Subject: [PATCH] add clock seconds + small tweaks --- README.md | 6 +- index.html | 267 +++++++++++++++++++++++++++-------------------------- 2 files changed, 138 insertions(+), 135 deletions(-) diff --git a/README.md b/README.md index 4ede0ba..53138e2 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ is to have a homepage for your browser that is functional and sexy. To go to a site, enter the corresponding key. To view the available sites and their keys, press `?`. If your input doesn’t match any of the keys, a -generic DuckDuckGo search will be triggered. For example: +generic Google search will be triggered. For example: - Entering `t` would redirect you to [twitter.com](https://twitter.com/home). - Entering `u` would redirect you to [unsplash.com](https://unsplash.com/images). -- Entering `google` would - [search DuckDuckGo for google](https://duckduckgo.com/?q=google). +- Entering `duckduckgo` would + [search Google for duckduckgo](https://www.google.com/search?q=duckduckgo). ### Searching diff --git a/index.html b/index.html index 59b795e..1cd5903 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,9 @@ // Show AM/PM indication when CONFIG.clockTwentyFourHours is false. clockShowAmPm: true, + // Show seconds on the clock. A monospaced font is recommended for this. + clockShowSeconds: true, + // Show a twenty-four-hour clock instead of a twelve-hour clock. clockTwentyFourHour: true, @@ -41,10 +44,13 @@ 0: ["0'8000", "0'8080"], c: ['c/calendar/u/1/r', 'c/calendar/u/2/r'], d: ['d/drive/u/1/my-drive', 'd/drive/u/2/my-drive'], - g: ['g/cadejscroggins/tilde', 'g/ossu'], + g: ['g/notifications', 'g/trending', 'g/ossu', 'g/cadejscroggins/tilde'], + h: ['h/popular', 'h/popular/lastweek', 'h/tags'], k: ['k/u/1', 'k/u/2'], m: ['m/mail/u/1', 'm/mail/u/2'], + r: ['r/hot', 'r/new', 'r/top', 'r/r/startpages'], s: ['s/client/T7K3RFA1M', 's/client/T018S4TL7CP'], + y: ['y/feed/subscriptions', 'y/feed/trending'], }, // The order, limit and minimum characters for each suggestion influencer. @@ -168,7 +174,7 @@ { category: 'Learn', name: 'Khan', - key: '-', + key: '+', url: 'www.khanacademy.org', search: '/search?page_search_query={}', hues: ['166', '146'], @@ -187,6 +193,7 @@ key: 'w', url: 'en.wikipedia.org/wiki/Main_Page', search: '/wiki/{}', + hues: ['217', '237'], }, { category: 'Learn', @@ -286,7 +293,7 @@ category: 'Listen', name: 'Hypem', key: 'h', - url: 'hypem.com/popular', + url: 'hypem.com/latest', search: '/search/{}', hues: ['90'], }, @@ -302,7 +309,7 @@ category: 'Watch', name: 'YouTube', key: 'y', - url: 'youtube.com/feed/subscriptions', + url: 'youtube.com', search: '/results?search_query={}', hues: ['5', '355'], }, @@ -322,8 +329,8 @@ hues: ['264', '244'], }, ].map((command) => { - const hsla = (hue, saturation = 'var(--commandColorSaturation)') => - `hsla(${hue}, ${saturation}, var(--commandColorLightness), var(--commandColorAlpha))`; + const hsla = (hue, saturation = 'var(--command-color-saturation)') => + `hsla(${hue}, ${saturation}, var(--command-color-lightness), var(--command-color-alpha))`; command.url = `https://${command.url}`; command.color = command.category ? hsla(0, '0%') : null; @@ -336,7 +343,7 @@ command.color = hsla(command.hues[0]); } else { const c = command.hues.reduce((a, h) => `${a}, ${hsla(h)}`, ''); - command.color = `linear-gradient(var(--commandColorGradient) ${c})`; + command.color = `linear-gradient(var(--command-color-gradient) ${c})`; } return command; @@ -346,40 +353,64 @@ @@ -726,6 +722,7 @@ this._el = $.el('#clock'); this._amPm = options.amPm; this._delimiter = options.delimiter; + this._showSeconds = options.showSeconds; this._twentyFourHour = options.twentyFourHour; this._setTime = this._setTime.bind(this); this._el.addEventListener('click', options.onClick); @@ -744,8 +741,12 @@ if (this._amPm) amPm = date.getHours() >= 12 ? ' PM' : ' AM'; } - const minutes = $.pad(date.getMinutes()); - this._el.innerHTML = `${hours}${this._delimiter}${minutes}${amPm}`; + const minutes = this._delimiter + $.pad(date.getMinutes()); + const seconds = this._showSeconds + ? this._delimiter + $.pad(date.getSeconds()) + : ''; + + this._el.innerHTML = hours + minutes + seconds + amPm; this._el.setAttribute('datetime', date.toTimeString()); } @@ -1001,6 +1002,7 @@ suggest(input) { this._currentInput = input.trim(); + this._highlitedSuggestion = null; if (!this._currentInput) { this._clearSuggestions(); @@ -1137,7 +1139,7 @@ this._suggestionEls = $.els('.js-search-suggestion'); this._registerSuggestionHighlightEvents(); this._registerSuggestionClickEvents(); - $.bodyClassAdd('suggestions'); + if (this._suggestionEls.length) $.bodyClassAdd('suggestions'); this._rehighlight(); } @@ -1406,6 +1408,7 @@ amPm: CONFIG.clockShowAmPm, delimiter: CONFIG.clockDelimiter, onClick: CONFIG.clockOnClickAction === 'Search' ? form.show : help.toggle, + showSeconds: CONFIG.clockShowSeconds, twentyFourHour: CONFIG.clockTwentyFourHour, });