-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
115 lines (105 loc) · 4.14 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<title>Liverstock</title>
</head>
<style>
.grd a{
width: 100%;
margin: 10px 15px;
}
</style>
<body class="bg-white">
<h1 class="text-3xl text-center text-orange-600 my-3 font-bold">
Liverstock Management Software
</h1>
<div class="grd w-full md:w-4/6 md:mx-auto mx-5 flex mt-10 md:mt-20 md:flex-row flex-col justify-around">
<a href="./pages/cattles.html">
<div class="w-54 md:w-full flex flex-col justify-center p-5 mx-2 h-28 bg-blue-100 shadow-sm">
<h4 class="text-3xl" id="cattlesLabel">01</h4>
<h6>Cattles</h6>
</div>
</a>
<a href="./pages/chickens.html">
<div class="w-54 md:w-full flex flex-col justify-center p-5 mx-2 h-28 bg-green-100 shadow-sm">
<h4 class="text-3xl" id="chickenLabel">11</h4>
<h6>Chicken</h6>
</div>
</a>
<a href="./pages/sheeps.html">
<div class="w-54 md:w-full flex flex-col justify-center p-5 mx-2 h-28 bg-orange-100 shadow-sm">
<h4 class="text-3xl" id="sheepLabel">122</h4>
<h6>Sheeps</h6>
</div>
</a>
</div>
<div id="piechart" class=" flex items-center justify-center"></div>
<footer class="absolute w-full bottom-0 left-0">
<div class="w-full py-2 bg-gray-100">
<marquee>
<h4>Liverstock Management System was built as my final year project at Alqalam University Katsina</h4>
</marquee>
</div>
</footer>
<script>
let chickensD = {
total: 1247,
sold: 533,
died: 40
}
let sheepsD = {
total: 45,
sold: 13,
died: 0
}
let cattlesD = {
total: 32,
sold: 4,
died: 0
}
window.onload = ()=>{
var cattles = JSON.parse(localStorage.getItem("@cattles"))
if(cattles === null){
localStorage.setItem("@chickens", JSON.stringify(chickensD))
localStorage.setItem("@sheeps", JSON.stringify(sheepsD))
localStorage.setItem("@cattles", JSON.stringify(cattlesD))
}else{
console.log("there is data already")
}
document.getElementById("cattlesLabel").innerText = cattles.total
var chickens = JSON.parse(localStorage.getItem("@chickens"))
document.getElementById("chickenLabel").innerText = chickens.total
var sheeps = JSON.parse(localStorage.getItem("@sheeps"))
document.getElementById("sheepLabel").innerText = sheeps.total
// localStorage.setItem("@chickens", JSON.stringify(chickens))
}
</script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load google charts
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
var chickenStat = JSON.parse(localStorage.getItem("@chickens"))
var sheepStat = JSON.parse(localStorage.getItem("@sheeps"))
var cattleStat = JSON.parse(localStorage.getItem("@cattles"))
// Draw the chart and set the chart values
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Animals', 'Total'],
['Sheeps', sheepStat.total],
['Cattles', cattleStat.total],
['Chickens', chickenStat.total],
]);
// Optional; add a title and set the width and height of the chart
var options = { 'title': 'My Farm Stats', 'width': 550, 'height': 400 };
// Display the chart inside the <div> element with id="piechart"
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</body>
</html>