word-games-theme 2.3.9 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,4 +17,5 @@
17
17
  --light-gray: rgb(137, 137, 137);
18
18
  --tooltip-padding: 0.5rem;
19
19
  --tooltip-border-style: 0.5rem;
20
- }
20
+ }
21
+
@@ -0,0 +1,198 @@
1
+ let txtBox = document.querySelector('.txtBox')
2
+ txtBox.focus()
3
+ let letterCloseButton = document.querySelector('.letter-close-button')
4
+
5
+ let startsWith = document.getElementById("startsWith");
6
+ let mustInclude = document.getElementById("mustInclude");
7
+ let endsWith = document.getElementById("endsWith");
8
+ let exculdeWith = document.getElementById("exculdeWith");
9
+ let inculdeWith = document.getElementById("inculdeWith");
10
+ let wordLength = document.getElementById("wordLength");
11
+
12
+ // // when typing on input
13
+ txtBox.addEventListener('input', (e) => {
14
+ if (e.target.value === "") {
15
+ // letterCloseButton.style.display = "none"
16
+ }
17
+ else {
18
+ // letterCloseButton.style.display = "block"
19
+ }
20
+ e.target.value = e.target.value.replace(/[^a-zA-Z? ]/g, "")
21
+ let rangeOfBlankTile = 3
22
+ if (rangeOfBlankTile === "") {
23
+ rangeOfBlankTile = 3
24
+ }
25
+ e.target.value = e.target.value.replace(/ /g, '?')
26
+ let data = []
27
+ data = e.target.value.split('').filter((i) => i === '?')
28
+ if (data.length > rangeOfBlankTile) {
29
+ e.target.value = e.target.value.replace(/\?$/, '')
30
+ }
31
+ })
32
+ letterCloseButton.addEventListener("click", () => {
33
+ txtBox.value = ""
34
+ letterCloseButton.style.display = "none"
35
+ })
36
+ //tooltips for advanced filter
37
+ const filterInputs = document.querySelectorAll('.filter_val');
38
+ Array.from(filterInputs).forEach((item) => {
39
+ item.addEventListener("input", (e) => {
40
+ const inputValue = e.target.value;
41
+ const parentElement = e.target.parentElement;
42
+ const imgElement = parentElement.querySelector('img');
43
+ const tooltipElement = parentElement.querySelector('.filter-tooltip');
44
+
45
+ if (inputValue == "") {
46
+ imgElement.src = "/assets/images/questionmark.svg"
47
+ setTimeout(() => {
48
+ item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id)
49
+ }, 100);
50
+ tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
51
+ tooltipElement.style.setProperty('--tooltip-border-style', 'soild');
52
+
53
+ } else {
54
+ item.nextElementSibling.removeAttribute("data-tip")
55
+ imgElement.src = "/assets/images/close-btn.svg"
56
+ tooltipElement.style.setProperty('--tooltip-padding', '0');
57
+ tooltipElement.style.setProperty('--tooltip-border-style', 'none');
58
+ }
59
+ item.nextElementSibling.addEventListener("click", () => {
60
+ e.target.value = ""
61
+ imgElement.src = "/assets/images/questionmark.svg"
62
+ setTimeout(() => {
63
+ item.nextElementSibling.setAttribute("data-tip", item.nextElementSibling.id)
64
+ }, 100);
65
+ tooltipElement.style.setProperty('--tooltip-padding', '0.5rem');
66
+ tooltipElement.style.setProperty('--tooltip-border-style', 'soild');
67
+ })
68
+ })
69
+ })
70
+
71
+
72
+ // Define the loadScript function first
73
+ const loadScript = (FILE_URL, data = {}, async = true, type = "text/javascript") => {
74
+ return new Promise((resolve, reject) => {
75
+ const scriptEle = document.createElement("script");
76
+ scriptEle.type = type;
77
+ scriptEle.async = async;
78
+ scriptEle.src = FILE_URL;
79
+
80
+ // Set additional data as attributes on the script element
81
+ Object.keys(data).forEach((key) => {
82
+ scriptEle.setAttribute(`data-${key}`, data[key]);
83
+ });
84
+
85
+ scriptEle.addEventListener("load", () => {
86
+ resolve({ status: true });
87
+ });
88
+
89
+ scriptEle.addEventListener("error", () => {
90
+ reject({
91
+ status: false,
92
+ message: `Failed to load the script ${FILE_URL}`,
93
+ });
94
+ });
95
+
96
+ document.body.appendChild(scriptEle);
97
+ });
98
+ };
99
+
100
+ // Now you can use the loadScript function with additional data
101
+ function checkQueryParam() {
102
+ const urlParams = new URLSearchParams(window.location.search);
103
+ const paramName = 'search';
104
+ if (urlParams.has(paramName)) {
105
+ const additionalData = {
106
+ url: "{{site.url}}",
107
+ range: "{{page.blanktilerange}}"
108
+ };
109
+ var p1 = loadScript("/assets/js/wordfinder.js", additionalData)
110
+ .then((data) => {
111
+ console.log(data);
112
+ })
113
+ .catch((error) => {
114
+ console.error(error);
115
+ });
116
+ }
117
+ }
118
+ checkQueryParam();
119
+
120
+ const formElement = document.querySelector("#form");
121
+ formElement.addEventListener("submit", function (e) {
122
+ e.preventDefault();
123
+
124
+ document.querySelector(".fillterWrapper").classList.add("hide")
125
+ let selectedDictionary = document.querySelector(".select_dropDown2").value;
126
+ if (history.pushState) {
127
+ var newurl =
128
+ window.location.protocol +
129
+ "//" +
130
+ window.location.host +
131
+ window.location.pathname +
132
+ "?" +
133
+ "search" +
134
+ "=" +
135
+ txtBox.value.toLowerCase() +
136
+ "&" +
137
+ "dictionary" +
138
+ "=" +
139
+ selectedDictionary +
140
+ "&" +
141
+ "prefix" +
142
+ "=" +
143
+ startsWith.value +
144
+ "&" +
145
+ "contains" +
146
+ "=" +
147
+ mustInclude.value +
148
+ "&" +
149
+ "suffix" +
150
+ "=" +
151
+ endsWith.value +
152
+ "&" +
153
+ "exclude" +
154
+ "=" +
155
+ exculdeWith.value +
156
+ "&" +
157
+ "include" +
158
+ "=" +
159
+ inculdeWith.value +
160
+ "&" +
161
+ "length" +
162
+ "=" +
163
+ wordLength.value;
164
+ window.history.pushState({ path: newurl }, "", newurl);
165
+
166
+ const params = new URLSearchParams(window.location.search);
167
+ serachValue = params.get("search");
168
+ prefixValue = params.get("prefix");
169
+ containsValue = params.get("contains");
170
+ suffixValue = params.get("suffix");
171
+ exculdeValue = params.get("exclude");
172
+ includeValue = params.get("include");
173
+ lengthValue = params.get("length");
174
+ dictonary = params.get("dictionary");
175
+
176
+ gtag("event", "page_view", {
177
+ page_location: window.location.pathname + location.search,
178
+ });
179
+ }
180
+
181
+ const paramName = 'search';
182
+ if (new URLSearchParams(window.location.search).has(paramName)) {
183
+ // Additional data to pass to the script
184
+ const additionalData = {
185
+ url: "{{site.url}}",
186
+ range: "{{page.blanktilerange}}"
187
+ };
188
+
189
+ var p1 = loadScript("/assets/js/wordfinder.js", additionalData)
190
+ .then((data) => {
191
+ console.log(data);
192
+ getData(txtBox.value.toLowerCase());
193
+ })
194
+ .catch((error) => {
195
+ console.error(error);
196
+ });
197
+ }
198
+ });