-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsafety.js
38 lines (32 loc) · 1.07 KB
/
safety.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
"use strict";
function assertation_failed (message) {
this.message = message;
}
function assert(boolean_value, exception_message) {
if(!boolean_value) {
console.trace();
write_error(exception_message); // cannot be async
document.body.style.cursor = get_cursor_or_none("default");
$("#layers_container").sortable("enable");
$("#ribbon,select,input,checkbox").prop("disabled", false);
write_descriptions(); // cannot be async
highlight_code(); // cannot be async
var link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement("link");
link.rel = "icon";
document.getElementsByTagName("head")[0].appendChild(link);
}
link.href = "favicon.ico";
throw new assertation_failed(exception_message);
} else {
document.body.style.cursor = get_cursor_or_none("default");
}
}
function typeassert(_var, type, name) {
if(type == "array") {
assert(Array.isArray(_var), `type of ${name} is not ${type}, but ${typeof(_var)}`);
} else {
assert(typeof(_var) == type, `type of ${name} is not ${type}, but ${typeof(_var)}`);
}
}