-
Notifications
You must be signed in to change notification settings - Fork 0
/
java.html
153 lines (132 loc) · 3.97 KB
/
java.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
</script>
<style>
@import url("http://fonts.googleapis.com/css?family=Open+Sans:regular,semibold,italic,italicsemibold|Droid+Sans+Mono");
body{background:#fafafa;font-size:20px;font-family:Droid Sans Mono;}
#main{width:800px;margin:0 auto;}
#main div{width:380px;position:relative;float: left;}
.wrap{width:400px;padding: 10px;
background: #fff;}
.wrap>div{padding-top:20px;}
#code{background:#fff;height:100px;}
#var{background:#fff;height:390px;border-top:1px solid #ccc;}
#res{background:#fff;height:500px;float:left;border-left:1px solid #ccc;width:379px !important;}
#code span{display:block;width:100%;}
#code span p,#var font{border-radius:5px;}
#code span .true:before,#code span .false:before{position:absolute;font-size:14px;margin-top:-20px;color:#ccc;font-weight:bold;}
#code span .true:before{content:'TRUE';}
#code span .false:before{content:'FALSE';}
#code span p,#var font {display:inline; -webkit-transition: background .25s ease-in-out;-moz-transition: background .25s ease-in-out;-o-transition: background .25s ease-in-out;transition: background .25s ease-in-out;}
.do{background:rgba(52, 152, 219,0.5);}
.check{background:rgba(52, 152, 219,0.5);}
.true{background:rgba(46, 204, 113,0.5);position:relative;}
.false{background:rgba(231, 76, 60,0.5);}
.output{display:block;width:100%;}
#res:before,#code:before,#var:before{
color: #ccc;
right: 10px;
position: absolute;
top: 5px;
font-size: 19px;
}
#res:before{content: 'OUTPUT';
}
#code:before{content: 'CODE';}
#var:before{content: 'VARIABLE';}
</style>
<script>
$(function(){
var i=1;
var frst=true;
var round=0;
var runcode=setInterval(function(){run()}, 500);
function run(){
console.log(i);
if(i==1){
if(frst){
frst=false;
$('.inti').addClass('do');
$('#var .i font').text(i);
}else if($('.inti').hasClass('do')){
$('.cond').addClass('check');
$('.inti').removeClass('do');
}else if($('.cond').hasClass('check')){
if(i<10){
i++;
$('.cond').addClass('true').removeClass('check');
}else{
$('.cond').addClass('false').removeClass('check');
clearInterval(runcode);
}
}else if($('.cond').hasClass('true')){
$('.code').addClass('do');
$('#res').append('<span class="output">Hello</span>');
$('.cond').removeClass('true');
}
}else{
if($('.code').hasClass('do')){
$('.inc').addClass('do');
$('.code,#var .r font').removeClass('do');
$('#var .i font').text(i).addClass('do');
}else if($('.inc').hasClass('do')){
$('.cond').addClass('check');
$('.inc,#var .i font').removeClass('do');
}else if($('.cond').hasClass('check')){
if(i<10){
i++;
$('.cond').addClass('true').removeClass('check');
frst=false;
}else{
$('.cond').addClass('false').removeClass('check');
clearInterval(runcode);
$('button').show();
}
}else if($('.cond').hasClass('true')){
$('.code').addClass('do');
round++;
$('#var .r font').text(round).addClass('do');
$('#res').append('<span class="output">Hello</span>');
$('.cond').removeClass('true');
}
}
}
$('button').on('click',function(){
i=1;
frst=true;
round=0;
$('#res').html('');
$('#var .r font,#var .i font').text(0);
$('.cond').removeClass('false');
runcode=setInterval(function(){run()}, 800);
$('button').hide();
});
});
</script
</head>
<body>
<div id="main">
<div class="wrap">
<div id="code">
<span>for(<p class="inti">int i=1</p>;<p class="cond">i<10</p>;<p class="inc">i++</p>){</span>
<span> <p class="code">System.out.println("hello");</p></span>
<span>}</span>
</div>
<div id="var">
<span class="r">Number of round = <font>0</font></span><br>
<span class="i">Current i = <font>0</font></span><br>
<button type="button" style="display:none">Run Again</button>
</div>
</div>
<div class="wrap">
<div id="res">
<span></span>
<span></span>
<span></span>
</div>
</div>
</div>
</body>
</html>