-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathKeepVariableValue.js
More file actions
27 lines (26 loc) · 905 Bytes
/
KeepVariableValue.js
File metadata and controls
27 lines (26 loc) · 905 Bytes
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
function passar(img) {
passar.contador = passar.contador || 0;
if (passar.contador == 0) {
var confirma = confirm("Tem certeza que deseja aumentar a imagem?");
if (confirma && passar.contador == 0) {
passar.contador++;
img.height *= 2;
img.width *= 2;
} else if (confirma && passar.contador == 1) {
window.alert("Não é possível aumentar mais");
}
} else {
var confirma = confirm("Tem certeza que deseja diminuir a imagem?");
if (confirma && passar.contador == 1) {
passar.contador--;
img.height /= 2;
img.width /= 2;
} else if (confirma && passar.contador == 0) {
window.alert("Não é possível diminuir mais");
}
}
}
var img = {height : 10, width : 10};
passar(img);
passar(img);
//https://pt.stackoverflow.com/q/117809/101