@@ -4,6 +4,8 @@ $(function() {
44
55 self . loginState = parameters [ 0 ] ;
66 self . settingsViewModel = parameters [ 1 ] ;
7+
8+ self . allViewModels = undefined ;
79
810 self . isWizardActive = false ;
911
@@ -14,9 +16,9 @@ $(function() {
1416 self . reconnectTimeout = undefined ;
1517
1618 self . enableQualitySorting = ko . observable ( false ) ;
17-
18- self . hostname = ko . observable ( ) ;
19- self . forwardUrl = ko . observable ( ) ;
19+
20+ self . hostname = ko . observable ( undefined ) ;
21+ self . forwardUrl = ko . observable ( undefined ) ;
2022
2123 self . status = {
2224 link : ko . observable ( ) ,
@@ -40,6 +42,10 @@ $(function() {
4042 self . editorWifiPassphraseMismatch = ko . computed ( function ( ) {
4143 return self . editorWifiPassphrase1 ( ) != self . editorWifiPassphrase2 ( ) ;
4244 } ) ;
45+ self . editorWifiPassphraseNotEmpty = ko . computed ( function ( ) {
46+
47+ return self . editorWifiPassphrase1 ( ) != self . editorWifiPassphrase2 ( ) ;
48+ } ) ;
4349
4450 self . working = ko . observable ( false ) ;
4551 self . error = ko . observable ( false ) ;
@@ -74,6 +80,10 @@ $(function() {
7480 return text ;
7581 } ) ;
7682
83+ self . onAllBound = function ( allViewModels ) {
84+ self . allViewModels = allViewModels ;
85+ }
86+
7787 self . onWizardDetails = function ( response ) {
7888 console . log ( "ANDYETST onWizardDetails() setting self.isWizardActive = true" ) ;
7989 self . isWizardActive = true ;
@@ -116,8 +126,7 @@ $(function() {
116126 return 0 ;
117127 }
118128 } ,
119- {
120- } ,
129+ { } ,
121130 "quality" ,
122131 [ ] ,
123132 [ ] ,
@@ -141,7 +150,7 @@ $(function() {
141150 }
142151
143152 self . hostname ( response . hostname ) ;
144- self . forwardUrl ( response . forwardUrl ) ;
153+ self . forwardUrl ( response . forwardUrl ? response . forwardUrl : undefined ) ;
145154
146155 self . status . link ( response . status . link ) ;
147156 self . status . connections . ap ( response . status . connections . ap ) ;
@@ -272,6 +281,17 @@ $(function() {
272281
273282 self . sendWifiConfig = function ( ssid , psk , successCallback , failureCallback ) {
274283 if ( ! self . canRun ( ) ) return ;
284+
285+ // trigger onBeforeWifiConfigure event.
286+ callViewModels ( self . allViewModels , "onBeforeWifiConfigure" ,
287+ function ( viewModelCallback ) {
288+ if ( viewModelCallback && typeof viewModelCallback === 'function' ) {
289+ var result = viewModelCallback ( ) ;
290+ if ( result && result . forwardUrl ) {
291+ self . forwardUrl ( result . forwardUrl ) ;
292+ }
293+ }
294+ } ) ;
275295
276296 self . working ( true ) ;
277297 if ( self . status . connections . ap ( ) ) {
@@ -306,13 +326,14 @@ $(function() {
306326 } ;
307327
308328 self . tryReconnect = function ( ) {
309- // // ANDYTEST
310- // return
311- // var hostname = self.hostname();
312-
313- // var location = window.location.href
314- // location = location.replace(location.match("https?\\://([^:@]+(:[^@]+)?@)?([^:/]+)")[3], hostname);
315- var location = self . forwardUrl ( ) ;
329+ var location = undefined ;
330+ if ( ! self . forwardUrl ( ) ) {
331+ var hostname = self . hostname ( ) ;
332+ location = window . location . href
333+ location = location . replace ( location . match ( "https?\\://([^:@]+(:[^@]+)?@)?([^:/]+)" ) [ 3 ] , hostname ) ;
334+ } else {
335+ location = self . forwardUrl ( ) ;
336+ }
316337
317338 var pingCallback = function ( result ) {
318339 if ( ! result ) {
0 commit comments