serg155alternate 2 lat temu
rodzic
commit
84e11010b7

+ 21 - 10
HW10 Closures and scopes/form OOP/script.js

@@ -93,15 +93,26 @@ function Form(el, data, okCallback, cancelCallback) {
         },
     }
 
-    function createForm(data) {
-        for (let [key, value] of Object.entries(data)) {
-            let errorSpan = document.createElement('span');
-            let input = inputCreators[value.constructor.name](key, value, newValue => {
-                    data[key] = newValue;
-            });
-            formBody.append(input);
-            formBody.append(errorSpan);
+    function createForm(initialState) {
+        let formBody = document.createElement('div')
+        let okButton = document.createElement('button')
+        okButton.innerHTML = 'OK'
+        let cancelButton = document.createElement('button')
+        cancelButton.innerHTML = 'Cancel';
+            for (let [key, value] of Object.entries(initialState)) {
+                let errorSpan = document.createElement('span');
+                let input = inputCreators[value.constructor.name](key, value, newValue => {
+                    initialState[key] = newValue;
+                });
+        formBody.append(input, errorSpan, okButton, cancelButton  );
+        el.appendChild(formBody)
+        this.okCallback = okCallback
+        this.cancelCallback = cancelCallback;
+        this.data = data
+        this.validators = {
+    
         }
+    }
 
     }
     for (let [key, value] of Object.entries(data)) {
@@ -124,9 +135,9 @@ function Form(el, data, okCallback, cancelCallback) {
     if (typeof cancelCallback === 'function') {
         formBody.appendChild(cancelButton);
         cancelButton.onclick = () => {
-           // formBody.remove();
+            formBody.remove();
             createForm(initialState);
-           // this.cancelCallback();
+            this.cancelCallback();
         }
     }
 

+ 15 - 1
HW11 Redux/style.css

@@ -9,11 +9,23 @@
     padding: 50px;
 }
 table {
-    margin-top: 10px;
+    margin-top: 20px;
     border-style: ridge;
     text-align: center;
     vertical-align: middle;
+    background-color: rgb(228, 217, 217);
+    color: rgb(38, 21, 127);
 }
+/* table:before {
+    content: 'REDUX';
+    position: absolute;
+    top: 90px;
+    left: 52px;
+    width: 62%;
+    height: 100px;
+    border-bottom: 0;
+    background-color:chartreuse;
+} */
 td {
     border-style: ridge;
     padding: 5px;
@@ -25,3 +37,5 @@ td {
  tr:nth-child(2n + 1) {
     background-color: rgb(223, 227, 235);
  }
+
+

+ 1 - 0
HW12 Async , callback hell/index.html

@@ -11,6 +11,7 @@
 
 <body>
     <div class="container">
+        <div id='root'></div>
        
     </div>
     <script src="script.js"></script>

Plik diff jest za duży
+ 191 - 0
HW12 Async , callback hell/script.js


+ 11 - 0
HW12 Async , callback hell/style.css

@@ -8,3 +8,14 @@
     margin: 0 auto;
     padding: 50px;
 }
+td {
+    border-style: ridge;
+    padding: 5px;
+    width: 40px;
+    height: 40px;
+    text-align: center;
+    vertical-align: middle;
+ }
+ tr:nth-child(2n + 1) {
+    background-color: rgb(223, 227, 235);
+ }