bep40 commited on
Commit
a7eeffc
·
verified ·
1 Parent(s): 55ce686

Add search-plus auto-loader as deferred script"

Browse files
Files changed (1) hide show
  1. search-plus-boot.js +26 -0
search-plus-boot.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- This file auto-loads search-plus functionality -->
2
+ <!-- Include via: <script src="search-plus-boot.js"></script> before </body> -->
3
+ (function(){
4
+ 'use strict';
5
+ // Create and inject search-plus.js
6
+ function boot(){
7
+ var s=document.createElement('script');
8
+ s.src='search-plus.js';
9
+ s.onload=function(){
10
+ // Add magic button to search box
11
+ var sb=document.querySelector('.search-box');
12
+ if(!sb)return;
13
+ var btn=document.createElement('button');
14
+ btn.onclick=function(){if(typeof toggleSearchPlus==='function')toggleSearchPlus()};
15
+ btn.title='Tìm kiếm Plus - AI tìm SP bên ngoài';
16
+ btn.style.cssText='position:absolute;right:70px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:7px;background:linear-gradient(135deg,#db9815,#f0b840);color:#fff;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:.7rem;z-index:2';
17
+ btn.innerHTML='✨';
18
+ sb.appendChild(btn);
19
+ // Load saved products
20
+ setTimeout(function(){if(typeof loadExternalProducts==='function')loadExternalProducts()},3000);
21
+ };
22
+ document.body.appendChild(s);
23
+ }
24
+ if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',boot);
25
+ else boot();
26
+ })();