-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathold.js
executable file
·308 lines (294 loc) · 7.89 KB
/
old.js
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
class appWindow {
constructor(title, content) {
this.title = title;
this.content = content;
}
display() {
//title thing
var node = document.createElement('window');
let g = document.createElement('taskbar');
//close btn
var taskbar = document.createTextNode("X");
var taskbardiv = document.createElement("close");
taskbardiv.appendChild(taskbar);
g.appendChild(taskbardiv);
g.innerHTML += this.title;
node.appendChild(g);
let y = document.createElement('windowcontent');
y.innerHTML = this.content;
node.appendChild(y);
//draggy resizo
const position = { x: 0, y: 0 };
const positiona = { x: 0, y: 0 }
interact(node).draggable({
allowFrom: "taskbar",
modifiers: [],
listeners: {
start(event) {},
move(event) {
position.x += event.dx;
position.y += event.dy;
event.target.style.transform = `translate(${position.x}px, ${position.y}px)`;
}
}
})
interact(node).resizable({
edges: {
top: false,
left: false,
bottom: true,
right: true
}
}).on('resizemove', event => {
let { x, y } = event.target.dataset;
Object.assign(event.target.style, {
width: `${event.rect.width}px`,
height: `${event.rect.height}px`
})
Object.assign(event.target.dataset, { x, y })
});
document.getElementById("windows").appendChild(node); // add to window container
document.querySelectorAll('close').forEach( (x) => x.onclick = function() {
windowsOpened--;
//console.log(this.parentNode.parentNode)
this.parentNode.parentNode.remove();
});
windowsOpened++
}
}
//file system
var storage = {
private: {
"version.str": "alpha 5.4"
},
appData: {
tempJS: {
"commands.str": ``
}
},
stored: {
"text.str": "true",
"haha.ra": ["hi", "wow"],
desktop: {
"yes.str": "yes"
}
},
"wow.str": "clap clap wow"
};
var node = document.createElement("window");
//the boring variable thingies
const errtxt = document.getElementById("popup-text");
const blur = document.getElementById("darken");
const windowContainer = document.getElementById("windows");
var active = "";
var isnotifsopen = false;
var appcodes = {
/*yay new method*/
hub: `
<h1>Hub thingy<h1>
<div id='hhtabs'></div>
`
};
var windowsOpened = 0;
var xOffset, yOffset;
//function defining
function toggleblur() {
$(".darken").toggle();
}
function togglePopup() {
toggleblur();
$(".popup").toggle();
}
//no longer used:
function openWindow(appID, custom) {
//get the code and stuff
var classCount = 0;
var windowname;
var windowcode;
if (custom) {
windowcode = appcodes[appID];
} else {
windowcode = appID;
windowname = custom;
}
var windowname = appID;
var node = document.createElement("window"); //make a node (for the app)
//decode the windowcode
//title bar (named taskbar)
const position = { x: 0, y: 0 };
interact(node).draggable({
allowFrom: "taskbar",
modifiers: [],
listeners: {
start(event) {},
move(event) {
position.x += event.dx;
position.y += event.dy;
event.target.style.transform = `translate(${position.x}px, ${position.y}px)`;
}
}
})
interact(node).resizable({
edges: {
top: false,
left: false,
bottom: true,
right: true
}
}).on('resizemove', event => {
let { x, y } = event.target.dataset;
Object.assign(event.target.style, {
width: `${event.rect.width}px`,
height: `${event.rect.height}px`
})
Object.assign(event.target.dataset, { x, y })
});
var taskbar;
if (!custom) {
taskbar = document.createTextNode("" + windowname + "");
} else {
taskbar = document.createTextNode("");
}
var taskbardiv = document.createElement("taskbar");
taskbardiv.id = "windowId" + windowsOpened + "header";
taskbardiv.appendChild(taskbar);
taskbardiv.id = "windowTitle" + windowsOpened;
node.appendChild(taskbardiv);
//close
//dont mind recycling of vars
taskbar = document.createTextNode("X");
taskbardiv = document.createElement("close");
taskbardiv.appendChild(taskbar);
taskbardiv.onclick = function() {
windowsOpened--;
this.parentNode.remove();
};
taskbardiv.id = "closeButton" + windowsOpened;
node.appendChild(taskbardiv);
//aaa
var line;
for (var i = 0; i < windowcode.length; i++) {
line = windowcode[i];
var textnode = document.createTextNode(line);
if (i % 2 == 0) {
var tag = document.createElement(line);
tag.id = classCount + "of" + appID;
classCount += 1;
} else {
tag.appendChild(textnode);
node.appendChild(tag);
} //-if
} //-for
windowsOpened++;
node.id = "windowId" + windowsOpened;
document.getElementById("windows").appendChild(node); // add to window container
//add icon to bar
addToBar(appID, "#fff", appID.charAt(0));
elmnt = document.getElementById(active);
} //-function
function appendNewElement(ae_name, ae_content, ae_element) {
var ae_node = newElement(ae_name, ae_content);
ae_element.appendChild(ae_node);
}
function newElement(ne_tagname, ne_content) {
var ne_textnode = document.createTextNode(ne_content);
var ne_node = document.createElement(ne_tagname);
ne_node.appendChild(ne_textnode);
return ne_node;
}
$(document).on("click", "taskbar", function() {
active = this.id;
});
function closewindo() {
alert("no");
}
function feGetFilesaddElements() {
feContainer.innerHTML = "";
var fefile = "";
for (fefile in feDirectory) {
var fecurrentfile = feDirectory[fefile];
//check if folder or file
if (typeof fecurrentfile == "string") {
appendNewElement("fefile", fefile, feContainer);
} else {
appendNewElement("fefolder", fefile, feContainer);
}
}
$('fefolder').onclick = function() {
feDirectory = feDirectory[this.innerHTML];
feGetFilesaddElements();
feGetFilesaddElements();
}
$('fefile').onclick = function() {
alert(feDirectory[this.innerHTML]);
feGetFilesaddElements();
}
}
function addToBar(atb_name, atb_color, atb_iconhtm) {
document.getElementById("bar").innerHTML +=
"<baritem>" + atb_iconhtm + "</baritem>";
}
$(document).ready(function() {
//openWindow('settings', false);
});
$('body').bind('contextmenu', function() { //i think it removes the right click menu
return false;
});
//redirect from Nothing
if (document.referrer.startsWith('https://liimee.') || document.referrer.includes('vercel.app') || document.referrer.includes('bit.ly') || document.referrer.includes('.tinyurl.')) {
alert("you're already in the best OS, and no HmmOS is not better. And if you came here from bit.ly or vercel.app, NOPE LOL")
window.history.back();
}
//rickroll for iframes
aaa = window.location.href
if (window.location !== window.parent.location && !aaa.startsWith("http://localhost:")) {
document.body.innerHTML = ('<iframe width="420" height="345" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" frameborder="0" allowfullscreen></iframe>')
}
//modern app maker
function openApp(code, name) {
var openwin = new appWindow(name, code);
openwin.display();
}
function newNotif(heading, body) {
var node = document.createElement('notif')
node.innerHTML = '<b class="block">' + heading + '</b>' + body
document.getElementById('notifs').appendChild(node)
}
$(document).ready(function() {})
document.onclick = function() {
document.querySelector('audio').play()
document.onclick = function() {}
newNotif('Welcome!', 'Hello there, this is the worst OS');
anime({
target: "#darken",
opacity: 1
})
}
window.onload = function() {
document.querySelector('#start').ondblclick = function() {
if (!isnotifsopen) {
$('notif').addClass('open')
} else {
$('notif').removeClass('open')
}
isnotifsopen = !isnotifsopen
}
// "boot"
anime({
target: "div",
opacity: 0
})
}
function restart() {
document.querySelector('#darken').style.display = 'block'
var xa = 0
setInterval(function() {
document.querySelector('#darken').style.opacity = xa
xa += 0.05
if (xa = 0) {
document.querySelector('#darken').style.opacity = 1;
}
}, 30)
}