Mitrofanova Natali %!s(int64=3) %!d(string=hai) anos
pai
achega
df1c29bdff

RGB/.idea/.gitignore → ClassWorks/ClassWork (promisofication)/.idea/.gitignore


RGB/.idea/.name → ClassWorks/ClassWork (promisofication)/.idea/.name


RGB/.idea/ClassWork.iml → ClassWorks/ClassWork (promisofication)/.idea/ClassWork.iml


RGB/.idea/modules.xml → ClassWorks/ClassWork (promisofication)/.idea/modules.xml


+ 23 - 0
ClassWorks/ClassWork (promisofication)/index.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <div id="wrapper">
+        <p>Login :</p>
+        <input type="text" id="login">
+        <p>Password :</p>
+        <input type="password" id="password">
+        <button id="check">Check</button>
+        
+        <button id="cancel">Cancel</button>
+        <p id="result"></p>
+    </div>
+
+    <script src="script.js"></script>
+</body>
+</html>

+ 67 - 0
ClassWorks/ClassWork (promisofication)/script.js

@@ -0,0 +1,67 @@
+// function confirmPromise(text){
+    
+//     return new Promise((fulfill, reject) => {
+//         let a = confirm(text);
+//         if(a === false){
+//             reject("i'm absent")
+//         }else{
+//         fulfill("yes")
+//     }  
+// })
+// }
+
+// confirmPromise("Are you here?")
+//     .then((result)=>{console.log(result);})
+//     .catch((result)=>console.log(result))
+
+
+function promptPromise(text){
+    
+    return new Promise((fulfill, reject) => {
+        let a = prompt(text);
+        if(a === null || a === ""){
+            reject("i'm absent")
+        }else{
+            fulfill(a)
+    }
+})
+}
+
+promptPromise("What is your name?")
+    .then((res)=>console.log(res))
+    .catch((res)=>console.log(res))
+
+// let {login,password} = await loginFormPromis()
+
+const login = document.getElementById("login");
+const password = document.getElementById("password");
+const btnCancel = document.getElementById("cancel");
+const btnCheck = document.getElementById("check");
+const result = document.getElementById("result");
+
+function loginForm(e){
+    const p = new Promise((fulfill,reject)=>{
+        let log = login.value;
+        let pass = password.value;
+        const user = {
+            login:"",
+            password: "",
+        }
+        if((log !== "" && log !== undefined)&&(pass !== "" && pass !== undefined && e.target !== btnCancel)){
+            user.login = log;
+            user.password = pass;
+            fulfill(user);
+        }else{
+            reject("something is wrong");
+        }
+    })
+    p.then((user) => console.log(user))
+    .catch((res)=>{
+        login.value = "";
+        password.value = "";
+        console.log(res)
+    });
+    
+}
+btnCheck.addEventListener("click", loginForm)
+btnCancel.addEventListener("qclick", loginForm)

+ 0 - 0
ClassWorks/ClassWork (promisofication)/style.css


+ 5 - 0
ClassWorks/RGB/.idea/.gitignore

@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 1 - 0
ClassWorks/RGB/.idea/.name

@@ -0,0 +1 @@
+script.js

+ 12 - 0
ClassWorks/RGB/.idea/ClassWork.iml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/temp" />
+      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+      <excludeFolder url="file://$MODULE_DIR$/tmp" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
ClassWorks/RGB/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/ClassWork.iml" filepath="$PROJECT_DIR$/.idea/ClassWork.iml" />
+    </modules>
+  </component>
+</project>

RGB/assets/1@3x.png → ClassWorks/RGB/assets/1@3x.png


RGB/assets/skillet_-_hero.mp3 → ClassWorks/RGB/assets/skillet_-_hero.mp3


RGB/index.html → ClassWorks/RGB/index.html


RGB/script.js → ClassWorks/RGB/script.js


RGB/style.css → ClassWorks/RGB/style.css


+ 12 - 0
HW10 Scope and Closures/index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Document</title>
+    <link rel="stylesheet" href="style.css"><link
+</head>
+<body>
+
+    <script src="script.js"></script>
+</body>
+</html>

+ 90 - 0
HW10 Scope and Closures/script.js

