-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombos.php
More file actions
146 lines (139 loc) · 5.34 KB
/
combos.php
File metadata and controls
146 lines (139 loc) · 5.34 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Carbon Sequestration | CREEC</title>
<link rel="stylesheet" href="/portfolio/creec/assets/styles/main.css" />
<script src="/portfolio/creec/assets/scripts/jquery-3.2.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.7.12/xlsx.core.min.js"></script>
<meta charset="utf-8" />
<meta content="" />
<?php
date_default_timezone_set('America/Los_Angeles');
ini_set('display_errors',1);
error_reporting(-1);
?>
<script src="/portfolio/creec/assets/scripts/combinatorics.js"></script>
<script>
$(document).ready(function() {
// No Script Override
document.getElementById('content').style.display = 'block';
var letters = ['A', 'B', 'C', 'D', 'E', 'F']
var minvals = [0, 1, 5, 25, 50, 75];
var maxvals = [1, 5, 25, 50, 75, 100];
var size = 7;
var combos = [];
var data = [];
function rangeSet(size, letters, minval, maxval) {
addLetter([], 0, 0);
function addLetter(set, min, max) {
for (var lt = 0; lt < letters.length; lt++) {
if (min + minval[lt] < 100) {
var set_copy = set.concat([letters[lt]]);
var min_copy = min + minval[lt];
var max_copy = max + maxval[lt];
if (set_copy.length == size) {
if (max_copy >= 100) {
combos.push(set_copy);
}
}
else addLetter(set_copy, min_copy, max_copy);
}
}
}
}
rangeSet(size, letters, minvals, maxvals);
$('#log').html('# of Possible Combinations: ' + combos.length);
$(document).on('click', '#excel', function() {
alasql('SELECT * INTO XLSX('+path+') FROM ?', [data]);
});
$.each(combos, function(index, set) {
var row = $('<tr>', {
'class': 'data-row'
});
var cell0 = $('<td>', {
text: index
});
var cell1 = $('<td>', {
text: set[0]
});
var cell2 = $('<td>', {
text: set[1]
});
var cell3 = $('<td>', {
text: set[2]
});
var cell4 = $('<td>', {
text: set[3]
});
var cell5 = $('<td>', {
text: set[4]
});
var cell6 = $('<td>', {
text: set[5]
});
var cell7 = $('<td>', {
text: set[6]
});
$(row)
.appendTo('#combos tbody')
.append(cell0)
.append(cell1)
.append(cell2)
.append(cell3)
.append(cell4)
.append(cell5)
.append(cell6)
.append(cell7);
});
window.exportExcel = function exportExcel() {
alasql('SELECT * INTO XLSX("Permutations.xlsx",{headers:true}) FROM HTML("#combos",{headers:true})');
}
});
</script>
<style>
table {
border-collapse: collapse;
margin: auto;
}
tr {
border-bottom: 1px solid black;
border-top: 1px solid black;
}
td, th {
border-right: 1px solid black;
border-left: 1px solid black;
padding: 10px 20px;
}
</style>
</head>
<body>
<?php include($_SERVER['DOCUMENT_ROOT'].'/portfolio/creec/includes/header.php'); ?>
<?php
?>
<div id="content" style="display: none;">
<button id="excel" onclick="window.exportExcel()">Download Excel</button>
<br />
<br />
<p id="log"></p>
<br />
<table id="combos">
<thead>
<tr>
<th>ID</th>
<th>Willow</th>
<th>Cottonwood</th>
<th>Oak</th>
<th>Shrub</th>
<th>Alwal</th>
<th>ABS</th>
<th>Other</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="clear"></div>
<noscript>Javascript Must be enabled for this site to function</noscript>
</body>
</html>