-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUžduotys.html
162 lines (125 loc) · 3.82 KB
/
Užduotys.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
154
155
156
157
158
159
160
161
162
<html>
<title>Užduotys</title>
<head>
<script src="jquery-2.1.1.min.js"></script>
<script>
var a = 0;
var time;
var myTimer=[];
function clik(e) {
if ($("#"+e).css("background-color") == "rgb(0, 0, 0)") $("#"+e).css("background", "#FFF");
else $("#"+e).css("background", "#000000");
};
$(function(){
$('#addfile').click(function(e){
e.preventDefault();
$('#files').click();}
);
});
window.onload = function() {
if (window.File && window.FileList && window.FileReader) {
var filesInput = document.getElementById("files");
filesInput.addEventListener("change", function(event) {
var files = event.target.files; //FileList object
for (var i = 0; i < files.length; i++) {
var file = files[i];
//Only plain text
if (!file.type.match('plain')) continue;
var picReader = new FileReader();
picReader.addEventListener("load", function(event) {
var textFile = event.target;
var data = textFile.result.split("\n");
for (i=0;i<data.length;i++) {
var uzd = data[i].split("|");
$("#bod").append("<li><div id='" + a + "' contenteditable>"+uzd[0]+"<div style='display:none' id='a" + a + "'>Ats.:"+uzd[1]+"</div></div><div class='barb' id='b" + a + "'> <div class='bar' id='t" + a + "'></div> </div><button onClick='clik(" + a + ")'>h</button><button onClick='ats(" + a + ")'>a</button><button onClick='del(" + a + ")'>x</button><button onClick='time(" + a + ")'>+1</button></li>");
$("#"+a).css("background", "#000");
a++;
};
});
//Read the text file
picReader.readAsText(file);
}
});
}
else {
console.log("Your browser does not support File API");
};
};
function add() {
$("#bod").append("<li><div style='display:inline;' id='" + a + "' contenteditable></div> <button onClick='clik(" + a + ")'>h</button><button onClick='del(" + a + ")'>x</button></li>");
a++;
};
function del(e) {
$("#"+e).parent().fadeOut();
};
function ats(e) {
$("#a"+e).toggle(500);
};
function time(e){
if (time[e] > 0) {
time[e]=time[e]+120;
$("#b"+e).css('width',$("#b"+e).width()+120);
}
else {
time[e] = 120;
$("#b"+e).css('width',120).fadeIn(10);
myTimer[e]=setInterval(function(){
time[e]=time[e]-1;
$("#t"+e).css('width',time[e]+"px");
testt(e);
},500);
};
};
function testt(e) {
if(time[e]<=0) {
clearInterval(myTimer[e]);
ats(e);
$("#b"+e).fadeout(10);
};
}
function fsz() {
$("li").css('font-size',$("#fontSize").val()+"px");
$("li").css('margin-left',$("#fontSize").val()+"px");
};
</script>
<style>
button {
width:30px;
height:30px;
border-radius:15px;
padding:0px;
margin:5px;
font-size:10px;
}
ol > li {
margin-left:30px;
font-size:30px;
}
li > div {
transition: background 1s;
border-radius:3px;
}
#fontSize{
height:10px;
}
.bar {
width:0px;
background:#95e203;
height:6px;
transition: width 0.5s;
}
.barb {
border:solid 1px;
width:0px;
display:none;
}
</style>
</head>
<body>
<ol id="bod"> </ol>
<button onClick="add()">+</button>
<button id="addfile">O</button>
<input type="file" id="files" style="display:none"></input>
+<input type="range" id="fontSize" oninput="fsz()" value="30" min="30" max="100"></input>-
</body>
</html>