chemicaljs 1.7.5 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/chemical.components.js +131 -121
- package/client/chemical.js +358 -296
- package/client/chemical.sw.js +32 -21
- package/config/meteor/meteor.config.js +13 -0
- package/config/scramjet/scramjet.config.js +8 -8
- package/config/uv/uv.config.js +9 -9
- package/index.js +460 -272
- package/package.json +4 -3
|
@@ -1,155 +1,165 @@
|
|
|
1
1
|
class ChemicalInput extends HTMLInputElement {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
constructor() {
|
|
3
|
+
super();
|
|
4
|
+
}
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
this.addEventListener("keydown", async function (e) {
|
|
7
|
+
if (e.key == "Enter" && window.chemical.loaded && e.target.value) {
|
|
8
|
+
let service = this.dataset.service || "uv";
|
|
9
|
+
let autoHttps = this.dataset.autoHttps !== undefined ? true : false;
|
|
10
|
+
let searchEngine = this.dataset.searchEngine;
|
|
11
|
+
let action = this.dataset.action;
|
|
12
|
+
let target = this.dataset.target;
|
|
13
|
+
let frame = this.dataset.frame;
|
|
14
|
+
let encodedURL = await chemical.encode(e.target.value, {
|
|
15
|
+
service,
|
|
16
|
+
autoHttps,
|
|
17
|
+
searchEngine,
|
|
18
|
+
});
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if (frame) {
|
|
21
|
+
let forFrame = document.getElementById(frame);
|
|
22
|
+
forFrame.src = encodedURL;
|
|
23
|
+
forFrame.setAttribute("data-open", "true");
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (action) {
|
|
27
|
+
window[action](encodedURL);
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
if (target) {
|
|
31
|
+
if (target == "_self") {
|
|
32
|
+
window.location = encodedURL;
|
|
33
|
+
} else if (target == "_blank") {
|
|
34
|
+
window.open(encodedURL);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
class ChemicalButton extends HTMLButtonElement {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
constructor() {
|
|
44
|
+
super();
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this.addEventListener("click", function (e) {
|
|
48
|
+
let forInput = document.getElementById(this.dataset.for);
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
if (forInput) {
|
|
51
|
+
forInput.dispatchEvent(
|
|
52
|
+
new KeyboardEvent("keydown", {
|
|
53
|
+
key: "Enter",
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
class ChemicalIFrame extends HTMLIFrameElement {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
static observedAttributes = ["data-open"];
|
|
63
|
+
constructor() {
|
|
64
|
+
super();
|
|
65
|
+
}
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
let open = this.dataset.open;
|
|
68
|
+
this.style.display = open == "true" ? "" : "none";
|
|
69
|
+
}
|
|
70
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
71
|
+
if (name == "data-open") {
|
|
72
|
+
let open = this.dataset.open;
|
|
73
|
+
this.style.display = open == "true" ? "" : "none";
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
let controls = document.getElementById(this.dataset.controls);
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
77
|
+
if (controls) {
|
|
78
|
+
controls.dataset.open = open;
|
|
79
|
+
}
|
|
79
80
|
}
|
|
81
|
+
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
class ChemicalControls extends HTMLElement {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
85
|
+
static observedAttributes = ["data-open"];
|
|
86
|
+
constructor() {
|
|
87
|
+
super();
|
|
88
|
+
}
|
|
89
|
+
connectedCallback() {
|
|
90
|
+
let open = this.dataset.open;
|
|
91
|
+
this.style.display = open == "true" ? "" : "none";
|
|
92
|
+
}
|
|
93
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
94
|
+
if (name == "data-open") {
|
|
95
|
+
let open = this.dataset.open;
|
|
96
|
+
this.style.display = open == "true" ? "" : "none";
|
|
96
97
|
}
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
class ChemicalLink extends HTMLAnchorElement {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
constructor() {
|
|
103
|
+
super();
|
|
104
|
+
}
|
|
105
|
+
async connectedCallback() {
|
|
106
|
+
let href = this.dataset.href;
|
|
107
|
+
let service = this.dataset.service || "uv";
|
|
108
|
+
let autoHttps = this.dataset.autoHttps !== undefined ? true : false;
|
|
109
|
+
let searchEngine = this.dataset.searchEngine;
|
|
110
|
+
this.dataset.chemicalLoading = "true";
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
if (window.chemical.loaded) {
|
|
113
|
+
this.setAttribute(
|
|
114
|
+
"href",
|
|
115
|
+
await chemical.encode(href, {
|
|
116
|
+
service,
|
|
117
|
+
autoHttps,
|
|
118
|
+
searchEngine,
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
this.dataset.chemicalLoading = "false";
|
|
122
|
+
} else {
|
|
123
|
+
window.addEventListener("chemicalLoaded", async () => {
|
|
124
|
+
this.setAttribute(
|
|
125
|
+
"href",
|
|
126
|
+
await chemical.encode(href, {
|
|
127
|
+
service,
|
|
128
|
+
autoHttps,
|
|
129
|
+
searchEngine,
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
this.dataset.chemicalLoading = "false";
|
|
133
|
+
});
|
|
127
134
|
}
|
|
135
|
+
}
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
customElements.define("chemical-input", ChemicalInput, { extends: "input" });
|
|
131
139
|
customElements.define("chemical-button", ChemicalButton, { extends: "button" });
|
|
132
140
|
customElements.define("chemical-iframe", ChemicalIFrame, { extends: "iframe" });
|
|
133
|
-
customElements.define("chemical-controls", ChemicalControls, {
|
|
141
|
+
customElements.define("chemical-controls", ChemicalControls, {
|
|
142
|
+
extends: "section",
|
|
143
|
+
});
|
|
134
144
|
customElements.define("chemical-link", ChemicalLink, { extends: "a" });
|
|
135
145
|
|
|
136
146
|
function chemicalAction(action, frameID) {
|
|
137
|
-
|
|
147
|
+
let frame = document.getElementById(frameID);
|
|
138
148
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
149
|
+
if (frame) {
|
|
150
|
+
switch (action) {
|
|
151
|
+
case "back":
|
|
152
|
+
frame.contentWindow.history.back();
|
|
153
|
+
break;
|
|
154
|
+
case "forward":
|
|
155
|
+
frame.contentWindow.history.forward();
|
|
156
|
+
break;
|
|
157
|
+
case "reload":
|
|
158
|
+
frame.contentWindow.location.reload();
|
|
159
|
+
break;
|
|
160
|
+
case "close":
|
|
161
|
+
frame.dataset.open = "false";
|
|
162
|
+
frame.src = "";
|
|
154
163
|
}
|
|
164
|
+
}
|
|
155
165
|
}
|