-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
160 lines (141 loc) · 5.94 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1, maximum-scale=1"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="utf-8"/>
<title>chayns.js v4</title>
<script src="https://api.chayns-static.space/css/v4/compatibility/compatibility.min.js" version="4.2"></script>
</head>
<style>
#colorTest div {
height: 30px;
width: 48%;
margin: 0 1%;
display: inline-block;
}
</style>
<body>
<div class="tapp">
<div class="tapp__content">
<h1>chayns API v4</h1>
<button class="button" id="cursorFunction">WaitCursor</button>
<button class="button" id="cursorCall">WaitCursor Call</button>
<button class="button" id="globalCall">GlobalData Call</button>
<button class="button" id="globalData">chayns.getGlobalData</button>
<button class="button" id="colorCompare">Compare Colors</button>
<button class="button" id="consoleClear">Clear Console</button>
<button class="button" id="addOnActivateListener">onActivateListener</button>
<button class="button" id="disableDisplayTimeout">disableDisplayTimeout</button>
<button class="button" id="enableDisplayTimeout">enableDisplayTimeout</button>
<button class="button" id="openUrlInBrowser">openUrlInBrowser</button>
<div class="content__card" id="console">
<p id="0"></p>
</div>
<div id="colorTest"></div>
</div>
</div>
<script src="chayns.js"></script>
<script>
chayns.ready.then(() => {
let cursorStatus = false;
chayns.utils.setLevel(5);
window.cursorFunction = () => {
cursorStatus ? chayns.hideWaitCursor() : chayns.showWaitCursor();
cursorStatus = !cursorStatus;
};
window.cursorCall = () => {
cursorStatus = !cursorStatus;
let waitcursor = {
action: 1,
value: {
enabled: cursorStatus
}
};
chayns.invokeCall(waitcursor);
};
window.globalDataTest = () => {
chayns.getGlobalData().then(window.log);
};
window.globalCallTest = () => {
const getGlobalData = {
action: 18,
value: {
callback: 'window.log',
apiVersion: 4000
},
isWidget: true
};
chayns.invokeCall(getGlobalData);
};
let id = 1;
window.clearConsole = () => {
id = 0;
let element = document.getElementById('console');
element.innerHTML = '<p id="0"></p>';
};
window.log = (...args) => {
args.forEach((arg) => {
let para = document.createElement('p');
let node = document.createTextNode(JSON.stringify(arg, null, 2));
para.appendChild(node);
para.setAttribute('id', (id + 1).toString());
let element = document.getElementById('console');
let child = document.getElementById(id.toString());
element.insertBefore(para, child);
id++;
});
};
const compareColors = (value) => {
const testElement = document.getElementById('colorTest');
let el1 = document.createElement('div');
el1.setAttribute('class', 'chayns__background-color--' + value);
testElement.appendChild(el1);
let el2 = document.createElement('div');
el2.setAttribute('style', 'background-color: ' + chayns.utils.colors.getColorFromPalette(value) + ';');
testElement.appendChild(el2);
};
window.colorCompare = () => {
document.getElementById('colorTest').innerHTML = null;
for (let i = 1; i <= 3; i += 1) {
for (let j = 1; j <= 9; j += 1) {
compareColors(i * 100 + j);
}
}
for (let i = 1; i <= 4; i += 1) {
compareColors('red-' + i);
compareColors('yellow-' + i);
compareColors('green-' + i);
}
compareColors('primary');
compareColors('headline');
compareColors('text');
compareColors('grey');
};
window.addOnActivateListener = () => {
window.chayns.addOnActivateListener(data => window.log({ date: new Date(), data }));
};
window.disableDisplayTimeout = () => {
window.chayns.disableDisplayTimeout().then(window.log);
};
window.enableDisplayTimeout = () => {
window.chayns.enableDisplayTimeout().then(window.log);
};
window.openUrlInBrowser = () => {
window.chayns.openUrlInBrowser('https://www.google.de');
};
document.getElementById('consoleClear').addEventListener('click', window.clearConsole);
document.getElementById('globalData').addEventListener('click', window.globalDataTest);
document.getElementById('globalCall').addEventListener('click', window.globalCallTest);
document.getElementById('cursorCall').addEventListener('click', window.cursorCall);
document.getElementById('cursorFunction').addEventListener('click', window.cursorFunction);
document.getElementById('colorCompare').addEventListener('click', window.colorCompare);
document.getElementById('addOnActivateListener').addEventListener('click', window.addOnActivateListener);
document.getElementById('disableDisplayTimeout').addEventListener('click', window.disableDisplayTimeout);
document.getElementById('enableDisplayTimeout').addEventListener('click', window.enableDisplayTimeout);
document.getElementById('openUrlInBrowser').addEventListener('click', window.openUrlInBrowser);
});
</script>
</body>
</html>