Skip to content

Commit 3e12ed8

Browse files
committed
Deploying to gh-pages from @ a16b32f 🚀
0 parents  commit 3e12ed8

14 files changed

+144988
-0
lines changed

copy-button.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// JavaScript for copy functionality
2+
document.addEventListener('click', function(e) {
3+
if (e.target.matches('.copy-button')) {
4+
const button = e.target;
5+
const targetId = button.getAttribute('data-target');
6+
const codeText = document.getElementById(targetId).textContent;
7+
8+
navigator.clipboard.writeText(codeText).then(() => {
9+
button.textContent = "Copied!";
10+
button.disabled = true;
11+
12+
setTimeout(() => {
13+
button.textContent = "Copy";
14+
button.disabled = false;
15+
}, 3000); // Revert after 3 seconds
16+
});
17+
}
18+
});

disable-wasm-option.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
document.addEventListener('DOMContentLoaded', async function() {
2+
const wasmCheckbox = document.getElementById('wasm');
3+
const extraWasmLabel = document.getElementById('extraWasmLabel');
4+
wasmCheckbox.disabled = true; // Initially disable the checkbox
5+
6+
try {
7+
const features = {
8+
tailCall: await wasmFeatureDetect.tailCall(),
9+
gc: await wasmFeatureDetect.gc(),
10+
exceptions: await wasmFeatureDetect.exceptions()
11+
};
12+
13+
const unsupportedFeatures = Object.entries(features)
14+
.filter(([feature, supported]) => !supported)
15+
.map(([feature]) => feature);
16+
17+
if (unsupportedFeatures.length === 0) {
18+
wasmCheckbox.disabled = false; // Re-enable the checkbox if all features are supported
19+
} else {
20+
wasmCheckbox.checked = false;
21+
22+
let featureText = unsupportedFeatures.join(', ');
23+
let firefoxText = unsupportedFeatures.map(feature => {
24+
if (feature === 'tailCall') return 'javascript.options.wasm_tail_calls';
25+
if (feature === 'gc') return 'javascript.options.wasm_gc';
26+
if (feature === 'exceptions') return 'javascript.options.wasm_exceptions';
27+
return feature;
28+
}).join(', ');
29+
30+
if (navigator.userAgent.includes('Firefox')) {
31+
extraWasmLabel.innerHTML = `(enable <code>${firefoxText}</code> in <code>about:config</code>)`;
32+
} else {
33+
extraWasmLabel.innerHTML = `(missing wasm support for: ${featureText})`;
34+
}
35+
}
36+
} catch (error) {
37+
console.error('Error checking wasm feature support:', error);
38+
}
39+
});

fiat-crypto.html

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Fiat Cryptography Web Interface</title>
6+
<style>
7+
.error { color: red; white-space: pre-wrap; }
8+
/*code { display: block; white-space: pre-wrap; border: 1px solid #ddd; padding: 10px; position: relative; }*/
9+
.code-container {
10+
position: relative;
11+
}
12+
13+
.code {
14+
display: block;
15+
white-space: pre-wrap;
16+
border: 1px solid #ddd;
17+
padding: 10px;
18+
position: relative;
19+
/*margin-bottom: 20px;*/ /* Space for the button, adjust as needed */
20+
}
21+
22+
.copy-button {
23+
position: absolute;
24+
top: 5px;
25+
right: 5px;
26+
background: #f8f8f8;
27+
padding: 5px;
28+
border: 1px solid #ddd;
29+
cursor: pointer;
30+
z-index: 1;
31+
}
32+
.hidden { display: none; }
33+
#inputArgs { width: 100%; box-sizing: border-box; }
34+
.form-row { display: flex; flex-wrap: wrap; align-items: center; }
35+
.form-row label, .form-row button, .status-span, .permalink-span { margin-right: 10px; }
36+
.status-span, .permalink-span { flex-grow: 1; text-align: right; }
37+
.version { color: #333; }
38+
</style>
39+
</head>
40+
<body>
41+
<div id="versionContainer"><span class="version">Fiat Cryptography <span id="version"></span> (<a href="https://github.com/mit-plv/fiat-crypto">GitHub Source</a>)</span></div>
42+
<form id="inputForm" class="hidden">
43+
<div class="form-row">
44+
<input type="text" id="inputArgs" placeholder="Enter arguments">
45+
</div>
46+
<div class="form-row">
47+
<label>
48+
<input type="radio" name="inputType" value="json"> Input JSON Array
49+
</label>
50+
<label>
51+
<input type="radio" name="inputType" value="string" checked> Input String
52+
</label>
53+
<label>
54+
<input type="checkbox" id="wasm" name="codeKind" value="wasm"> Use WASM <span id="extraWasmLabel"></span>
55+
</label>
56+
</div>
57+
<div class="form-row">
58+
<button type="button" id="synthesizeButton">Synthesize</button>
59+
<button type="button" id="cancelButton" disabled>Cancel</button>
60+
<span id="status" class="status-span hidden"></span>
61+
<a id="permalink" class="permalink-span hidden" href="#">Pseudopermalink</a>
62+
<button type="button" id="clearCacheButton">Clear Cache</button>
63+
</div>
64+
</form>
65+
<div id="error" class="error hidden"></div>
66+
<div id="output" class="hidden">
67+
<div id="stdoutContainer" class="code-container">
68+
<code id="stdout" class="code"></code>
69+
<button class="copy-button" data-target="stdout">Copy</button>
70+
</div>
71+
<div id="stderrContainer" class="code-container hidden">
72+
<code id="stderr" class="code"></code>
73+
<button class="copy-button" data-target="stderr">Copy</button>
74+
</div>
75+
</div>
76+
<script src="version.js"></script>
77+
<script src="https://unpkg.com/wasm-feature-detect/dist/umd/index.js"></script>
78+
<script src="main.js"></script>
79+
<!-- N.B. disable-wasm-option.js must come after main.js so that the wasm box is unchecked correctly after parsing argv -->
80+
<script src="disable-wasm-option.js"></script>
81+
<script src="copy-button.js"></script>
82+
</body>
83+
</html>

0 commit comments

Comments
 (0)