@@ -484,9 +484,59 @@ VisualizerController.prototype.showVisualizationWindow = function(source, size)
484484 this . visualizerAssignEventHandlers ( ) ;
485485} ;
486486
487+ function WebDriverJsView ( ) {
488+ if ( localStorage && localStorage . webDriverUrlPort ) {
489+ this . setDriverUrlPort ( localStorage . webDriverUrlPort ) ;
490+ } else {
491+ this . setDriverUrlPort ( '' ) ;
492+ }
493+
494+ if ( localStorage && localStorage . webPage ) {
495+ this . setWebPage ( localStorage . webPage ) ;
496+ } else {
497+ this . setWebPage ( '' ) ;
498+ }
499+ }
500+
501+ WebDriverJsView . prototype . getDriverUrlPort = function ( ) {
502+ var input = document . getElementsByName ( 'webDriverUrlPort' ) [ 0 ] ;
503+ return input . value ;
504+ } ;
505+
506+ WebDriverJsView . prototype . setDriverUrlPort = function ( value ) {
507+ var input = document . getElementsByName ( 'webDriverUrlPort' ) [ 0 ] ;
508+ input . value = value ;
509+ this . updateSessionDepControls ( ) ;
510+ } ;
511+
512+ WebDriverJsView . prototype . getWebPage = function ( ) {
513+ var input = document . getElementsByName ( 'webPage' ) [ 0 ] ;
514+ return input . value ;
515+ } ;
516+
517+ WebDriverJsView . prototype . setWebPage = function ( value ) {
518+ var input = document . getElementsByName ( 'webPage' ) [ 0 ] ;
519+ input . value = value ;
520+ this . updateSessionDepControls ( ) ;
521+ } ;
522+
523+ WebDriverJsView . prototype . updateSessionDepControls = function ( ) {
524+ var disable = this . getDriverUrlPort ( ) . trim ( ) === '' ||
525+ this . getWebPage ( ) . trim ( ) === '' ;
526+
527+ var sessionDepControls = [ ] ;
528+ sessionDepControls . push ( document . getElementById ( 'sourceButton' ) ) ;
529+ sessionDepControls . push ( document . getElementById ( 'screenshotButton' ) ) ;
530+ for ( var controlIndex in sessionDepControls ) {
531+ var control = sessionDepControls [ controlIndex ] ;
532+ control . disabled = disable ;
533+ }
534+ }
535+
487536function WebDriverJsController ( ) {
488537 this . driver = new WebDriverProxy ( ) ;
489538 this . visualizer = new VisualizerController ( this . driver ) ;
539+ this . view = new WebDriverJsView ( ) ;
490540}
491541
492542WebDriverJsController . prototype . setServerUrl = function ( serverUrl ) {
@@ -612,16 +662,16 @@ WebDriverJsController.prototype.onQuit = function() {
612662 this . webPage = null ;
613663} ;
614664
615- function init ( ) {
616- if ( localStorage && localStorage . webDriverUrlPort ) {
617- var input = document . getElementsByName ( 'webDriverUrlPort' ) [ 0 ] ;
618- input . value = localStorage . webDriverUrlPort ;
619- }
665+ WebDriverJsController . prototype . onWebDriverUrlPortChange = function ( ) {
666+ var input = document . getElementsByName ( 'webDriverUrlPort' ) [ 0 ] ;
667+ this . view . setDriverUrlPort ( input . value ) ;
668+ } ;
620669
621- if ( localStorage && localStorage . webPage ) {
622- var input = document . getElementsByName ( 'webPage' ) [ 0 ] ;
623- input . value = localStorage . webPage ;
624- }
625- }
670+ WebDriverJsController . prototype . onWebPageChange = function ( ) {
671+ var input = document . getElementsByName ( 'webPage' ) [ 0 ] ;
672+ this . view . setWebPage ( input . value ) ;
673+ } ;
626674
627- var wd = new WebDriverJsController ( ) ;
675+ document . addEventListener ( "DOMContentLoaded" , function ( event ) {
676+ window . wd = new WebDriverJsController ( ) ;
677+ } ) ;
0 commit comments