-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript_V22.html
More file actions
284 lines (269 loc) · 10.2 KB
/
Script_V22.html
File metadata and controls
284 lines (269 loc) · 10.2 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- this is the code that will allow icon to be visible in the title bar of the brower -->
<link rel="icon" type="image/ico" href="WebsiteLogo2.png" />
<!-- you can also say this: <link rel="icon" type="image/png" href="location/image.png" /> -->
<head>
<title>Script</title>
<style>
div.field {
font-family: 'Consolas';
font-size: 20px;
color: black;
width: 1000px;
height: 1000px;
border: 3px solid #cccccc;
background-color: white;
padding: 10px;
resize: none;
}
textarea:focus {
background-image: none;
}
::selection {
background: #eeb005da;
/* WebKit/Blink Browsers */
}
::-moz-selection {
background: #eeb005da;
/* Gecko Browsers */
}
body {
background-color: #E5E4E2;
}
div.buttons {
padding-bottom: 20px;
position: sticky;
top: 0;
padding-top: 10px;
padding-bottom: 20px;
background-color: #E5E4E2;
font-size: 20px;
}
table {
border-collapse: collapse;
border: 2px solid #bbb;
background-color: white;
letter-spacing: 1px;
font-size: 0.8rem;
padding: .2em;
table-layout: fixed;
font-family: 'Consolas';
font-size: 16px;
}
th {
background-color: #eeb005da;
color: white;
font-family: 'Consolas';
padding: 5px;
}
td {
font-family: 'Consolas';
padding: 5px;
}
tr:hover {
background-color: #f5f5f5;
}
button {
background-color: #bbb;
padding: .2em;
margin-left: 1em;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 10px;
color: #fff;
font-family: 'Consolas';
/*Oswald is a great font*/
text-decoration: none;
border: none;
font-size: 20px;
}
button:hover {
background-color: rgb(172, 122, 15);
}
</style>
</head>
<script src="./jquery-2.1.0.js"></script>
<body>
<div class="buttons"><img src="ScriptIcon.png" />
<button id="Control">Change Buttons</button>
<button id="Spelling">Spell Check</button>
<button id="Table">Insert Table</button>
<button id="EmojiA">Game Symbols</button>
<button id="EmojiB">Emotion emojis</button>
<button id="EmojiC">Legal Symbols</button>
<button id="EmojiD">Signs</button>
</div>
<!-- <textarea id="a" spellcheck="true" cols="30" autofocus="false" placeholder=""></textarea> -->
<div id="textZone" class="field" contentEditable="true">
<div id="top">
<img src="ScriptDOM2.png" />
</div>
<div>Welcome to the Second Edition of Script! This Edition contains many useful standardized features, such as
inserting images by copying them
to the document from an external source, common shortcuts (control-z, control-c, control-v), and expansive tables,
that can reach unlimited sizes.</div>
<div>Script II also has tables, which can be used for multiple purposes, such as this one right here, showing a
game of tic-tac-toe:</div>
<div>
<table id="Table1">
<tr>
<td>X</td>
<td>O</td>
<td>X</td>
</tr>
<tr>
<td></td>
<td>X</td>
<td>O</td>
</tr>
<tr>
<td></td>
<td></td>
<td>O</td>
</tr>
</table>
</div>
<div>Go to the above menu, and thumb through the buttons, testing their functions and properties. Don't forget the all-important button labelled
'Change Buttons,' as it gives you a different set of buttons on the menu, as if you are on a new tab. Once you begin to get comfortable with
Script II, you may delete this text(and table too!) and begin your document!</div>
<div id="body"></div>
</div>
<script>
//Registering the buttons
let control = document.getElementById("Control");
let spelling = document.getElementById("Spelling");
let emojiA = document.getElementById("EmojiA")
let emojiB = document.getElementById("EmojiB")
let emojiC = document.getElementById("EmojiC")
let emojiD = document.getElementById("EmojiD")
let table = document.getElementById("Table");
//button events
let tablecount = 1;
table.addEventListener("click", () => {
console.log("table clicked." + tablecount);
tablecount++;
InsertTable(2, 2, `Table${tablecount}`);
//The first table is table1, but that is already taken in the example
});
control.addEventListener("click", () => {
changeButtons();
//The last table inserted is removed
console.log("Changed " + tablecount)
});
emojiA.addEventListener("click", () => {
$('#textZone').append(`<div>🎰🎳🎱🎲🎮🀄♔🏓🃏⚾♠</div>`);
});
emojiB.addEventListener("click", () => {
$('#textZone').append(`<div>😋😏😇😃😄😒😞😕😐😮😠😈😱😓</div>`);
});
emojiC.addEventListener("click", () => {
$('#textZone').append(`<div>💱💵💲€¢£¥©®℗™℠§</div>`);
});
emojiD.addEventListener("click", () => {
$('#textZone').append(`<div>📵🚱🚯🚭🚫🚳🚷⛔♲⛽🌐ℹ🚰🛃🛅♿🅿⚠</div>`);
});
//Key events
document.addEventListener("keyDown", function (event) {
event.preventDefault();
});
var displayNum = -1;
changeButtons();
function changeButtons() {
if (displayNum == -1) {
//For starting purposes
displayNum++;
changeButtons();
} else if (displayNum == 0) {
//Main file stuff
clearButtons();
document.getElementById("Spelling").style.display = "inline";
displayNum++;
} else if (displayNum == 1) {
//TableStuff
clearButtons();
document.getElementById("Table").style.display = "inline";
displayNum++;
} else if(displayNum == 2){
//Emojis
clearButtons();
document.getElementById("EmojiA").style.display = "inline";
document.getElementById("EmojiB").style.display = "inline";
document.getElementById("EmojiC").style.display = "inline";
document.getElementById("EmojiD").style.display = "inline";
displayNum++;
}else{
displayNum = 0;
changeButtons();
}
}
function clearButtons() {
document.getElementById("Spelling").style.display = "none";
document.getElementById("Table").style.display = "none";
document.getElementById("EmojiA").style.display = "none";
document.getElementById("EmojiB").style.display = "none";
document.getElementById("EmojiC").style.display = "none";
document.getElementById("EmojiD").style.display = "none";
}
function InsertTable(x, y, identif) {
// $('#body').append(`<table id="${identif}" width="320" border="1"><tr><td colspan="${x}" rowspan="${y}">` + " Title" +
// '</td></tr><tr><td width="118">' + "sxs" + '</td><td width="186">' + "xs" + '</td></tr></table>');
console.log(identif);
$('#textZone').append(`
<button onclick="addRow(${identif})">add Row</button>
<button onclick="addCol(${identif})" display="inline">add Column</button>
<div style="overflow-x:auto;"><div style="overflow-y:auto;"><table id="${identif}" border="1" colspan="${x}" rowspan="${y}" padding="10px">
<tr>
<th>Column A</th>
<th>Column B</th>
</tr>
<tr>
<td>Data A</td>
<td>Data B</td>
</tr>
</table>
</div>
<div>text+</div>`);
console.log(identif)
}
function addRow(count) {
var table = count;
console.log(table)
var count = parseInt(table.rows[0].cells.length);
var rowCount = 1;
for (var k = 0; k < rowCount; k++) {
var row = table.insertRow(-1);
for (var i = 0; i < count; i++) {
row.insertCell(i).innerHTML = ".";
}
}
}
function addCol(count) {
var table = count;
var row = table.getElementsByTagName("tr");
for (i = 0; i < row.length; i++) {
if (i == 0) {
var td = document.createElement('th');
} else {
var td = document.createElement('td');
}
//td.innerHTML = "<input type='text' />";
row[i].appendChild(td);
if (i == 0) {
td.innerHTML = "Data+"
} else {
td.innerHTML = "."
}
}
}
function removeTable() {
if (tablecount > 0) {
var elem = document.getElementById(`Table${tablecount}`);
elem.parentNode.removeChild(elem);
tablecount = tablecount - 1;
}
}
</script>
</body>
</html>