hiaripc commited on
Commit ·
a09e8a3
1
Parent(s): e1f8d60
ajusting slider
Browse files- index.html +75 -1
- style.css +5 -0
index.html
CHANGED
|
@@ -122,7 +122,7 @@ Load model
|
|
| 122 |
|
| 123 |
</div>
|
| 124 |
|
| 125 |
-
<div>
|
| 126 |
<label>
|
| 127 |
Input Tokens (<i>n</i><sub>in</sub>):
|
| 128 |
<span id="ninValue">64</span>
|
|
@@ -136,10 +136,84 @@ Load model
|
|
| 136 |
step="1"
|
| 137 |
value="64"
|
| 138 |
oninput="ninValue.textContent = this.value; draw();">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
</div>
|
| 140 |
|
| 141 |
<div id="plot"></div>
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
<script src="app.js"></script>
|
| 145 |
|
|
|
|
| 122 |
|
| 123 |
</div>
|
| 124 |
|
| 125 |
+
<!-- <div>
|
| 126 |
<label>
|
| 127 |
Input Tokens (<i>n</i><sub>in</sub>):
|
| 128 |
<span id="ninValue">64</span>
|
|
|
|
| 136 |
step="1"
|
| 137 |
value="64"
|
| 138 |
oninput="ninValue.textContent = this.value; draw();">
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<div id="plot"></div> -->
|
| 142 |
+
|
| 143 |
+
<div id="ninWrapper">
|
| 144 |
+
<label>
|
| 145 |
+
Input Tokens (<i>n</i><sub>in</sub>):
|
| 146 |
+
<span id="ninValue">64</span>
|
| 147 |
+
</label>
|
| 148 |
+
|
| 149 |
+
<!-- Visible slider: linear in EXPONENT space (2^0 to 2^12 = 1 to 4096) -->
|
| 150 |
+
<input
|
| 151 |
+
id="ninSlider"
|
| 152 |
+
type="range"
|
| 153 |
+
min="0"
|
| 154 |
+
max="12"
|
| 155 |
+
step="0.01"
|
| 156 |
+
value="6"
|
| 157 |
+
list="ninTicks"
|
| 158 |
+
oninput="updateNin(this.value)">
|
| 159 |
+
|
| 160 |
+
<!-- Tick marks at each power of two, matching the plot's xaxis.tickvals -->
|
| 161 |
+
<datalist id="ninTicks">
|
| 162 |
+
<option value="0"></option>
|
| 163 |
+
<option value="1"></option>
|
| 164 |
+
<option value="2"></option>
|
| 165 |
+
<option value="3"></option>
|
| 166 |
+
<option value="4"></option>
|
| 167 |
+
<option value="5"></option>
|
| 168 |
+
<option value="6"></option>
|
| 169 |
+
<option value="7"></option>
|
| 170 |
+
<option value="8"></option>
|
| 171 |
+
<option value="9"></option>
|
| 172 |
+
<option value="10"></option>
|
| 173 |
+
<option value="11"></option>
|
| 174 |
+
<option value="12"></option>
|
| 175 |
+
</datalist>
|
| 176 |
+
|
| 177 |
+
<!-- Hidden input: holds the ACTUAL token count, exactly what app.js reads -->
|
| 178 |
+
<input id="nin" type="hidden" value="64">
|
| 179 |
</div>
|
| 180 |
|
| 181 |
<div id="plot"></div>
|
| 182 |
|
| 183 |
+
<script src="app.js"></script>
|
| 184 |
+
|
| 185 |
+
<script>
|
| 186 |
+
function updateNin(exponent) {
|
| 187 |
+
const value = Math.round(Math.pow(2, parseFloat(exponent)));
|
| 188 |
+
const clamped = Math.min(4096, Math.max(1, value));
|
| 189 |
+
|
| 190 |
+
document.getElementById('nin').value = clamped;
|
| 191 |
+
document.getElementById('ninValue').textContent = clamped;
|
| 192 |
+
|
| 193 |
+
draw();
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Keep the slider's on-screen width exactly matched to the rendered plot width.
|
| 197 |
+
function syncSliderWidth() {
|
| 198 |
+
const plotDiv = document.getElementById('plot');
|
| 199 |
+
const slider = document.getElementById('ninSlider');
|
| 200 |
+
if (plotDiv && slider) {
|
| 201 |
+
const plotWidth = plotDiv.getBoundingClientRect().width;
|
| 202 |
+
if (plotWidth > 0) {
|
| 203 |
+
slider.style.width = plotWidth + 'px';
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
window.addEventListener('resize', syncSliderWidth);
|
| 209 |
+
window.addEventListener('load', syncSliderWidth);
|
| 210 |
+
|
| 211 |
+
if (window.ResizeObserver) {
|
| 212 |
+
const plotEl = document.getElementById('plot');
|
| 213 |
+
if (plotEl) new ResizeObserver(syncSliderWidth).observe(plotEl);
|
| 214 |
+
}
|
| 215 |
+
</script>
|
| 216 |
+
|
| 217 |
|
| 218 |
<script src="app.js"></script>
|
| 219 |
|
style.css
CHANGED
|
@@ -15,6 +15,11 @@ p {
|
|
| 15 |
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
.card {
|
| 19 |
max-width: 620px;
|
| 20 |
margin: 0 auto;
|
|
|
|
| 15 |
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
+
#ninSlider {
|
| 19 |
+
width: 100%;
|
| 20 |
+
box-sizing: border-box;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
.card {
|
| 24 |
max-width: 620px;
|
| 25 |
margin: 0 auto;
|