-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexCODE.html
More file actions
192 lines (167 loc) · 6.66 KB
/
texCODE.html
File metadata and controls
192 lines (167 loc) · 6.66 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!--
Thanks to Caleb Cooper for refactoring the source code and implementing show code
file renaming.
Want to mod texCODE? I'll make a tutorial at some point.
🄯2023 Matthew_inc.
VERSION: v1.0.1 RETAIL VER
CHANGELOG: Finalised systems and implemented appView mode.
This is the first full release. EXPECT MISSING FEATURES!
[Caleb C]:
[04/17/2024]
- Added indentation to the source file
- Refactored buttons to have single function calls
- Added the 'newEditor' and 'evaluateCode' functions
- Removed redundant lines of code
- 'appMode' now toggles between showing and hiding code
- 'makeEruda' will no longer create duplicate buttons
- Reordered buttons to group similar opterations together
LICENSE: Matthew_inc. OSS License (see LICENSE.html)
-->
<html style="overflow: hidden;">
<head>
<title>MI texCODE</title>
</head>
<body style="background: lightgray;overflow: hidden;">
<menubar style="background:gray;">
<input type="text" id="fileName" placeholder="File name/path">
<button onclick="download()">⤓ Download</button>
</menubar>
<br>
<menubar style="background: gray;">
<button onclick="newEditor()">⧉ New Editor</button>
<button onclick="makeEruda()">⎈ Console</button>
<button onclick="appMode()" id="appModeButton">☰ Hide Code</button>
<button onclick="evaluateCode()">► Evaluate</button>
<button onclick="runCode()">≫ Preview HTML</button>
</menubar>
<br height="1px">
<style>
*:focus{
outline: none;
}
textarea {
resize: none;
width: 49%;
height: 90%;
margin: none;
display:inline-block;
white-space: pre;
overflow-wrap: normal;
overflow-x: scroll;
}
div {
overflow: scroll;
width: 49%;
height: 90%;
margin: none;
background-color:white;
display:inline-block;
outline: solid 1px DimGray;
size: fixed;
}
</style>
<textarea id="code" spellcheck="false"></textarea>
<div id="view"></div>
<script id="image-library">
colours = [0,4,3,7,2,6,5,1,9,8]
function rgb_colour(r,g,b,s){
return colours[(s<<3)+(r<<2)+(g<<1)+b];
}
function special_colour(id){
return (1<<3)+id;
}
class colour {
s = false
r = false
g = false
b = false
constructor(r,g,b,s=false){
this.r = r
this.g = g
this.b = b
this.s = s
}
get_id(){
return rgb_colour(this.r,this.g,this.b,this.s)
}
}
colour_test = new colour(0,1,0).get_id()
class image {
grid = [...Array(16).keys()].map(x => [...Array(16).keys()].map(y => new colour(1,1,1)))
set_rgb(x,y,r,g,b,s=0){
this.grid[x][y].r=r
this.grid[x][y].g=g
this.grid[x][y].b=b
this.grid[x][y].s=s
}
fill(r,g,b,s=0){
this.grid = [...Array(16).keys()].map(x => [...Array(16).keys()].map(y => new colour(r,g,b,s)))
}
render(){
return "<img src=\"https://verumignis.com/bitmapgen/"+this.grid.map(row => row.map(colour => colour.get_id()).join('')).join('-')+"\">"
}
}
picture = new image()
picture.fill(0,0,1)
picture.set_rgb(8,8,0,1,0)
setScreen(picture.render())
</script>
<script>
var erudaVisible = false;
var inAppMode = false;
function newEditor() {
open(window.location.href,'','width:500')
}
function runCode() {
setScreen(getCode())
}
function evaluateCode() {
eval(document.getElementById('code').value)
}
function appMode() {
if (inAppMode) {
// Exit App Mode
document.getElementById('code').style='display:inline-block';
document.getElementById('view').style='width:50%';
document.getElementById("appModeButton").innerHTML = "☰Hide Code"
inAppMode = false;
} else {
document.getElementById('code').style='display:none';
document.getElementById('view').style='width:98%';
document.getElementById("appModeButton").innerHTML = "☰Show Code"
inAppMode = true;
}
}
function makeEruda() {
// Makes it so the Eruda button isn't spawned in multiple times
if (erudaVisible) {return;}
erudaVisible = true;
var script = document.createElement('script');
script.src='https://cdn.jsdelivr.net/npm/eruda';
document.body.appendChild(script); eruda.init();
}
function download() {
var text = document.getElementById("code").value;
var path = document.getElementById("fileName").value;
var blob = new Blob([text], { type: "text/plain"});
var anchor = document.createElement("a");
anchor.download = path;
anchor.href = window.URL.createObjectURL(blob);
anchor.target ="_blank";
anchor.style.display = "none";
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
function setScreen(text){
document.getElementById("view").innerHTML = text;
}
function getCode(){
return document.getElementById("code").value;
}
</script>
<script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<div id="eruda" style="all: initial;"></div>
<div class="__chobitsu-hide__" style="all: initial;"></div>
</body>
</html>