@@ -0,0 +1,90 @@
+// Task makeProfileTimer
+
+// function makeProfileTimer(){
+//     const t0 = performance.now();
+//     alert('Замеряем время работы этого alert');
+//     return function (){
+        
+//         const t1 = performance.now()
+//         return t1-t0;
+//     }
+
+// }
+// const timer = makeProfileTimer();
+// alert(timer());
+
+
+//  Task makeSaver
+
+// function makeSaver(func){
+//     let result = null;
+//     return function() {
+//         result = ( result === null ? func() : result);
+//         return result;
+//     }
+// }
+
+// var saver = makeSaver(Math.random);
+// var value1 = saver()              
+// var value2 = saver()           
+// console.log(value1 === value2)                 // всегда true
+
+// var saver2 = makeSaver(() => console.log('saved function called') || [null, undefined, false, '', 0, Math.random()][Math.ceil(Math.random()*6)])
+// var value3 = saver2()
+// var value4 = saver2()
+
+// console.log(value3 === value4) // тоже должно быть true
+
+
+// let namePrompt = prompt.bind(window, 'Как тебя зовут?')
+// let nameSaver = makeSaver(namePrompt)
+// alert(`Привет! Prompt еще не было!`)
+// alert(`Привет ${nameSaver()}. Только что запустился prompt, первый и последний раз`)
+// alert(`Слушай, ${nameSaver()}, го пить пиво. Ведь prompt был только один раз`)
+
+// Task Final countdown
+
+// (function () {
+//     let sec = 5;
+//     return function(){
+//         for(let i = 0; i <= sec; i++){
+//             setTimeout(()=>{
+//                 console.log(sec === 0 ? "Поехали" : sec);
+//                 sec--;
+//             }, i * 1000)
+//         }
+//     }()
+//     })();
+
+
+
+
+// Task myBind
+
+function myBind( func, context, arr){
+    return function(...params){
+        let i = 0;
+        const filledArr = arr.map(item => {
+            if (item){
+            return item
+        } else {
+            i++;
+            return params[i-1]
+        }
+    })
+        return func.call(context, ...filledArr);
+    }
+}
+var pow5 = myBind(Math.pow, Math, [undefined, 5]) 
+var cube = myBind(Math.pow, Math, [undefined, 3]) 
+
+console.log(pow5(2)) // => 32, вызывает Math.pow(2,5), соотнесите с [undefined, 5]
+console.log(cube(3)) // => 27
+
+var chessMin = myBind(Math.min, Math, [undefined, 4, undefined, 5,undefined, 8,undefined, 9])
+console.log(chessMin(-1,-5,3,15)) // вызывает Math.min(-1, 4, -5, 5, 3, 8, 15, 9), результат -5
+
+// var zeroPrompt = myBind(prompt, window, [undefined, "0"])
+// var someNumber = zeroPrompt("Введите число")   
+
+console.log(myBind((...params) => params.join(''), null, [undefined, 'b', undefined, undefined, 'e', 'f'])('a','c','d') === 'abcdef')

+ 0 - 0
HW10 Scope and Closures/style.css


+ 5 - 0
HW11 Redux/.idea/.gitignore

@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 1 - 0
HW11 Redux/.idea/.name

@@ -0,0 +1 @@
+script.js

+ 12 - 0
HW11 Redux/.idea/ClassWork.iml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/temp" />
+      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
+      <excludeFolder url="file://$MODULE_DIR$/tmp" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
HW11 Redux/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/ClassWork.iml" filepath="$PROJECT_DIR$/.idea/ClassWork.iml" />
+    </modules>
+  </component>
+</project>

BIN=BIN
HW11 Redux/auto.jpg


+ 30 - 0
HW11 Redux/index.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>kicet</title>
+    <link rel="stylesheet" href="style.css">
+</head>
+<body>
+<div class="wrapper">
+    <div class="showcase">
+    <select id="select"></select>
+    <input id="input" placeholder="скока шт надо?" type="number">
+</div>
+    <p id="cashier"> К ОПЛАТЕ :</p>
+    <p>Баблоприемник</p>  
+   
+    <!-- <table id="table"></table> -->
+<div class="wrapperBablo">
+    
+    <input id="bablo" placeholder="скока даешь?" type="number">
+    <button id="btn">Купить</button>
+</div>
+<p class="alarm">Автомат сдачу не дает!</p>
+    <div class="cashbox">КАССА: 0</div>
+    
+</div>
+
+    <script src="script.js"></script>
+</body>
+</html>

+ 113 - 0
HW11 Redux/script.js

