|
@ -15,8 +15,8 @@ let state = { |
|
|
scored_links: [] |
|
|
scored_links: [] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
global._fuzzyhome_delete_everything = do |
|
|
global._fuzzyhome_delete_everything = do |prompt=yes| |
|
|
return unless window.confirm "This will delete everything. Are you sure?" |
|
|
return if prompt and window.confirm "This will delete everything. Are you sure?" |
|
|
indexedDB.deleteDatabase("fuzzyhome") |
|
|
indexedDB.deleteDatabase("fuzzyhome") |
|
|
delete localStorage.fuzzyhome_config |
|
|
delete localStorage.fuzzyhome_config |
|
|
delete localStorage.fuzzyhome_visited |
|
|
delete localStorage.fuzzyhome_visited |
|
@ -69,16 +69,17 @@ tag app |
|
|
config = JSON.parse(global.localStorage.fuzzyhome_config) |
|
|
config = JSON.parse(global.localStorage.fuzzyhome_config) |
|
|
validate_config! |
|
|
validate_config! |
|
|
catch |
|
|
catch |
|
|
|
|
|
p "resetting config" |
|
|
reset_config! |
|
|
reset_config! |
|
|
|
|
|
|
|
|
def validate_config |
|
|
def validate_config |
|
|
p config |
|
|
p config |
|
|
throw _ if config.default_bang.id is null |
|
|
throw _ if config.default_bang.id == null |
|
|
throw _ if config.default_bang.url is null |
|
|
throw _ if config.default_bang.url == null |
|
|
throw _ if config.default_bang.icon is null |
|
|
throw _ if config.default_bang.icon == null |
|
|
throw _ if config.default_bang.name is null |
|
|
throw _ if config.default_bang.name == null |
|
|
throw _ if config.default_bang.frequency is null |
|
|
throw _ if config.default_bang.frequency == null |
|
|
throw _ if config.default_bang.display_name is null |
|
|
throw _ if config.default_bang.display_name == null |
|
|
|
|
|
|
|
|
def reset_config |
|
|
def reset_config |
|
|
p "resetting config" |
|
|
p "resetting config" |
|
@ -96,6 +97,25 @@ tag app |
|
|
state.links = await db.links.toArray() |
|
|
state.links = await db.links.toArray() |
|
|
sort_links! |
|
|
sort_links! |
|
|
|
|
|
|
|
|
|
|
|
get tip_url |
|
|
|
|
|
let split_query = state.query.trim!.split /\s+/ |
|
|
|
|
|
if split_query.length >= 2 |
|
|
|
|
|
return ' https://' + split_query.pop! |
|
|
|
|
|
else |
|
|
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
get tip_name |
|
|
|
|
|
let split_query = state.query.trim!.split /\s+/ |
|
|
|
|
|
let name = split_query.join ' ' |
|
|
|
|
|
if split_query.length >= 2 |
|
|
|
|
|
split_query.pop! |
|
|
|
|
|
if split_query[-1].startsWith '~' |
|
|
|
|
|
split_query.pop! |
|
|
|
|
|
name = split_query.join ' ' |
|
|
|
|
|
if name.startsWith '!' |
|
|
|
|
|
name = name.slice(1) |
|
|
|
|
|
name |
|
|
|
|
|
|
|
|
def sort_links |
|
|
def sort_links |
|
|
if state.query.trim!.length > 0 |
|
|
if state.query.trim!.length > 0 |
|
|
state.scored_links = fzi state.links, state.query |
|
|
state.scored_links = fzi state.links, state.query |
|
@ -281,7 +301,7 @@ tag app |
|
|
|
|
|
|
|
|
def handle_shift_backspace |
|
|
def handle_shift_backspace |
|
|
return unless state.scored_links.length > 0 |
|
|
return unless state.scored_links.length > 0 |
|
|
handle_delete state.scored_links[selection_index] |
|
|
handle_edit state.scored_links[selection_index] |
|
|
|
|
|
|
|
|
def handle_shift_return |
|
|
def handle_shift_return |
|
|
handle_add! |
|
|
handle_add! |
|
@ -365,23 +385,36 @@ tag app |
|
|
css .settings-container |
|
|
css .settings-container |
|
|
d:flex fld:row jc:space-around ai:center |
|
|
d:flex fld:row jc:space-around ai:center |
|
|
w:100% h:50px |
|
|
w:100% h:50px |
|
|
bg:purple4/10 rd:5px |
|
|
mt:10px |
|
|
|
|
|
gap:10px |
|
|
|
|
|
|
|
|
css .settings-button |
|
|
css .settings-button, .settings-container button |
|
|
d:flex fld:column jc:center ai:center fl:1 |
|
|
d:flex fld:column jc:center ai:center fl:1 |
|
|
bg:none c:purple4 bd:none cursor:pointer fs:14px |
|
|
bg:none c:purple4 bd:none cursor:pointer fs:14px |
|
|
|
|
|
bg:purple4/10 rd:5px |
|
|
|
|
|
h:100% |
|
|
|
|
|
|
|
|
css .middle-button |
|
|
css .middle-button |
|
|
d:flex fld:column jc:center ai:center |
|
|
d:flex fld:row w:100% |
|
|
h:35px c:purple4 fs:20px cursor:pointer |
|
|
c:purple4 fs:20px cursor:pointer |
|
|
fs:20px |
|
|
fs:14px pt:15px |
|
|
|
|
|
|
|
|
|
|
|
css .tip |
|
|
|
|
|
d:flex fld:column bdr:1px solid blue3/10 min-width:0 fl:1 p:5px |
|
|
|
|
|
@last bd:none |
|
|
|
|
|
|
|
|
|
|
|
css .tip-hotkey |
|
|
|
|
|
fs:12px c:purple3/50 |
|
|
|
|
|
|
|
|
|
|
|
css .tip-content |
|
|
|
|
|
pt:2px fs:14px c:purple3 white-space:nowrap |
|
|
|
|
|
|
|
|
css .disabled |
|
|
css .disabled |
|
|
c:gray4 cursor:default user-select:none |
|
|
c:gray4 cursor:default user-select:none |
|
|
|
|
|
|
|
|
css .links |
|
|
css .links |
|
|
d:flex fld:column jc:flex-start fl:1 |
|
|
d:flex fld:column jc:flex-start fl:1 |
|
|
w:100% ofy:auto |
|
|
w:100% ofy:auto pt:15px |
|
|
|
|
|
|
|
|
css .link |
|
|
css .link |
|
|
d:flex fld:row jc:space-between ai:center |
|
|
d:flex fld:row jc:space-between ai:center |
|
@ -439,7 +472,13 @@ tag app |
|
|
Consider refreshing. |
|
|
Consider refreshing. |
|
|
Check developer console for more information. |
|
|
Check developer console for more information. |
|
|
""" |
|
|
""" |
|
|
else |
|
|
|
|
|
|
|
|
### |
|
|
|
|
|
<[c:purple3/90 cursor:pointer fs:14px pb:20px] |
|
|
|
|
|
@click.if(!loading)=toggle_settings |
|
|
|
|
|
> "SETTINGS" |
|
|
|
|
|
### |
|
|
|
|
|
|
|
|
if settings_active |
|
|
if settings_active |
|
|
<.settings-container> |
|
|
<.settings-container> |
|
|
<label.settings-button .disabled=loading> |
|
|
<label.settings-button .disabled=loading> |
|
@ -454,14 +493,27 @@ tag app |
|
|
.disabled=loading |
|
|
.disabled=loading |
|
|
@click.if(!loading)=handle_click_export |
|
|
@click.if(!loading)=handle_click_export |
|
|
> "EXPORT" |
|
|
> "EXPORT" |
|
|
|
|
|
<.settings-container> |
|
|
|
|
|
<.settings-button |
|
|
|
|
|
.disabled=loading |
|
|
|
|
|
@click.if(!loading)=handle_click_github |
|
|
|
|
|
> "TUTORIAL" |
|
|
<.settings-button |
|
|
<.settings-button |
|
|
.disabled=loading |
|
|
.disabled=loading |
|
|
@click.if(!loading)=handle_click_github |
|
|
@click.if(!loading)=handle_click_github |
|
|
> "GITHUB" |
|
|
> "GITHUB" |
|
|
|
|
|
<.settings-container> |
|
|
|
|
|
<.settings-button> |
|
|
|
|
|
config.enable_tips ? "DISABLE TIPS" : "ENABLE TIPS" |
|
|
|
|
|
<.settings-button |
|
|
|
|
|
.disabled=loading |
|
|
|
|
|
@click.if(!loading)=handle_click_github |
|
|
|
|
|
> "LIGHT THEME" |
|
|
|
|
|
|
|
|
else |
|
|
else |
|
|
<input$main-input |
|
|
<input$main-input |
|
|
bind=state.query |
|
|
bind=state.query |
|
|
placeholder=pretty_date |
|
|
# placeholder=pretty_date |
|
|
@hotkey('return').capture=handle_return |
|
|
@hotkey('return').capture=handle_return |
|
|
@hotkey('shift+return').capture.if(can_add)=handle_shift_return |
|
|
@hotkey('shift+return').capture.if(can_add)=handle_shift_return |
|
|
@hotkey('shift+backspace').capture=handle_shift_backspace |
|
|
@hotkey('shift+backspace').capture=handle_shift_backspace |
|
@ -475,16 +527,22 @@ tag app |
|
|
disabled=loading |
|
|
disabled=loading |
|
|
> |
|
|
> |
|
|
|
|
|
|
|
|
if state.query.trim!.split(/\s+/).length < 2 |
|
|
if config.enable_tips |
|
|
<.middle-button |
|
|
<.middle-button> |
|
|
[mt:-10px py:5px fs:25px] |
|
|
<.tip[jc:start ta:left fl:1] @click=handle_return> |
|
|
.disabled=loading |
|
|
<.tip-hotkey> "Return" |
|
|
@click.if(!loading)=toggle_settings |
|
|
<.tip-content> "Navigate To Link" |
|
|
> "..." |
|
|
<.tip[jc:center ta:center fl:2 px:15px] |
|
|
elif can_add |
|
|
@click=handle_shift_return |
|
|
<.middle-button@click=handle_click_add> "+" |
|
|
> |
|
|
else |
|
|
<.tip-hotkey> "Shift + Return" |
|
|
<.middle-button.disabled> "+" |
|
|
<.tip-content[of:hidden text-overflow:ellipsis]> |
|
|
|
|
|
"Add New Link \"{state.query.trim!}\"" |
|
|
|
|
|
<.tip[jc:end ta:right fl:1] |
|
|
|
|
|
@click=handle_shift_backspace |
|
|
|
|
|
> |
|
|
|
|
|
<.tip-hotkey> "Shift + Backspace" |
|
|
|
|
|
<.tip-content> "Edit Link" |
|
|
|
|
|
|
|
|
<.links> |
|
|
<.links> |
|
|
if bang or state.scored_links.length < 1 |
|
|
if bang or state.scored_links.length < 1 |
|
@ -520,6 +578,7 @@ tag app |
|
|
<.link-button[fs:12px]@click.prevent.stop=handle_click_edit(link)> "✎" |
|
|
<.link-button[fs:12px]@click.prevent.stop=handle_click_edit(link)> "✎" |
|
|
<.link-button@click.prevent.stop=handle_click_delete(link)> "x" |
|
|
<.link-button@click.prevent.stop=handle_click_delete(link)> "x" |
|
|
<.frequency> link.frequency |
|
|
<.frequency> link.frequency |
|
|
|
|
|
# <[c:purple3 pt:10px fs:10px]> state.scored_links.length |
|
|
$main-input.focus! |
|
|
$main-input.focus! |
|
|
|
|
|
|
|
|
imba.mount <app> |
|
|
imba.mount <app> |
|
|