(ads, width, height)
| 352 | this.elements.parent.setAttribute("style", "--ejs-primary-color:" + getColor(color) + ";"); |
| 353 | } |
| 354 | setupAds(ads, width, height) { |
| 355 | const div = this.createElement("div"); |
| 356 | const time = (typeof this.config.adMode === "number" && this.config.adMode > -1 && this.config.adMode < 3) ? this.config.adMode : 2; |
| 357 | div.classList.add("ejs_ad_iframe"); |
| 358 | const frame = this.createElement("iframe"); |
| 359 | frame.src = ads; |
| 360 | frame.setAttribute("scrolling", "no"); |
| 361 | frame.setAttribute("frameborder", "no"); |
| 362 | frame.style.width = width; |
| 363 | frame.style.height = height; |
| 364 | const closeParent = this.createElement("div"); |
| 365 | closeParent.classList.add("ejs_ad_close"); |
| 366 | const closeButton = this.createElement("a"); |
| 367 | closeParent.appendChild(closeButton); |
| 368 | closeParent.setAttribute("hidden", ""); |
| 369 | div.appendChild(closeParent); |
| 370 | div.appendChild(frame); |
| 371 | if (this.config.adMode !== 1) { |
| 372 | this.elements.parent.appendChild(div); |
| 373 | } |
| 374 | this.addEventListener(closeButton, "click", () => { |
| 375 | div.remove(); |
| 376 | }) |
| 377 | |
| 378 | this.on("start-clicked", () => { |
| 379 | if (this.config.adMode === 0) div.remove(); |
| 380 | if (this.config.adMode === 1) { |
| 381 | this.elements.parent.appendChild(div); |
| 382 | } |
| 383 | }) |
| 384 | |
| 385 | this.on("start", () => { |
| 386 | closeParent.removeAttribute("hidden"); |
| 387 | const time = (typeof this.config.adTimer === "number" && this.config.adTimer > 0) ? this.config.adTimer : 10000; |
| 388 | if (this.config.adTimer === -1) div.remove(); |
| 389 | if (this.config.adTimer === 0) return; |
| 390 | setTimeout(() => { |
| 391 | div.remove(); |
| 392 | }, time); |
| 393 | }) |
| 394 | |
| 395 | } |
| 396 | adBlocked(url, del) { |
| 397 | if (del) { |
| 398 | document.querySelector('div[class="ejs_ad_iframe"]').remove(); |
no test coverage detected