Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from Olya Levitskaya #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dvpj7wd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added knopp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions lib/jquery-1.7.1.min.js

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows" />
<title>Calc</title>

<link href="style.css" rel="stylesheet" type="text/css" />

<script src="lib/jquery-1.7.1.min.js" type="text/javascript" ></script>
<script src="script.js"></script>

</head>


<body>
<div id="message"> ������! � �����������, ���������� ���� ��������� =)</div>

<table border=5 bordercolor=4e5e6f vspace=10 cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" id='round'><p><div id="expression"></div><div id="result"></div></p></td>
<td id="rou"><div id="del" >C</div></td>

</tr>
<tr>
<td id="rou"><div id="i7">7</div></td>
<td id="rou"><div id="i8">8</div></td>
<td id="rou"><div id="i9">9</div></td>
<td id="rou"><div id="dev">/</div></td>
</tr>
<tr>
<td id="rou"><div id="i4">4</div></td>
<td id="rou"><div id="i5">5</div></td>
<td id="rou"><div id="i6">6</div></td>
<td id="rou"><div id="mul">*</div></td>
</tr>
<tr>
<td id="rou"><div id="i1">1</div></td>
<td id="rou"><div id="i2">2</div></td>
<td id="rou"><div id="i3">3</div></td>
<td id="rou"><div id="sub">-</div></td>
</tr>
<tr>
<td id="rou"><div id="i0">0</div></td>
<td colspan="2" id="rou"><div id="calc">=</div></td>
<td id="rou"><div id="sum">+</div></td>
</tr>
</table>
</body>
72 changes: 72 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
var f; //���� ��������� ���������
var x; //�������� ������
var a1; //������ �������
var a2; //������ �������
var op; //��������
var eq; //���� �������� "="
var symbl1; //���������� ������ � ������ ��������
var symbl2; //���������� ������ �� ������ ��������
var res=0;
var mes='������! � �����������, ���������� ���� ��������� =)';
$(document).ready(function() {
$('div').click(function() {

x = $(this).attr('id'); //����������� ������ �������� ���� �������������
if (x=="i0") x=0;
if (x=="i1") x=1;
if (x=="i2") x=2;
if (x=="i3") x=3;
if (x=="i4") x=4;
if (x=="i5") x=5;
if (x=="i6") x=6;
if (x=="i7") x=7;
if (x=="i8") x=8;
if (x=="i9") x=9;
if (x=="sum") x=10;
if (x=="sub") x=11;
if (x=="mul") x=12;
if (x=="dev") x=13;
if (x=="del") x=14;
if (x=="calc") x=15;


if (!isFinite(f)){ //���������, ��� ��� �� ��������� ��������, ������ �� ��� ������ �����

if(!isFinite(a1)) {
if (x==14){document.getElementById("expression").innerHTML=""; document.getElementById("result").innerHTML=""; document.getElementById("message").innerHTML=mes;}
if (x<10){a1=x; symbl1=1; eq=0; document.getElementById("expression").innerHTML=a1; document.getElementById("result").innerHTML=""; }
}

else {

if (x<10 && symbl1<8) {a1=a1*10+x; symbl1++; eq=0; document.getElementById("expression").innerHTML=a1;}
else{
if (x==10) {f=1; op=x; eq=0; document.getElementById("expression").innerHTML+="+";}
if (x==11) {f=1; op=x; eq=0; document.getElementById("expression").innerHTML+="-";}
if (x==12) {f=1; op=x; eq=0; document.getElementById("expression").innerHTML+="*";}
if (x==13) {f=1; op=x; eq=0; document.getElementById("expression").innerHTML+="/";}
if (x==14) {f=NaN; a1=NaN; eq=0; document.getElementById("expression").innerHTML=""; document.getElementById("message").innerHTML=mes;}
}
}
}

else{ //��� ��� �������� ��� ���, ������ ����� ������ �����
if (x>10 && x!=15 && eq!=1) {document.getElementById("message").innerHTML="Sorry! ������ ���� ������ ������ �����"}
if(!isFinite(a2) && (x<10)) {a2=x; symbl2=1; eq=1; document.getElementById("expression").innerHTML+=a2; document.getElementById("message").innerHTML="����� ������ �����, ��� ="}
else {
if (x<10 && symbl2<8) {a2=a2*10+x; eq=1; symbl2++; document.getElementById("expression").innerHTML+=x;}
if (x==14) {f=NaN; a1=NaN; a2=NaN; eq=0; document.getElementById("expression").innerHTML=""; document.getElementById("message").innerHTML=mes;}
}
}


if(x==15 && eq==1){ //�������������� �������� �� ��, ��� "=" ������ ����� ������� ��������
if (op==10) {f=NaN; res=a1+a2; a1=NaN; a2=NaN; eq=0;}
if (op==11) {f=NaN; res=a1-a2; a1=NaN; a2=NaN; eq=0;}
if (op==12) {f=NaN; res=a1*a2; a1=NaN; a2=NaN; eq=0;}
if (op==13) {f=NaN; res=a1/a2; a1=NaN; a2=NaN; eq=0;}
document.getElementById("result").innerHTML='='+res;
document.getElementById("message").innerHTML="������ �������? =)"
}
});
});
107 changes: 107 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
body{
background: url('wallpaper.png');
height: 100%;
width: 100%;
}

table{
position: absolute;
top: 30px;
height: 500px;
background: #4e5e6f;
border-color: #4e5e6f;
margin-left: 25%;
text-align: right;
}

#message{
position: absolute;
left: 90px;
top: 180px;
width: 200px;
height: auto;
font: 25pt bolt;
padding: 10px;
background: url("dvpj7wd.png");
word-wrap: break-word;
border: 2px ridge #4e5e6f;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
}



#round {
background-color: white;
border: 2px ridge #4e5e6f;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
}

#i0, #i1, #i2, #i3, #i4, #i5, #i6, #i7, #i8, #i9, #del, #dev, #mul, #sub, #sum, #calc{
width: 150px;
height: 100%;
background: url("text_bg2.jpg");
display: table;
text-align: center;
vertical-align: center;
font: 40pt bolt;
padding-top: 15px;
}
#del{
padding-top: 35px;
}

#calc{
width: 302px;
height: 100%;
background: url("text_bg2.jpg");
background-repeat: repeat-x;
display: table;
text-align: center;
vertical-align: center;
font: 50pt bolt;

}

#i0, #i1, #i2, #i3, #i4, #i5, #i6, #i7, #i8, #i9, #del, #dev, #mul, #sub, #sum, #calc:hover{
cursor: pointer;
}


#expression{
float:left;
position: relative;
top: -25px;
height: 35px;
width: 100%;
max-width: 500px;
display: inline;
text-align: right;
vertical-align: bottom;
font: 25pt bolt;
padding-top: 20px;
}
#result{
float:left;
position:relate;
top:-15px;
height: 35px;
width:100%;
max-width: 450px;
display: inline;
text-align: right;
vertical-align: center;
font: 35pt bolt;
padding-bottom: 20px;
}

#rou{
border: 1px solid #434343;
padding: 2px;
background: url("text_bg2.jpg");
-moz-border-radius: 10px;
-webkit-border-radius: 10px;


}
Binary file added text_bg2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wallpaper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.