|
9 | 9 | import SwitchInstanceIcon from "../icons/SwitchInstanceIcon.svelte"
|
10 | 10 | import SettingsIcon from "../icons/SettingsIcon.svelte"
|
11 | 11 | import { options, config } from "./stores"
|
12 |
| - import ServiceIcon from "./components/ServiceIcon.svelte" |
13 | 12 | import { onDestroy } from "svelte"
|
14 | 13 | import servicesHelper from "../../assets/javascripts/services"
|
15 |
| - import Checkbox from "../components/Checkbox.svelte" |
| 14 | + import Switch from "./components/Switch.svelte" |
16 | 15 |
|
17 | 16 | let _options
|
18 | 17 | let _config
|
|
35 | 34 | servicesHelper.switchInstance(url).then(r => (switchInstance = r))
|
36 | 35 | servicesHelper.reverse(url).then(r => (redirectToOriginal = r))
|
37 | 36 | servicesHelper.redirectAsync(url, "main_frame", null, true).then(r => (redirect = r))
|
38 |
| - currentService = await servicesHelper.computeService(url) |
| 37 | + servicesHelper.computeService(url).then(r => (currentService = r)) |
39 | 38 | }
|
40 | 39 | })
|
41 | 40 | </script>
|
42 | 41 |
|
43 | 42 | {#if redirect}
|
44 |
| - <Row class="row" on:click={() => browser.runtime.sendMessage("redirectTab")}> |
| 43 | + <Row class="interactive" on:click={() => browser.runtime.sendMessage("redirectTab")}> |
45 | 44 | <Label>Redirect</Label>
|
46 | 45 | <RedirectIcon />
|
47 | 46 | </Row>
|
48 | 47 | {/if}
|
49 | 48 |
|
50 | 49 | {#if switchInstance}
|
51 |
| - <Row class="row" on:click={async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) })}> |
| 50 | + <Row |
| 51 | + class="interactive" |
| 52 | + on:click={async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url) })} |
| 53 | + > |
52 | 54 | <Label>Switch Instance</Label>
|
53 | 55 | <SwitchInstanceIcon />
|
54 | 56 | </Row>
|
55 | 57 | {/if}
|
56 | 58 |
|
57 | 59 | {#if redirectToOriginal}
|
58 |
| - <Row class="row" on:click={() => servicesHelper.copyRaw(url)}> |
| 60 | + <Row class="interactive" on:click={() => servicesHelper.copyRaw(url)}> |
59 | 61 | <Label>Copy Original</Label>
|
60 | 62 | <CopyIcon />
|
61 | 63 | </Row>
|
62 |
| - <Row class="row" on:click={() => browser.runtime.sendMessage("reverseTab")}> |
| 64 | + <Row class="interactive" on:click={() => browser.runtime.sendMessage("reverseTab")}> |
63 | 65 | <Label>Redirect To Original</Label>
|
64 | 66 | <RedirectToOriginalIcon />
|
65 | 67 | </Row>
|
66 | 68 | {/if}
|
67 | 69 |
|
68 |
| -<hr /> |
| 70 | +{#if redirect || switchInstance || redirectToOriginal} |
| 71 | + <hr /> |
| 72 | +{/if} |
69 | 73 |
|
70 | 74 | {#if currentService}
|
71 |
| - <Row> |
72 |
| - <div |
73 |
| - style="display: flex;justify-content: space-between;align-items: center;" |
74 |
| - class="row" |
75 |
| - on:keydown={null} |
76 |
| - on:click={() => window.open(browser.runtime.getURL(_config.services[currentService].url), "_blank")} |
77 |
| - > |
78 |
| - <ServiceIcon details={{ value: currentService, label: _config.services[currentService].name }} /> |
79 |
| - <Label>{_config.services[currentService].name}</Label> |
80 |
| - </div> |
81 |
| - <div style="display: flex;align-items: center;"> |
82 |
| - <Checkbox |
83 |
| - style="margin-right:5px" |
84 |
| - label="Enable" |
85 |
| - checked={_options[currentService].enabled} |
86 |
| - onChange={e => { |
87 |
| - _options[currentService].enabled = e.target.checked |
88 |
| - options.set(_options) |
89 |
| - }} |
90 |
| - /> |
91 |
| - <SwitchInstanceIcon |
92 |
| - class="row" |
93 |
| - on:click={async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url, currentService) })} |
94 |
| - /> |
95 |
| - </div> |
96 |
| - </Row> |
| 75 | + <Switch serviceKey={currentService} {url} /> |
| 76 | + <hr /> |
97 | 77 | {/if}
|
98 | 78 |
|
99 |
| -<hr /> |
100 |
| - |
101 | 79 | {#each _options.popupServices as serviceKey}
|
102 | 80 | {#if currentService !== serviceKey}
|
103 |
| - <Row> |
104 |
| - <div |
105 |
| - style="display: flex;align-items: center;" |
106 |
| - class="row" |
107 |
| - on:keydown={null} |
108 |
| - on:click={() => window.open(browser.runtime.getURL(_config.services[serviceKey].url), "_blank")} |
109 |
| - > |
110 |
| - <ServiceIcon details={{ value: serviceKey, label: _config.services[serviceKey].name }} /> |
111 |
| - <Label>{_config.services[serviceKey].name}</Label> |
112 |
| - </div> |
113 |
| - <div style="display: flex;align-items: center;"> |
114 |
| - <Checkbox |
115 |
| - style="margin-right:5px" |
116 |
| - label="Enable" |
117 |
| - checked={_options[serviceKey].enabled} |
118 |
| - onChange={e => { |
119 |
| - console.log(e.target.checked) |
120 |
| - _options[serviceKey].enabled = e.target.checked |
121 |
| - options.set(_options) |
122 |
| - }} |
123 |
| - /> |
124 |
| - <SwitchInstanceIcon |
125 |
| - class="row" |
126 |
| - on:click={async () => browser.tabs.update({ url: await servicesHelper.switchInstance(url, serviceKey) })} |
127 |
| - /> |
128 |
| - </div> |
129 |
| - </Row> |
| 81 | + <Switch {serviceKey} {url} /> |
130 | 82 | {/if}
|
131 | 83 | {/each}
|
132 | 84 |
|
133 | 85 | <hr />
|
134 | 86 |
|
135 |
| -<Row class="row" on:click={() => window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> |
| 87 | +<Row class="interactive" on:click={() => window.open(browser.runtime.getURL("pages/options/index.html"), "_blank")}> |
136 | 88 | <Label>Settings</Label>
|
137 | 89 | <SettingsIcon />
|
138 | 90 | </Row>
|
139 | 91 |
|
140 | 92 | <style>
|
141 |
| - :global(.row) { |
| 93 | + :global(.interactive) { |
142 | 94 | transition: 0.1s;
|
143 | 95 | }
|
144 |
| - :global(.row:hover) { |
| 96 | + :global(.interactive:hover) { |
145 | 97 | color: var(--active);
|
146 | 98 | cursor: pointer;
|
147 | 99 | }
|
148 |
| - :global(.row:active) { |
| 100 | + :global(.interactive:active) { |
149 | 101 | transform: translateY(1px);
|
150 | 102 | }
|
151 | 103 |
|
|
0 commit comments