Browse Source

<hw_func_oop+rgb> done

Mark 1 year ago
parent
commit
ff24a372e0
2 changed files with 9 additions and 15 deletions
  1. 0 4
      10/index.html
  2. 9 11
      10/main.js

+ 0 - 4
10/index.html

@@ -9,10 +9,6 @@
 </head>
 
 <body>
-   <div id="login">
-   </div>
-   <div id="pv1">
-   </div>
    <script src="main.js"></script>
 </body>
 

+ 9 - 11
10/main.js

@@ -16,8 +16,7 @@ function Password(parent, open) {
    };
    this.setValue = (value) => (pass.value = value);
    this.getValue = () => pass.value;
-   this.setOpen = function (open1) {
-      open = open1
+   this.setOpen = function (open) {
       check.checked = open
       pass.type = open ? 'text' : 'password'
       if (typeof this.onOpenChange === 'function') {
@@ -60,8 +59,7 @@ function LoginForm(parent) {
    }
    this.setValue = (value) => (pass.value = value);
    this.getValue = () => pass.value;
-   this.setOpen = function (newOpen) {
-      open = newOpen
+   this.setOpen = function (open) {
       check.checked = open
       pass.type = open ? 'text' : 'password'
       if (typeof this.onOpenChange === 'function') {
@@ -80,13 +78,13 @@ function LoginForm(parent) {
       }
    }
 }
-let Form = new LoginForm(login)
-Form.onChange = data => console.log(data)
-Form.onOpenChange = open => console.log(open)
-Form.setValue('qwerty')
-console.log(Form.getValue())
-Form.setOpen(false)
-console.log(Form.getOpen())
+let form = new LoginForm(document.body)
+form.onChange = data => console.log(data)
+form.onOpenChange = open => console.log(open)
+form.setValue('qwerty')
+console.log(form.getValue())
+form.setOpen(false)
+console.log(form.getOpen())