-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
94 lines (79 loc) · 3.28 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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- This page was generated via prompting OpenAI's ChatGPT (GPT-4) on 2023-09-30. -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Population Dynamics</title>
<style>
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<h2>Population Dynamics</h2>
<label for="stAges">Number of Stages:</label>
<input type="number" id="stAges">
<button onclick="initializeMatrix()">Initialize Matrix</button>
<br><br>
<label for="fecundity">Fecundity (comma-separated values):</label>
<input type="text" id="fecundity">
<button onclick="addFecundity()">Add Fecundity</button>
<br><br>
<label for="survival">Survival (comma-separated values):</label>
<input type="text" id="survival">
<button onclick="addSurvival()">Add Survival</button>
<br><br>
<label for="recurrence">Recurrence (comma-separated values):</label>
<input type="text" id="recurrence">
<button onclick="addRecurrence()">Add Recurrence</button>
<br><br>
<label for="population">Population (comma-separated values):</label>
<input type="text" id="population">
<button onclick="setPopulation()">Set Population</button>
<br><br>
<button onclick="stepForward()">Step Forward</button>
<br><br>
<div id="output"></div>
</div>
<script src="matpopdyn.js"></script>
<script>
let matrix;
function initializeMatrix() {
const stAges = parseInt(document.getElementById('stAges').value);
matrix = new LMatrix(stAges);
document.getElementById('output').innerText = `Matrix initialized with ${stAges} stages.`;
}
function addFecundity() {
const fecundity = document.getElementById('fecundity').value.split(',').map(Number);
matrix.LM_AddFecundity(fecundity);
document.getElementById('output').innerText = `Fecundity added: ${fecundity}`;
}
function addSurvival() {
const survival = document.getElementById('survival').value.split(',').map(Number);
matrix.LM_AddSurvival(survival);
document.getElementById('output').innerText = `Survival added: ${survival}`;
}
function addRecurrence() {
const recurrence = document.getElementById('recurrence').value.split(',').map(Number);
matrix.LM_AddRecurrence(recurrence);
document.getElementById('output').innerText = `Recurrence added: ${recurrence}`;
}
function setPopulation() {
const population = document.getElementById('population').value.split(',').map(Number);
matrix.LM_SetPopulation(population);
document.getElementById('output').innerText = `Population set: ${population}`;
}
function stepForward() {
matrix.LM_StepForward();
document.getElementById('output').innerText = `Population after step: ${matrix.popvec}`;
}
</script>
</body>
</html>