@@ -74,7 +74,7 @@ function view() {
7474 } ,
7575 [
7676 m ( "div" , {
77- "id" : "filter-search"
77+ id : "filter-search"
7878 } ) ,
7979 m ( "div" , [
8080 m ( "input" , {
@@ -109,7 +109,9 @@ function filterLogins(e) {
109109 filter . forEach ( function ( word ) {
110110 if ( word . length > 0 ) {
111111 var refine = [ ] ;
112- FuzzySort . go ( word , logins , { allowTypo : false } ) . forEach ( function ( result ) {
112+ FuzzySort . go ( word , logins , { allowTypo : false } ) . forEach ( function (
113+ result
114+ ) {
113115 refine . push ( result . target ) ;
114116 } ) ;
115117 logins = refine . slice ( 0 ) ;
@@ -132,16 +134,20 @@ function filterLogins(e) {
132134
133135function searchKeyHandler ( e ) {
134136 // switch to search mode if backspace is pressed and no filter text has been entered
135- if ( e . code == "Backspace" && logins . length > 0 && e . target . value . length == 0 ) {
137+ if (
138+ e . code == "Backspace" &&
139+ logins . length > 0 &&
140+ e . target . value . length == 0
141+ ) {
136142 e . preventDefault ( ) ;
137143 logins = resultLogins = [ ] ;
138- e . target . value = fillOnSubmit ? '' : domain ;
139- domain = '' ;
144+ e . target . value = fillOnSubmit ? "" : domain ;
145+ domain = "" ;
140146 showFilterHint ( false ) ;
141147 }
142148}
143149
144- function showFilterHint ( show = true ) {
150+ function showFilterHint ( show = true ) {
145151 var filterHint = document . getElementById ( "filter-search" ) ;
146152 var searchField = document . getElementById ( "search-field" ) ;
147153 if ( show ) {
@@ -180,7 +186,7 @@ function init(tab) {
180186 searchPassword ( activeDomain , "match_domain" ) ;
181187}
182188
183- function searchPassword ( _domain , action = "search" , useFillOnSubmit = true ) {
189+ function searchPassword ( _domain , action = "search" , useFillOnSubmit = true ) {
184190 searching = true ;
185191 logins = resultLogins = [ ] ;
186192 domain = _domain ;
@@ -191,30 +197,28 @@ function searchPassword(_domain, action="search", useFillOnSubmit=true) {
191197 // by requesting them from the background script (which has localStorage access
192198 // to the settings). Then construct the message to send to browserpass and
193199 // send that via sendNativeMessage.
194- chrome . runtime . sendMessage (
195- { action : "getSettings" } ,
196- function ( response ) {
197- chrome . runtime . sendNativeMessage (
198- app ,
199- { action : action , domain : _domain , settings : response } ,
200- function ( response ) {
201- if ( chrome . runtime . lastError ) {
202- error = chrome . runtime . lastError . message ;
203- console . error ( error ) ;
204- }
200+ chrome . runtime . sendMessage ( { action : "getSettings" } , function ( response ) {
201+ chrome . runtime . sendNativeMessage (
202+ app ,
203+ { action : action , domain : _domain , settings : response } ,
204+ function ( response ) {
205+ if ( chrome . runtime . lastError ) {
206+ error = chrome . runtime . lastError . message ;
207+ console . error ( error ) ;
208+ }
205209
206- searching = false ;
207- logins = resultLogins = response ? response : [ ] ;
208- document . getElementById ( "filter-search" ) . textContent = domain ;
209- fillOnSubmit = useFillOnSubmit && logins . length > 0 ;
210- if ( logins . length > 0 ) {
211- showFilterHint ( true ) ;
212- document . getElementById ( "search-field" ) . value = '' ;
213- }
214- m . redraw ( ) ;
210+ searching = false ;
211+ logins = resultLogins = response ? response : [ ] ;
212+ document . getElementById ( "filter-search" ) . textContent = domain ;
213+ fillOnSubmit = useFillOnSubmit && logins . length > 0 ;
214+ if ( logins . length > 0 ) {
215+ showFilterHint ( true ) ;
216+ document . getElementById ( "search-field" ) . value = "" ;
215217 }
216- ) ;
217- } ) ;
218+ m . redraw ( ) ;
219+ }
220+ ) ;
221+ } ) ;
218222}
219223
220224function parseDomainFromUrl ( url ) {
@@ -246,32 +250,44 @@ function launchURL() {
246250 if ( chrome . runtime . lastError ) {
247251 error = chrome . runtime . lastError . message ;
248252 m . redraw ( ) ;
249- return ;
253+ return ;
250254 }
251255 // get url from login path if not available in the host app response
252256 if ( ! response . hasOwnProperty ( "url" ) || response . url . length == 0 ) {
253257 var parts = entry . split ( / \/ / ) . reverse ( ) ;
254258 for ( var i in parts ) {
255259 var part = parts [ i ] ;
256260 var info = Tldjs . parse ( part ) ;
257- if ( info . isValid && info . tldExists && info . domain !== null && info . hostname === part ) {
261+ if (
262+ info . isValid &&
263+ info . tldExists &&
264+ info . domain !== null &&
265+ info . hostname === part
266+ ) {
258267 response . url = part ;
259268 break ;
260269 }
261270 }
262271 }
263272 // if a url is present, then launch a new tab via the background script
264273 if ( response . hasOwnProperty ( "url" ) && response . url . length > 0 ) {
265- var url = response . url . match ( / ^ ( [ a - z ] + : ) ? \/ \/ / i) ? response . url : "http://" + response . url ;
266- chrome . runtime . sendMessage ( { action : "launch" , url : url , username : response . u , password : response . p } ) ;
274+ var url = response . url . match ( / ^ ( [ a - z ] + : ) ? \/ \/ / i)
275+ ? response . url
276+ : "http://" + response . url ;
277+ chrome . runtime . sendMessage ( {
278+ action : "launch" ,
279+ url : url ,
280+ username : response . u ,
281+ password : response . p
282+ } ) ;
267283 window . close ( ) ;
268284 return ;
269285 }
270286 // no url available
271287 if ( ! response . hasOwnProperty ( "url" ) ) {
272288 resetWithError (
273289 "Unable to determine the URL for this entry. If you have defined one in the password file, " +
274- "your host application must be at least v2.0.14 for this to be usable."
290+ "your host application must be at least v2.0.14 for this to be usable."
275291 ) ;
276292 } else {
277293 resetWithError ( "Unable to determine the URL for this entry." ) ;
@@ -346,17 +362,23 @@ function keyHandler(e) {
346362 break ;
347363 case "c" :
348364 if ( e . target . id != "search-field" && e . ctrlKey ) {
349- document . activeElement . parentNode . querySelector ( "button.copy.password" ) . click ( ) ;
365+ document . activeElement . parentNode
366+ . querySelector ( "button.copy.password" )
367+ . click ( ) ;
350368 }
351369 break ;
352370 case "C" :
353371 if ( e . target . id != "search-field" ) {
354- document . activeElement . parentNode . querySelector ( "button.copy.username" ) . click ( ) ;
372+ document . activeElement . parentNode
373+ . querySelector ( "button.copy.username" )
374+ . click ( ) ;
355375 }
356376 break ;
357377 case "g" :
358378 if ( e . target . id != "search-field" ) {
359- document . activeElement . parentNode . querySelector ( "button.launch.url" ) . click ( ) ;
379+ document . activeElement . parentNode
380+ . querySelector ( "button.launch.url" )
381+ . click ( ) ;
360382 }
361383 }
362384}
@@ -388,13 +410,13 @@ function oncreate() {
388410}
389411
390412function resetWithError ( errMsg ) {
391- domain = '' ;
413+ domain = "" ;
392414 logins = resultLogins = [ ] ;
393415 fillOnSubmit = false ;
394416 searching = false ;
395417 var filterSearch = document . getElementById ( "filter-search" ) ;
396418 filterSearch . style . display = "none" ;
397- filterSearch . textContent = '' ;
419+ filterSearch . textContent = "" ;
398420 var searchField = document . getElementById ( "search-field" ) ;
399421 searchField . setAttribute ( "placeholder" , "Search passwords..." ) ;
400422 error = errMsg ;
0 commit comments