-
Notifications
You must be signed in to change notification settings - Fork 0
/
bd.js
70 lines (60 loc) · 1.81 KB
/
bd.js
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
$(function(){
var i = Number(localStorage.getItem('pizza-contador')) + 1;
var j, k, orderList;
var $pizza = $("#NomePizza");
var $pizzaList = $("#pizzas");
var order = [];
orderList = localStorage.getItem('pizza-cadastro');
if(!orderList){
$("#semErros").css("display","block");
}
// Carregar Lista de Pizzas
orderList = orderList ? orderList.split(',') : [];
for( j = 0, k = orderList.length; j < k; j++) {
$pizzaList.append(
"<li id='" + orderList[j] + "'>"
+ "<a class='editable' data-split-theme='c'>"
+ localStorage.getItem(orderList[j])
+ "</a> <a href='#' class='close' data-icon='delete' data-theme='c'>X</a></li>"
);
}
// Incluir Pizzas
$("#IncluirPizzas").live("tap", function() {
if($pizza.val() != ""){
localStorage.setItem("pizza-"+i, $pizza.val());
localStorage.setItem("pizza-contador",i);
$("#semErros").css("display","none");
$pizzaList.append(
"<li id='pizza-" + i + "'>"
+ "<a class='editable' data-split-theme='c'>"
+ localStorage.getItem("pizza-" + i)
+ " </a><a href='#' data-icon='delete' class='close' data-theme='c'>x</a></li>"
);
$.mobile.changePage("#ListaPizzas", { transition: "slidedown"});
listaPizzas();
$pizza.val("");
i++
}
return false;
});
// Excluir Pizzas
$("#pizzas li a.close").live("tap", function() {
//alert($(this).parent().attr("id"));
localStorage.removeItem($(this).parent().attr("id"));
$(this).parent().slideUp('normal', function(){
$(this).remove();
listaPizzas();
});
return false;
});
function listaPizzas(){
var $pizzaLi = $("#pizzas li");
order.length = 0;
$pizzaLi.each(function(){
var id = $(this).attr("id");
order.push(id);
});
$('ul').listview('refresh');
localStorage.setItem("pizza-cadastro", order.join(","));
}
});