{"action":"created","comment":{"url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/comments/49931396","id":49931396,"diff_hunk":"@@ -0,0 +1,529 @@\n+\"use strict\";\n+/* ------------------------------------------------------------------------------\n+   ФУНКЦИЯ-КОНСТРУКТОР ДЛЯ КАЛЬКУЛЯТОРА\n+   ----------------------------------------------------------------------------*/\n+function Calculator() {\n+\t\n+\tvar mainContainer,    // Основной контейнер для размещения всех элементов\n+\t    indicator,        // Контейнер для элементов индикатора\n+\t\tupperLine,        // Контейнер для отображение промежуточных результатов\n+\t\t                  // расчетов в верхней строке индикатора\n+\t\tlowerLine,        // Нижняя строка индикатора (текущее число)\n+\t\tmemoryIndicator,  // Индикатор состояния памяти в верхней строке главного индикатора\n+\t\t\n+\t\tcurrentNumber = 0,\n+\t\tpreviousNumber = 0,\n+\t\tcurrentOperator = \"\",\n+\t\tmemoryValue = 0,\n+\t\tmaxLength = 16;\n+/*-----------------  Описание клавиш калькулятора -----------------------------*/\t\n+\tvar element0 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"0\", coordinateX: 4, coordinateY: 267, dimensionX: 85, dimensionY: 35\t};\n+\tvar element1 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"1\", coordinateX: 4, coordinateY: 230, dimensionX: 42, dimensionY: 35\t};\n+\tvar element2 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"2\", coordinateX: 48, coordinateY: 230, dimensionX: 42, dimensionY: 35};\n+\tvar element3 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"3\", coordinateX: 92, coordinateY: 230, dimensionX: 42, dimensionY: 35};\n+\tvar element4 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"4\", coordinateX: 4, coordinateY: 193, dimensionX: 42, dimensionY: 35};\n+\tvar element5 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"5\", coordinateX: 48, coordinateY: 193, dimensionX: 42, dimensionY: 35};\n+\tvar element6 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"6\", coordinateX: 92, coordinateY: 193, dimensionX: 42, dimensionY: 35};\n+\tvar element7 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"7\", coordinateX: 4, coordinateY: 156, dimensionX: 42, dimensionY: 35};\n+\tvar element8 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"8\", coordinateX: 48, coordinateY: 156, dimensionX: 42, dimensionY: 35};\n+\tvar element9 = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \"9\", coordinateX: 92, coordinateY: 156, dimensionX: 42, dimensionY: 35};\n+\tvar elementPoint = {\n+\t\ttypeOfElement: \"numeric\", innerValue: \".\", coordinateX: 92, coordinateY: 267, dimensionX: 42, dimensionY: 35};\t\n+\tvar elementPlus = {\n+\t\ttypeOfElement: \"binarOperation\", innerValue: \"+\", coordinateX: 136, coordinateY: 267, dimensionX: 42, dimensionY: 35};\n+\tvar elementMinus = {\n+\t\ttypeOfElement: \"binarOperation\", innerValue: \"-\", coordinateX: 136, coordinateY: 230, dimensionX: 42, dimensionY: 35};\n+\tvar elementMult = {\n+\t\ttypeOfElement: \"binarOperation\", innerValue: \"*\", coordinateX: 136, coordinateY: 193, dimensionX: 42, dimensionY: 35};\n+\tvar elementDiv = {\n+\t\ttypeOfElement: \"binarOperation\", innerValue: \"/\", coordinateX: 136, coordinateY: 156, dimensionX: 42, dimensionY: 35};\n+\tvar elementEq = {\n+\t\ttypeOfElement: \"result\", innerValue: \"=\", coordinateX: 180, coordinateY: 230, dimensionX: 42, dimensionY: 72};\t\t\n+\tvar elementCE = {\n+\t\ttypeOfElement: \"correction\", innerValue: \"CE\", coordinateX: 4, coordinateY: 119, dimensionX: 42, dimensionY: 35};\t\n+\tvar elementBS = {\n+\t\ttypeOfElement: \"correction\", innerValue: \"&#8592\", coordinateX: 48, coordinateY: 119, dimensionX: 86, dimensionY: 35};\t\n+\tvar elementC = {\n+\t\ttypeOfElement: \"correction\", innerValue: \"C\", coordinateX: 4, coordinateY: 82, dimensionX: 42, dimensionY: 35};\t\n+\tvar elementInv = {\n+\t\ttypeOfElement: \"unarOperation\", innerValue: \"+/-\", coordinateX: 136, coordinateY: 119, dimensionX: 42, dimensionY: 35};\t\n+\tvar elementSqr = {\n+\t\ttypeOfElement: \"unarOperation\", innerValue: \"Sqr\", coordinateX: 180, coordinateY: 119, dimensionX: 42, dimensionY: 35};\t\n+\tvar elementPercent = {\n+\t\ttypeOfElement: \"binarOperation\", innerValue: \"%\", coordinateX: 180, coordinateY: 193, dimensionX: 42, dimensionY: 35};\t\n+\tvar elementRevers = {\n+\t\ttypeOfElement: \"unarOperation\", innerValue: \"1/x\", coordinateX: 180, coordinateY: 156, dimensionX: 42, dimensionY: 35};\t\t\n+\tvar elementMC = {\n+\t\ttypeOfElement: \"memory\", innerValue: \"MC\", coordinateX: 48, coordinateY: 82, dimensionX: 42, dimensionY: 35}\t\n+\tvar elementMR = {\n+\t\ttypeOfElement: \"memory\", innerValue: \"MR\", coordinateX: 92, coordinateY: 82, dimensionX: 42, dimensionY: 35}\n+\tvar elementMPlus = {\n+\t\ttypeOfElement: \"memory\", innerValue: \"M+\", coordinateX: 136, coordinateY: 82, dimensionX: 42, dimensionY: 35}\n+\tvar elementMMinus = {\n+\t\ttypeOfElement: \"memory\", innerValue: \"M-\", coordinateX: 180, coordinateY: 82, dimensionX: 42, dimensionY: 35}\t\n+\tvar elementRemove = {\n+\t\ttypeOfElement: \"winManager\", innerValue: \"X\", coordinateX: 180, coordinateY: 3, dimensionX: 42, dimensionY: 15}\t\t\n+\tvar elementMinimize = {\n+\t\ttypeOfElement: \"winManager\", innerValue: \"__\", coordinateX: 136, coordinateY: 3, dimensionX: 42, dimensionY: 15}\n+\tvar elementView = {\n+\t\ttypeOfElement: \"winManager\", innerValue: \"Вид\", coordinateX: 4, coordinateY: 3, dimensionX: 60, dimensionY: 15}\t\t\n+\n+/*--------- Вспомогательные массивы для обработчиков событий клавиатуры ---------*/\n+\tvar numericKeys = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \".\"];\n+\tvar binarKeys = [\"+\", \"-\", \"*\", \"/\"];\n+\tvar resultKey = \"=\";\n+\tvar correctionKeysCodes = [27, 46, 8];\n+\tvar correctionKeysValues = [\"C\", \"CE\", \"←\"];\n+\t\n+/*----------------------- Построение DOM калькулятора ---------------------------*/\t\n+\tfunction render() {\n+\t\tmainContainer = document.createElement(\"div\");\n+\t\tmainContainer.className = \"mainContainer\";\n+\t\tdocument.body.appendChild(mainContainer);\n+\t\t\n+\t\tindicator = document.createElement(\"div\");\n+\t\tindicator.className = \"indicator\";\n+\t\tmainContainer.appendChild(indicator)\n+\t\t\n+\t\tupperLine = document.createElement(\"div\");\n+\t\tupperLine.className = \"upperLine\";\n+\t\tupperLine.innerHTML = \"\";\n+\t\tindicator.appendChild(upperLine)\n+\t\t\n+\t\tlowerLine= document.createElement(\"div\");\n+\t\tlowerLine.className = \"lowerLine\";\n+\t\tlowerLine.innerHTML = \"0\";\n+\t\tindicator.appendChild(lowerLine);\n+\t\t\n+\t\tmemoryIndicator= document.createElement(\"div\");\n+\t\tmemoryIndicator.className = \"memoryIndicator\";\n+\t\tmemoryIndicator.innerHTML = \"\";\n+\t\tindicator.appendChild(memoryIndicator);\t\t\n+\t\t\n+\t\tmainContainer.appendChild(createButton( element0 ));\n+\t\tmainContainer.appendChild(createButton( element1 ));\n+\t\tmainContainer.appendChild(createButton( element2 ));\n+\t\tmainContainer.appendChild(createButton( element3 ));\n+\t\tmainContainer.appendChild(createButton( element4 ));\n+\t\tmainContainer.appendChild(createButton( element5 ));\n+\t\tmainContainer.appendChild(createButton( element6 ));\n+\t\tmainContainer.appendChild(createButton( element7 ));\n+\t\tmainContainer.appendChild(createButton( element8 ));\n+\t\tmainContainer.appendChild(createButton( element9 ));\n+\t\tmainContainer.appendChild(createButton( elementPoint ));\n+\t\tmainContainer.appendChild(createButton( elementPlus ));\n+\t\tmainContainer.appendChild(createButton( elementMinus ));\n+\t\tmainContainer.appendChild(createButton( elementMult ));\n+\t\tmainContainer.appendChild(createButton( elementDiv ));\n+\t\tmainContainer.appendChild(createButton( elementEq ));\n+\t\tmainContainer.appendChild(createButton( elementCE ));\n+\t\tmainContainer.appendChild(createButton( elementBS ));\t\t\n+\t\tmainContainer.appendChild(createButton( elementC ));\t\t\n+\t\tmainContainer.appendChild(createButton( elementInv ));\t\t\n+\t\tmainContainer.appendChild(createButton( elementSqr ));\t\t\n+\t\tmainContainer.appendChild(createButton( elementPercent ));\t\t\n+\t\tmainContainer.appendChild(createButton( elementRevers ));\n+\t\tmainContainer.appendChild(createButton( elementMR ));\n+\t\tmainContainer.appendChild(createButton( elementMC ));\n+\t\tmainContainer.appendChild(createButton( elementMPlus ));\n+\t\tmainContainer.appendChild(createButton( elementMMinus ));\n+\t\tmainContainer.appendChild(createButton( elementRemove ));\n+\t\tmainContainer.appendChild(createButton( elementMinimize ));\t\t\n+\t\tmainContainer.appendChild(createButton( elementView ));\t\t\n+\t};\n+\t/* -------------------------------------------------------------------------------*/\n+\t/* --------------------- ОБРАБОТЧИКИ СОБЫТИЙ НА КАЛЬКУЛЯТОРЕ----------------------*/\n+\t/* -------------------- Обработчик событий мыши  ---------------------------------*/\n+\tfunction clickHandler (event) {\n+\t\t\n+\t\tvar clickedElement = event.target;\n+\t\t\n+\t\tif (clickedElement.classList.contains('button')) {\n+\t\t\tvar classArray = clickedElement.className.split(' ');\n+\t\t\tswitch(classArray[1]){\n+\t\t\t\tcase \"numeric\":\n+\t\t\t\t\tnumericHandler(clickedElement);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"result\":\n+\t\t\t\t\tresultHandler(clickedElement);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"correction\":\n+\t\t\t\t\tcorrectionHandler(clickedElement);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"unarOperation\":\n+\t\t\t\t\tunarOperationHandler(clickedElement);\n+\t\t\t\t\tbreak;\t\t\t\n+\t\t\t\tcase \"binarOperation\":\n+\t\t\t\t\tbinarOperationHandler(clickedElement);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"memory\":\n+\t\t\t\t\tmemoryHandler(clickedElement);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"winManager\":\n+\t\t\t\t\twinManagerHandler(clickedElement);\n+\t\t\t\t\tbreak;\t\t\t\t\t\n+\t\t\t};\t\t\n+\t\t};\n+\t\t\n+\t};\n+\t/* ------------------ Обработчик нажатия символьных клавиш  -----------------*/\t\n+\tfunction keypressHandler(event) {\n+\t\t\n+\t\tvar element = {\n+\t\t\tinnerHTML: \"\",\n+\t\t\ttypeOf:    \"defaultType\"\n+\t\t};\n+\t\t\n+\t\tvar currentChar = getChar (event);\n+\t\t\n+\t\tfor (var i = 0; i < numericKeys.length; i++) {\n+\t\t\tif(currentChar == numericKeys[i]) {\n+\t\t\t\telement.typeOf = \"numeric\";\n+\t\t\t\telement.innerHTML = currentChar;\n+\t\t\t\tbreak;\n+\t\t\t};\n+\t\t};\n+\t\t\n+\t\tfor (var i = 0; i < binarKeys.length; i++) {\n+\t\t\tif(currentChar == binarKeys[i]) {\n+\t\t\t\telement.typeOf = \"binarOperation\";\n+\t\t\t\telement.innerHTML = currentChar;\n+\t\t\t\tbreak;\n+\t\t\t};\n+\t\t};\t\n+\t\t\n+\t\tif(currentChar == resultKey) {\n+\t\t\telement.typeOf = \"result\";\n+\t\t\telement.innerHTML = currentChar;\n+\t\t};\n+\t\t\n+\t\tswitch(element.typeOf){\n+\t\t\tcase \"numeric\":\n+\t\t\t\tnumericHandler(element);\n+\t\t\t\tbreak;\n+\t\t\tcase \"result\":\n+\t\t\t\tresultHandler(element);\n+\t\t\t\tbreak;\t\t\t\n+\t\t\tcase \"binarOperation\":\n+\t\t\t\tbinarOperationHandler(element);\n+\t\t\t\tbreak;\t\t\t\t\n+\t\t};\t\t\n+\t};\n+\t/* ------------------ Обработчик нажатия управляющих клавиш  -----------------*/\t\t\n+\tfunction keyupHandler(event) {\n+\t\tfor (var i = 0; i < correctionKeysCodes.length; i++) {\n+\t\t\tif (event.keyCode == correctionKeysCodes[i]) {\n+\t\t\t\tvar element = {\n+\t\t\t\t\tinnerHTML: correctionKeysValues[i],\n+\t\t\t\t};\n+\t\t\t\tcorrectionHandler(element);\n+\t\t\t\tbreak;\n+\t\t\t};\n+\t\t};\n+\t};\n+\t/* -------------------------------------------------------------------------------*/\n+\t/* ------------- ФУНКЦИИ, РЕАЛИЗУЮЩИЕ ФУНКЦИОНАЛЬНОСТЬ (ПЛОХОЙ РУССКИЙ)-----------*/\n+\t/* ------ Действия, при нажатии цифровых клавиш на калькуляторе  -----------------*/\t\n+\tfunction numericHandler(elem) {\n+\t\tif(lowerLine.innerHTML.length >= maxLength) return;\n+\t\tif(lowerLine.innerHTML == \"0\") {\n+\t\t\tif(elem.innerHTML == \"0\") return;\n+\t\t\tif(elem.innerHTML == \".\") {\n+\t\t\t\tlowerLine.innerHTML += elem.innerHTML;\t\n+\t\t\t\treturn;\n+\t\t\t}\n+\t\t\tlowerLine.innerHTML = elem.innerHTML;\n+\t\t\treturn;\n+\t\t}\n+\t\tif(elem.innerHTML == \".\") {\n+\t\t\tif(~lowerLine.innerHTML.indexOf(\".\")) return;\n+\t\t};\n+\t\tlowerLine.innerHTML += elem.innerHTML;\t\t\n+\t};\n+\t/* ------ Действия, при нажатии клавиши \"равно\" (\"=\") на калькуляторе  -----------*/\t\n+\tfunction resultHandler (elem) {\n+\t\tif(currentOperator == \"\") return;\n+\t\tcurrentNumber = +lowerLine.innerHTML;\n+\t\tcurrentNumber = madeBinarOperation(previousNumber, currentNumber, currentOperator);\n+\t\tlowerLine.innerHTML = (\"\" + currentNumber).slice(0, maxLength);\n+\t\tcurrentOperator = \"\";\n+\t\tupperLine.innerHTML = \"\";\n+\t};\n+\t/* ------ Действия, при нажатии клавиш коррекции на калькуляторе  -----------------*/\n+\tfunction correctionHandler(elem) {\n+\t\tswitch(elem.innerHTML) {\n+\t\t\tcase \"←\":\n+\t\t\t\tif(lowerLine.innerHTML == \"0\") {\n+\t\t\t\treturn;\n+\t\t\t\t};\n+\t\t\t\tvar currentValueLength = lowerLine.innerHTML.length;\n+\t\t\t\tif(currentValueLength == 1) {\n+\t\t\t\t\tlowerLine.innerHTML = \"0\";\n+\t\t\t\t} else {\n+\t\t\t\t\tlowerLine.innerHTML = lowerLine.innerHTML.slice(0,(currentValueLength - 1));\n+\t\t\t\t};\n+\t\t\t\tbreak;\n+\t\t\tcase \"CE\":\n+\t\t\t\tlowerLine.innerHTML = \"0\";\n+\t\t\t\tbreak;\n+\t\t\tcase \"C\":\n+\t\t\t\tupperLine.innerHTML = \"\";\n+\t\t\t\tpreviousNumber = 0;\n+\t\t\t\tcurrentOperator = \"\";\n+\t\t\t\tlowerLine.innerHTML = \"0\";\n+\t\t\t\tbreak;\n+\t\t};\n+\t};\n+\t/* ------ Действия, при нажатии клавиш унарных операций на калькуляторе  ----------*/\n+\tfunction unarOperationHandler(elem) {\n+\t\tcurrentNumber = +lowerLine.innerHTML;\n+\t\tswitch(elem.innerHTML) {\n+\t\t\tcase \"+/-\":\n+\t\t\t\tcurrentNumber *= (-1);\n+\t\t\t\tlowerLine.innerHTML = (\"\" + currentNumber).slice(0, maxLength);\n+\t\t\t\tbreak;\n+\t\t\tcase \"Sqr\":\n+\t\t\t\tif(currentNumber > 0) {\n+\t\t\t\t\tcurrentNumber = Math.sqrt(currentNumber);\n+\t\t\t\t\tlowerLine.innerHTML = (\"\" + currentNumber).slice(0, maxLength);\n+\t\t\t\t};\t\t\t\n+\t\t\t\tbreak;\n+\t\t\tcase \"1/x\":\n+\t\t\t\tif(currentNumber == 0) {\n+\t\t\t\t\talert(\"На ноль делить нельзя !\");\n+\t\t\t\t\treturn;\n+\t\t\t\t} else {\n+\t\t\t\t\tcurrentNumber = 1 / currentNumber;\n+\t\t\t\t\tlowerLine.innerHTML = (\"\" + currentNumber).slice(0, maxLength);\t\t\t\t\t\n+\t\t\t\t};\t\t\t\n+\t\t\t\tbreak;\t\t\t\t\n+\t\t};\n+\t};\t\n+\t/* ------ Действия, при нажатии клавиш бинарных операций на калькуляторе  ----------*/\t\n+\tfunction binarOperationHandler(elem) {\n+\t\tif(upperLine.innerHTML == \"\") {\n+\t\t\tcurrentOperator = elem.innerHTML;\n+\t\t\tpreviousNumber = +lowerLine.innerHTML;\t\t\t\n+\t\t} else {\n+\t\t\tcurrentNumber = +lowerLine.innerHTML;\n+\t\t\tpreviousNumber = madeBinarOperation(previousNumber, currentNumber, currentOperator);\n+\t\t\tcurrentOperator = elem.innerHTML;\t\n+\t\t};\n+\t\tupperLine.innerHTML = (\"\" + previousNumber).slice(0, maxLength) + currentOperator;\n+\t\tlowerLine.innerHTML = \"0\";\n+\t};\t\n+\t/* ------ Действия, при нажатии клавиш управления памятью на калькуляторе  ----------*/\t\t\n+\tfunction memoryHandler(elem) {\n+\t\tswitch(elem.innerHTML) {\n+\t\t\tcase \"M+\":\n+\t\t\t\tmemoryValue += +lowerLine.innerHTML;\n+\t\t\t\tif(memoryIndicator.innerHTML == \"\") {\n+\t\t\t\t\tmemoryIndicator.innerHTML = \"MEMORY\";\n+\t\t\t\t};\n+\t\t\t\tbreak;\n+\t\t\tcase \"M-\":\n+\t\t\t\tmemoryValue -= +lowerLine.innerHTML;\n+\t\t\t\tif(memoryIndicator.innerHTML == \"\") {\n+\t\t\t\t\tmemoryIndicator.innerHTML = \"MEMORY\";\n+\t\t\t\t}\t\t\t\t\n+\t\t\t\tbreak;\n+\t\t\tcase \"MC\":\n+\t\t\t\tmemoryValue = 0;\n+\t\t\t\tif(memoryIndicator.innerHTML == \"MEMORY\") {\n+\t\t\t\t\tmemoryIndicator.innerHTML = \"\";\n+\t\t\t\t};\n+\t\t\t\tbreak;\n+\t\t\tcase \"MR\":\n+\t\t\t\tlowerLine.innerHTML = (\"\" + memoryValue).slice(0, maxLength);\n+\t\t\t\tbreak;\n+\t\t};\t\n+\t};\t\n+\t/* ------ Действия, при нажатии клавиш управления видом и состоянием окна  ----------*/\t\n+\tfunction winManagerHandler(elem) {\n+\t\tswitch(elem.innerHTML) {\n+\t\t\tcase \"X\":\n+\t\t\t\tmainContainer.parentElement.removeChild(mainContainer);\n+\t\t\t\tbreak;\n+\t\t\tcase \"__\":\n+\t\t\t\tmainContainer.hidden = true;\n+\t\t\t\tmadeSmallContainer(mainContainer);\n+\t\t\t\tbreak;\n+\t\t\tcase \"Вид\":\n+\t\t\t\tmadeViewChooseContainer(mainContainer);\n+\t\t\t\tbreak;\t\t\t\t\n+\t\t};\n+\t};\t\n+\t/* ------------------------------------------------------------------------------------*/\n+\t\t\n+\trender();\n+\t\n+\tmainContainer.addEventListener(\"click\", clickHandler);\t\n+\tmainContainer.addEventListener(\"keypress\", keypressHandler);\t\n+\tmainContainer.addEventListener(\"keyup\", keyupHandler);\t\n+\t\n+};\n+/* ----------------------------------------------------------------------------------------*/\n+/* --------------------- ВСПОМОГАТЕЛЬНЫЕ ФУНКЦИИ ------------------------------------------*/\n+/* -------------- \tФормирование клавиши в DOM калькулятора  ------------------------------*/\n+function createButton(elementButton) {\n+\t\t\n+\tvar newButton = document.createElement(\"button\");\n+\n+\tnewButton.classList.add(\"button\");\n+\tnewButton.classList.add(elementButton.typeOfElement);\n+\tnewButton.style.top = elementButton.coordinateY + 'px';\n+\tnewButton.style.left = elementButton.coordinateX + 'px';\n+\tnewButton.style.width = elementButton.dimensionX + 'px';\n+\tnewButton.style.height = elementButton.dimensionY + 'px';\n+\tnewButton.innerHTML = elementButton.innerValue;\n+\t\n+\treturn newButton;\n+};\n+/* -------------- \tФункция выполнения бинарной операции  --------------------------------*/\t\n+function madeBinarOperation(number1, number2, operator) {\n+\tswitch(operator) {\n+\t\tcase \"+\": \n+\t\t\treturn  number1 + number2;\n+\t\tcase \"-\":\n+\t\t\treturn  number1 - number2;\n+\t\tcase \"/\": \n+\t\t\tif (number2 == 0){\n+\t\t\t\talert(\"На ноль делить нельзя !\");\n+\t\t\t\treturn number1;\n+\t\t\t} else {\n+\t\t\t\treturn  number1 / number2;\n+\t\t\t};\n+\t\tcase \"*\": \n+\t\t\treturn number1 * number2;\n+\t\tcase \"%\": \n+\t\t\tif (number2 == 0){\n+\t\t\t\talert(\"На ноль делить нельзя !\");\n+\t\t\t\treturn number1;\n+\t\t\t} else {\n+\t\t\t\treturn  100 * number1 / number2;\n+\t\t\t};\n+\t\t};\t\n+\t};\t\n+/* -------------- \tФункция получение символа с клавиатупы (ИЗ УЧЕБНИКА)-------------*/\n+function getChar(event) {\n+  if (event.which == null) {                      \n+    if (event.keyCode < 32) return null;          \n+    return String.fromCharCode(event.keyCode)\n+  }\n+\n+  if (event.which != 0 && event.charCode != 0) {   \n+    if (event.which < 32) return null;            \n+    return String.fromCharCode(event.which);      \n+  }\n+\n+  return null;                                     \n+}\n+/* ----------------------------------------------------------------------------------------*/\n+/* ---\tФУНКЦИЯ ФОРМИРОВАНИЯ \"СВЕРНУТОГО\" ВИДА С СООТВЕТСТВУЮЩИМИ ОБРАБОТЧИКАМИ -----------*/\t\n+function madeSmallContainer (mainElement) {\n+\tvar smallContainer;\n+\tvar elementRemove = {\n+\t\ttypeOfElement: \"winManager\", innerValue: \"X\", coordinateX: 180, coordinateY: 3, dimensionX: 42, dimensionY: 15}\t\t\n+\tvar elementMaximize = {\n+\t\ttypeOfElement: \"winManager\", innerValue: \"&#9744\", coordinateX: 136, coordinateY: 3, dimensionX: 42, dimensionY: 15}\t\n+\t\n+\tsmallContainer = document.createElement(\"div\");\n+\tsmallContainer.className = \"smallContainer\";\n+\tdocument.body.appendChild(smallContainer);\n+\t\t\n+\tsmallContainer.appendChild(createButton( elementRemove ));\n+\tsmallContainer.appendChild(createButton( elementMaximize ));\n+\n+\tsmallContainer.addEventListener(\"click\", smallClickHandler);\t\n+\t\n+\tfunction smallClickHandler (event) {\n+\t\t\n+\t\tvar clickedElement = event.target;\n+\t\t\n+\t\tif (clickedElement.classList.contains('button')) {\n+\t\t\tswitch(clickedElement.innerHTML) {\n+\t\t\t\tcase \"X\":\n+\t\t\t\t\tmainElement.parentElement.removeChild(mainElement);\n+\t\t\t\t\tsmallContainer.parentElement.removeChild(smallContainer);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"☐\":\n+\t\t\t\t\tmainElement.hidden = false;\n+\t\t\t\t\tsmallContainer.parentElement.removeChild(smallContainer);\n+\t\t\t\t\tbreak;\n+\t\t\t};\t\t\n+\t\t};\n+\t};\t\n+};\n+/* ----------------------------------------------------------------------------------------*/\n+/* ---\tФУНКЦИЯ ФОРМИРОВАНИЯ ОКНА УПРАВЛЕНИЯ ВИДОМ КАЛЬКУЛЯТОРА  --------------------------*/\n+/* ---\tС СООТВЕТСТВУЮЩИМИ ОБРАБОТЧИКАМИ --------------------------------------------------*/\n+function madeViewChooseContainer (mainElement) {\n+\t\n+\tvar viewChooseContainer;\n+\t\n+\tvar elementCommon = {\n+\t\ttypeOfElement: \"viewChooseButton\", innerValue: \"ОБЫЧНЫЙ\", coordinateX: 3, coordinateY: 3, dimensionX: 70, dimensionY: 15};\t\t\n+\tvar elementSimple = {\n+\t\ttypeOfElement: \"viewChooseButton\", innerValue: \"ПОПРОЩЕ\", coordinateX: 3, coordinateY: 21, dimensionX: 70, dimensionY: 15};\t\n+\t\t\n+\tviewChooseContainer = document.createElement(\"div\");\n+\tviewChooseContainer.className = \"viewChoose\";\n+\tmainElement.appendChild(viewChooseContainer);\n+\t\n+    viewChooseContainer.appendChild(createButton( elementCommon ));\n+    viewChooseContainer.appendChild(createButton( elementSimple ));\n+\t\n+\tmainElement.addEventListener(\"click\", viewChooseHandler);\n+\t\n+\tfunction viewChooseHandler (event) {\n+\t\t\n+\t\tvar clickedElement = event.target;\n+\t\t\n+\t\tif (clickedElement.classList.contains('viewChooseButton')) {\n+\t\t\tswitch(clickedElement.innerHTML) {\n+\t\t\t\tcase \"ОБЫЧНЫЙ\":\n+\t\t\t\t\tvar changedElements = document.querySelectorAll('.simple');\n+\t\t\t\t\tif(changedElements.length > 0){\n+\t\t\t\t\t\tfor(var i = 0; i < changedElements.length; i++) {\n+\t\t\t\t\t\t\tchangedElements[i].classList.remove(\"simple\");\n+\t\t\t\t\t\t};\n+\t\t\t\t\t};\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase \"ПОПРОЩЕ\":\n+\t\t\t\t\tvar changedElements = document.querySelectorAll('.simple');\n+\t\t\t\t\tif(changedElements.length == 0){","path":"calculator.js","position":504,"original_position":504,"commit_id":"5958fb6ad24b1080b67f2456008d4d988aa328fb","original_commit_id":"5958fb6ad24b1080b67f2456008d4d988aa328fb","user":{"login":"mgrinko","id":3237782,"avatar_url":"https://avatars.githubusercontent.com/u/3237782?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrinko","html_url":"https://github.com/mgrinko","followers_url":"https://api.github.com/users/mgrinko/followers","following_url":"https://api.github.com/users/mgrinko/following{/other_user}","gists_url":"https://api.github.com/users/mgrinko/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrinko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrinko/subscriptions","organizations_url":"https://api.github.com/users/mgrinko/orgs","repos_url":"https://api.github.com/users/mgrinko/repos","events_url":"https://api.github.com/users/mgrinko/events{/privacy}","received_events_url":"https://api.github.com/users/mgrinko/received_events","type":"User","site_admin":false},"body":"можно просто \r\n```\r\nif (!arr.length) {","created_at":"2016-01-16T12:53:51Z","updated_at":"2016-01-16T12:53:51Z","html_url":"https://github.com/mgrinko/oleg_pomazkov/pull/1#discussion_r49931396","pull_request_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/comments/49931396"},"html":{"href":"https://github.com/mgrinko/oleg_pomazkov/pull/1#discussion_r49931396"},"pull_request":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1","id":56252674,"html_url":"https://github.com/mgrinko/oleg_pomazkov/pull/1","diff_url":"https://github.com/mgrinko/oleg_pomazkov/pull/1.diff","patch_url":"https://github.com/mgrinko/oleg_pomazkov/pull/1.patch","issue_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/1","number":1,"state":"open","locked":false,"title":"First calculator implementation","user":{"login":"mgrinko","id":3237782,"avatar_url":"https://avatars.githubusercontent.com/u/3237782?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrinko","html_url":"https://github.com/mgrinko","followers_url":"https://api.github.com/users/mgrinko/followers","following_url":"https://api.github.com/users/mgrinko/following{/other_user}","gists_url":"https://api.github.com/users/mgrinko/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrinko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrinko/subscriptions","organizations_url":"https://api.github.com/users/mgrinko/orgs","repos_url":"https://api.github.com/users/mgrinko/repos","events_url":"https://api.github.com/users/mgrinko/events{/privacy}","received_events_url":"https://api.github.com/users/mgrinko/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-16T12:30:42Z","updated_at":"2016-01-16T12:53:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a429d0caeadd37da2f4ddd7ed14c1b6b106ee93","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1/commits","review_comments_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1/comments","review_comment_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/1/comments","statuses_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/statuses/5958fb6ad24b1080b67f2456008d4d988aa328fb","head":{"label":"mgrinko:gh-pages","ref":"gh-pages","sha":"5958fb6ad24b1080b67f2456008d4d988aa328fb","user":{"login":"mgrinko","id":3237782,"avatar_url":"https://avatars.githubusercontent.com/u/3237782?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrinko","html_url":"https://github.com/mgrinko","followers_url":"https://api.github.com/users/mgrinko/followers","following_url":"https://api.github.com/users/mgrinko/following{/other_user}","gists_url":"https://api.github.com/users/mgrinko/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrinko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrinko/subscriptions","organizations_url":"https://api.github.com/users/mgrinko/orgs","repos_url":"https://api.github.com/users/mgrinko/repos","events_url":"https://api.github.com/users/mgrinko/events{/privacy}","received_events_url":"https://api.github.com/users/mgrinko/received_events","type":"User","site_admin":false},"repo":{"id":49772218,"name":"oleg_pomazkov","full_name":"mgrinko/oleg_pomazkov","owner":{"login":"mgrinko","id":3237782,"avatar_url":"https://avatars.githubusercontent.com/u/3237782?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrinko","html_url":"https://github.com/mgrinko","followers_url":"https://api.github.com/users/mgrinko/followers","following_url":"https://api.github.com/users/mgrinko/following{/other_user}","gists_url":"https://api.github.com/users/mgrinko/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrinko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrinko/subscriptions","organizations_url":"https://api.github.com/users/mgrinko/orgs","repos_url":"https://api.github.com/users/mgrinko/repos","events_url":"https://api.github.com/users/mgrinko/events{/privacy}","received_events_url":"https://api.github.com/users/mgrinko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mgrinko/oleg_pomazkov","description":"","fork":false,"url":"https://api.github.com/repos/mgrinko/oleg_pomazkov","forks_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/forks","keys_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/teams","hooks_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/hooks","issue_events_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/events{/number}","events_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/events","assignees_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/assignees{/user}","branches_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/branches{/branch}","tags_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/tags","blobs_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/refs{/sha}","trees_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/statuses/{sha}","languages_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/languages","stargazers_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/stargazers","contributors_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/contributors","subscribers_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/subscribers","subscription_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/subscription","commits_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/commits{/sha}","git_commits_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/commits{/sha}","comments_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/comments{/number}","issue_comment_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/comments{/number}","contents_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/contents/{+path}","compare_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/merges","archive_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/downloads","issues_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues{/number}","pulls_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls{/number}","milestones_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/milestones{/number}","notifications_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/labels{/name}","releases_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/releases{/id}","created_at":"2016-01-16T12:19:40Z","updated_at":"2016-01-16T12:28:21Z","pushed_at":"2016-01-16T12:30:43Z","git_url":"git://github.com/mgrinko/oleg_pomazkov.git","ssh_url":"git@github.com:mgrinko/oleg_pomazkov.git","clone_url":"https://github.com/mgrinko/oleg_pomazkov.git","svn_url":"https://github.com/mgrinko/oleg_pomazkov","homepage":null,"size":48,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"mgrinko:master","ref":"master","sha":"6ff6c8fcb71d79d38e0e8455c72ee2e6e947cbeb","user":{"login":"mgrinko","id":3237782,"avatar_url":"https://avatars.githubusercontent.com/u/3237782?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrinko","html_url":"https://github.com/mgrinko","followers_url":"https://api.github.com/users/mgrinko/followers","following_url":"https://api.github.com/users/mgrinko/following{/other_user}","gists_url":"https://api.github.com/users/mgrinko/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrinko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrinko/subscriptions","organizations_url":"https://api.github.com/users/mgrinko/orgs","repos_url":"https://api.github.com/users/mgrinko/repos","events_url":"https://api.github.com/users/mgrinko/events{/privacy}","received_events_url":"https://api.github.com/users/mgrinko/received_events","type":"User","site_admin":false},"repo":{"id":49772218,"name":"oleg_pomazkov","full_name":"mgrinko/oleg_pomazkov","owner":{"login":"mgrinko","id":3237782,"avatar_url":"https://avatars.githubusercontent.com/u/3237782?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrinko","html_url":"https://github.com/mgrinko","followers_url":"https://api.github.com/users/mgrinko/followers","following_url":"https://api.github.com/users/mgrinko/following{/other_user}","gists_url":"https://api.github.com/users/mgrinko/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrinko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrinko/subscriptions","organizations_url":"https://api.github.com/users/mgrinko/orgs","repos_url":"https://api.github.com/users/mgrinko/repos","events_url":"https://api.github.com/users/mgrinko/events{/privacy}","received_events_url":"https://api.github.com/users/mgrinko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mgrinko/oleg_pomazkov","description":"","fork":false,"url":"https://api.github.com/repos/mgrinko/oleg_pomazkov","forks_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/forks","keys_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/teams","hooks_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/hooks","issue_events_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/events{/number}","events_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/events","assignees_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/assignees{/user}","branches_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/branches{/branch}","tags_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/tags","blobs_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/refs{/sha}","trees_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/statuses/{sha}","languages_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/languages","stargazers_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/stargazers","contributors_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/contributors","subscribers_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/subscribers","subscription_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/subscription","commits_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/commits{/sha}","git_commits_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/git/commits{/sha}","comments_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/comments{/number}","issue_comment_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/comments{/number}","contents_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/contents/{+path}","compare_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/merges","archive_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/downloads","issues_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues{/number}","pulls_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls{/number}","milestones_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/milestones{/number}","notifications_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/labels{/name}","releases_url":"https://api.github.com/repos/mgrinko/oleg_pomazkov/releases{/id}","created_at":"2016-01-16T12:19:40Z","updated_at":"2016-01-16T12:28:21Z","pushed_at":"2016-01-16T12:30:43Z","git_url":"git://github.com/mgrinko/oleg_pomazkov.git","ssh_url":"git@github.com:mgrinko/oleg_pomazkov.git","clone_url":"https://github.com/mgrinko/oleg_pomazkov.git","svn_url":"https://github.com/mgrinko/oleg_pomazkov","homepage":null,"size":48,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1"},"html":{"href":"https://github.com/mgrinko/oleg_pomazkov/pull/1"},"issue":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/1"},"comments":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/mgrinko/oleg_pomazkov/statuses/5958fb6ad24b1080b67f2456008d4d988aa328fb"}}}}