@@ -123,6 +123,20 @@ const isolationDomainAddRule = async () => {
123
123
updateIsolationDomains ( ) ;
124
124
} ;
125
125
126
+ window . isolationDomainEditRule = ( domainPattern ) => {
127
+ document . querySelector ( '#isolationDomainPattern' ) . value = domainPattern ;
128
+
129
+ if ( preferences . isolation . domain [ domainPattern ] ) {
130
+ const domainRules = preferences . isolation . domain [ domainPattern ] ;
131
+
132
+ $ ( '#isolationDomainAlways' ) . dropdown ( 'set selected' , domainRules . always . action ) ;
133
+ document . querySelector ( '#isolationDomainAlwaysAllowedInPermanent' ) . checked = domainRules . always . allowedInPermanent ;
134
+ $ ( '#isolationDomainNavigation' ) . dropdown ( 'set selected' , domainRules . navigation . action ) ;
135
+ $ ( '#isolationDomainMouseClickMiddle' ) . dropdown ( 'set selected' , domainRules . mouseClick . middle . action ) ;
136
+ $ ( '#isolationDomainMouseClickCtrlLeft' ) . dropdown ( 'set selected' , domainRules . mouseClick . ctrlleft . action ) ;
137
+ $ ( '#isolationDomainMouseClickLeft' ) . dropdown ( 'set selected' , domainRules . mouseClick . left . action ) ;
138
+ }
139
+ } ;
126
140
127
141
let isolationDomainRulesClickEvent = false ;
128
142
window . updateIsolationDomains = ( ) => {
@@ -131,9 +145,10 @@ window.updateIsolationDomains = () => {
131
145
if ( domainRules . length ) {
132
146
isolationDomainRules . html ( '' ) ;
133
147
domainRules . map ( ( domainPattern ) => {
134
- const el = $ ( `<div class="item" id="${ encodeURIComponent ( domainPattern ) } ">${ domainPattern } ` +
135
- `<span href="#" id="domainRule:${ encodeURIComponent ( domainPattern ) } ">🛈</span> ` +
136
- '<a href="#" id="isolationRemoveDomainRules" data-tooltip="Remove Rule (no confirmation)" ' +
148
+ const el = $ ( `<div class="item" id="${ encodeURIComponent ( domainPattern ) } ">` +
149
+ `<span id="infoDomainRule" href="#">${ domainPattern } 🛈</span> ` +
150
+ '<a href="#" id="editDomainRule" data-tooltip="Edit">🖊️</a> ' +
151
+ '<a href="#" id="removeDomainRule" data-tooltip="Remove Rule (no confirmation)" ' +
137
152
'data-position="right center">❌</a></div>' ) ;
138
153
isolationDomainRules . append ( el ) ;
139
154
@@ -146,7 +161,7 @@ window.updateIsolationDomains = () => {
146
161
`Middle: ${ preferences . isolation . domain [ domainPattern ] . mouseClick . middle . action } <br>` +
147
162
`Ctrl+Left: ${ preferences . isolation . domain [ domainPattern ] . mouseClick . ctrlleft . action } <br>` +
148
163
`Left: ${ preferences . isolation . domain [ domainPattern ] . mouseClick . left . action } </div>` ;
149
- el . popup ( {
164
+ el . find ( '#infoDomainRule' ) . popup ( {
150
165
html : domainRuleTooltip ,
151
166
inline : true
152
167
} ) ;
@@ -155,14 +170,18 @@ window.updateIsolationDomains = () => {
155
170
if ( ! isolationDomainRulesClickEvent ) {
156
171
isolationDomainRules . on ( 'click' , async ( event ) => {
157
172
event . preventDefault ( ) ;
173
+ const targetId = $ ( event . target ) . attr ( 'id' ) ;
158
174
const domainPattern = $ ( event . target ) . parent ( ) . attr ( 'id' ) ;
159
- if ( domainPattern === 'isolationDomains' ) {
175
+ if ( targetId === 'editDomainRule' ) {
176
+ isolationDomainEditRule ( domainPattern ) ;
160
177
return ;
161
178
}
162
- delete preferences . isolation . domain [ decodeURIComponent ( domainPattern ) ] ;
163
- // TODO show "rule deleted" instead of "preferences saved"
164
- await savePreferences ( ) ;
165
- updateIsolationDomains ( ) ;
179
+ if ( targetId === 'removeDomainRule' ) {
180
+ delete preferences . isolation . domain [ decodeURIComponent ( domainPattern ) ] ;
181
+ // TODO show "rule deleted" instead of "preferences saved"
182
+ await savePreferences ( ) ;
183
+ updateIsolationDomains ( ) ;
184
+ }
166
185
} ) ;
167
186
isolationDomainRulesClickEvent = true ;
168
187
}
0 commit comments