|
1 | 1 | <script lang="ts"> |
2 | | - import { go } from "@codemirror/lang-go"; |
3 | 2 | import { cpp } from "@codemirror/lang-cpp"; |
4 | | - import { python } from "@codemirror/lang-python"; |
| 3 | + import { go } from "@codemirror/lang-go"; |
5 | 4 | import { javascript } from "@codemirror/lang-javascript"; |
6 | | - import Graph from "./Graph.svelte"; |
7 | | - import type { Language } from "../control-flow/cfg"; |
| 5 | + import { python } from "@codemirror/lang-python"; |
| 6 | + import type { LanguageSupport } from "@codemirror/language"; |
8 | 7 | import * as LZString from "lz-string"; |
9 | | - import Editor from "./Editor.svelte"; |
| 8 | + import type { Language } from "../control-flow/cfg"; |
| 9 | + import { evolve } from "../control-flow/evolve.ts"; |
10 | 10 | import CodeSegmentation from "./CodeSegmentation.svelte"; |
11 | 11 | import ColorScheme from "./ColorSchemeEditor.svelte"; |
12 | | - import { getSystemColorList, toggleTheme, isDark } from "./lightdark.ts"; |
13 | | - import type { LanguageSupport } from "@codemirror/language"; |
14 | | - import { evolve } from "../control-flow/evolve.ts"; |
| 12 | + import Editor from "./Editor.svelte"; |
| 13 | + import Graph from "./Graph.svelte"; |
| 14 | + import { getSystemColorList, isDark, toggleTheme } from "./lightdark.ts"; |
15 | 15 |
|
16 | 16 | // ADD-LANGUAGES-HERE |
17 | 17 | const defaultCodeSamples: { [language in Language]?: string } = { |
|
112 | 112 | ]; |
113 | 113 |
|
114 | 114 | let selection = |
115 | | - languages[parseInt(urlParams.get("language"))] ?? languages[0]; |
| 115 | + languages[Number.parseInt(urlParams.get("language"))] ?? languages[0]; |
116 | 116 |
|
117 | 117 | function share() { |
118 | 118 | const compressedCode = LZString.compressToEncodedURIComponent( |
119 | 119 | languageCode[selection.language], |
120 | 120 | ); |
121 | 121 | const codeName = selection.language.toLowerCase(); |
122 | | - const language = languages.findIndex((lang) => lang == selection); |
| 122 | + const language = languages.findIndex((lang) => lang === selection); |
123 | 123 | const query = `?language=${language}&${codeName}=${compressedCode}`; |
124 | | - const newUrl = |
125 | | - window.location.protocol + |
126 | | - "//" + |
127 | | - window.location.host + |
128 | | - window.location.pathname + |
129 | | - query; |
| 124 | + const newUrl = `${window.location.protocol}//${window.location.host}${window.location.pathname}${query}`; |
130 | 125 | navigator.clipboard.writeText(newUrl); |
131 | 126 | window.open(newUrl, "_blank").focus(); |
132 | 127 | } |
133 | 128 |
|
134 | 129 | let graph: Graph; |
135 | 130 |
|
136 | 131 | function downloadString(text: string, fileType: string, fileName: string) { |
137 | | - var blob = new Blob([text], { type: fileType }); |
| 132 | + const blob = new Blob([text], { type: fileType }); |
138 | 133 |
|
139 | | - var a = document.createElement("a"); |
| 134 | + const a = document.createElement("a"); |
140 | 135 | a.download = fileName; |
141 | 136 | a.href = URL.createObjectURL(blob); |
142 | 137 | a.dataset.downloadurl = [fileType, a.download, a.href].join(":"); |
143 | 138 | a.style.display = "none"; |
144 | 139 | document.body.appendChild(a); |
145 | 140 | a.click(); |
146 | 141 | document.body.removeChild(a); |
147 | | - setTimeout(function () { |
| 142 | + setTimeout(() => { |
148 | 143 | URL.revokeObjectURL(a.href); |
149 | 144 | }, 1500); |
150 | 145 | } |
|
0 commit comments