@@ -0,0 +1,113 @@
+const select = document.getElementById("select");
+const input = document.getElementById("input");
+const btn = document.getElementById("btn");
+const cash = document.querySelector(".cashbox");
+const bablo = document.getElementById("bablo");
+const cashier = document.getElementById("cashier")
+
+const store = createStore(reducer);
+store.subscribe(updateCashbox);
+const unsubscribe = store.subscribe(() => console.log(store.getState()));
+
+function reducer(state, { type, ШО, СКОКА, БАБЛО }) {
+  //объект action деструктуризируется на три переменных
+  if (!state) {
+    //начальная уборка в ларьке:
+    return {
+      stock: {
+        пиво: {
+          price: 20,
+          amount: 100,
+        },
+        чипсы: {
+          price: 25,
+          amount: 100,
+        },
+        сиги: {
+          price: 50,
+          amount: 100,
+        },
+      },
+      cashbox: 0,
+    };
+    //
+  }
+  if (type === "КУПИТЬ") {
+    //если тип action - КУПИТЬ, то:
+    return {
+      ...state, //берем все что было из ассортимента
+      stock: {
+          ...state.stock,
+          [ШО]: {
+            price: state.stock[ШО].price,
+            amount: state.stock[ШО].amount - СКОКА,
+
+      }
+      
+      
+      }, //и уменьшаем то, что покупается на количество
+    cashbox: state.cashbox + БАБЛО,
+
+
+    };
+  }
+
+  return state; //если мы не поняли, что от нас просят в `action` - оставляем все как есть
+}
+
+function createStore(reducer) {
+  let state = reducer(undefined, {}); //стартовая инициализация состояния, запуск редьюсера со state === undefined
+  let cbs = []; //массив подписчиков
+
+  const getState = () => state; //функция, возвращающая переменную из замыкания
+  const subscribe = (cb) => (
+    cbs.push(cb), //запоминаем подписчиков в массиве
+    () => (cbs = cbs.filter((c) => c !== cb))
+  ); //возвращаем функцию unsubscribe, которая удаляет подписчика из списка
+
+  const dispatch = (action) => {
+    const newState = reducer(state, action); //пробуем запустить редьюсер
+    if (newState !== state) {
+      //проверяем, смог ли редьюсер обработать action
+      state = newState; //если смог, то обновляем state
+      for (let cb of cbs) cb(); //и запускаем подписчиков
+    }
+  };
+
+  return {
+    getState, //добавление функции getState в результирующий объект
+    dispatch,
+    subscribe, //добавление subscribe в объект
+  };
+}
+let html = "";
+for (let key in store.getState().stock) {
+  html += `<option>${key}</option>`;
+}
+select.innerHTML = html;
+
+btn.addEventListener("click", buy);
+input.addEventListener("input", counter );
+select.addEventListener("click", counter)
+
+function buy(e) {
+    if(bablo.value >= (input.value * store.getState().stock[select.value].price) ){
+  store.dispatch({
+    type: "КУПИТЬ",
+    ШО: select.value,
+    СКОКА: input.value,
+    БАБЛО: Number(bablo.value),
+  });
+  console.log(store);
+  bablo.value = "";
+}else{
+    alert("Не хватает бабла");
+}
+}
+function updateCashbox(){
+    cash.innerText = `КАССА : ${store.getState().cashbox}`
+}
+function counter( ){
+    cashier.innerText = ` К ОПЛАТЕ : ${ (input.value * store.getState().stock[select.value].price)}`
+
+}

+ 73 - 0
HW11 Redux/style.css

@@ -0,0 +1,73 @@
+html{
+    width: 100vw;
+    height: 100vh;
+    background-color: #E0E0E0;
+}
+body{
+    width: 100%;
+    height: 100%;
+    display: flex;
+
+    justify-content: center;
+    align-items: center;
+}
+.wrapper{
+    min-width: 800px;
+    min-height: 1000px;
+    position: relative;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    
+}
+.wrapper::after{
+    content: "";
+    position: absolute;
+    background: url(auto.jpg);
+    z-index: -1;
+    width: 100%;
+    height: 100%;
+    opacity: 0.7;
+    background-repeat: no-repeat no-repeat;
+    background-position: center;
+}
+
+input{
+    height: 25px;
+    text-align: center;
+    font-size: 20px;
+}
+select{
+    height: 31px;
+    font-size: 25px;
+}
+button{
+    font-size: 20px;
+    width: 100px;
+    margin-left: 10px;
+    height: 31px;
+}
+.cashbox{
+    margin-top: 50px;
+    background-color: blanchedalmond;
+}
+p{
+    padding: 3px;
+    font-size: 20px;
+    background-color: honeydew;
+}
+.showcase{
+    
+    display: flex;
+}
+.wrapperBablo{
+    display: flex;
+}
+#bablo{
+    width: 210px;    
+}
+.alarm{
+    color: red;
+
+}