Skip to content

Commit

Permalink
Deploying to gh-pages from @ 01207f8 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jul 20, 2024
1 parent 023d9e2 commit dae21f2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
2 changes: 1 addition & 1 deletion latest/build_info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"gitHash" : "77885caf1d0683770c7830aa41e11206f5f2da21",
"gitHash" : "01207f80b70219b87ccfc6cac28bff86f1ce8e93",
"scalametaVersion" : "4.8.10"
}
2 changes: 1 addition & 1 deletion latest/main.js.map

Large diffs are not rendered by default.

60 changes: 53 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,44 @@ import hljs from "https://unpkg.com/@highlightjs/[email protected]/es/highlight.
import scala from "https://unpkg.com/@highlightjs/[email protected]/es/languages/scala.min.js";
hljs.registerLanguage("scala", scala);

function fromBase64(base64) {
const binString = atob(base64);
const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));
return new TextDecoder().decode(bytes);
}

function toBase64(text) {
const bytes = new TextEncoder().encode(text);
const binString = Array.from(bytes, (byte) =>
String.fromCodePoint(byte),
).join("");
return btoa(binString);
}

const getFromStorageOr = (key, defaultValue, fun) => {
const saved = localStorage.getItem(key);
if (saved === null) {
return defaultValue;
} else {
if (fun == null) {
return saved;
const p = new URLSearchParams(location.search);
const fromQuery = p.get(key);
if (fromQuery == null) {
const saved = localStorage.getItem(key);
if (saved === null) {
return defaultValue;
} else {
return fun(saved);
if (fun == null) {
return saved;
} else {
return fun(saved);
}
}
} else {
try {
if (fun == null) {
return fromBase64(fromQuery);
} else {
return fun(fromBase64(fromQuery));
}
} catch (e) {
console.log(e);
return defaultValue;
}
}
};
Expand Down Expand Up @@ -369,6 +398,23 @@ const App = () => {
clear local storage
</button>
</div>
<div class="col">
<button
class="btn btn-primary"
id="share"
onclick=${() =>
navigator.clipboard.writeText(
window.location.origin +
window.location.pathname +
"?" +
[["source", inputScala]]
.map(([k, v]) => k + "=" + toBase64(v))
.join("&"),
)}
>
share
</button>
</div>
</div>
</div>
<div class="col-2">
Expand Down
2 changes: 1 addition & 1 deletion scalafix-compat/build_info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"gitHash" : "77885caf1d0683770c7830aa41e11206f5f2da21",
"gitHash" : "01207f80b70219b87ccfc6cac28bff86f1ce8e93",
"scalametaVersion" : "4.6.0"
}
2 changes: 1 addition & 1 deletion scalafix-compat/main.js.map

Large diffs are not rendered by default.

0 comments on commit dae21f2

Please sign in to comment.