1/** 2 * JokerBox å¼¹çªç»ä»¶ï¼è¿ä¸ªç»ä»¶å¯ä»¥èªå¨å®ç°å¼¹çªçåè½ï¼ä¸å 许æ¨èªå®ä¹å¼¹çªçæ ¼å¼ï¼ 3 * 4 * JokerBox pop-up component, this component can automatically implement the pop-up function and allow you to customize the format of the pop-up! 5 */ 6class JokerBox_popUp { 7 8 /** 9 * å°å¼¹çªåè½è£ è½½å°ä¸ä¸ªå ç´ ä¸ï¼è¿å°ä¼æå¼¹çªç»ä»¶ç声æå¨æä¸å ç´ ççå½å¨æç»å®å¨ä¸èµ· 10 * 11 * Load the pop-up function onto an element, which will bind the declaration cycle of the pop-up component to the lifecycle of the element 12 * @param dom {HTMLElement} éè¦æ¿è½½å¼¹çªçå ç´ 13 * 14 * Elements that need to carry pop-ups 15 * 16 * @param cssFormatter {string} å¨å¼¹çªä¸æ¾ç¤ºå 容æ¶è¦ä½¿ç¨çé¢å¶æ ¼å¼ï¼æä»¬å è®¸å¹¶æ¯ææ¨ä½¿ç¨èªå·±çæ ¼å¼å为弹çªä¸çå±ç¤ºï¼è¯·æ³¨æï¼è¿å°ä¼è®©æ¨çå ç´ è¢« jokerBox 管çï¼ 17 * We allow and support you to use your own pre made format for displaying content in pop ups. Please note that this will allow your elements to be managed by jokerBox! 18 * 19 * Elements that need to carry pop-ups 20 * @param color {{color: string, background: string}} å嫿¯èæ¯é¢è²ååä½é¢è² 21 * 22 * 23 * They are background color and font color, respectively 24 * @param closeClickAnimation å ³éæé®è¢«ç¹å»ä¹åçå ³éå¨ç»ææ å¨è¿é使ç¨çæ¯å ç½®çå¨ç»ï¼å¦ææ¨æèªå·±çå¨ç»ï¼å¯ä»¥ç´æ¥å¨è¿éä¼ éå¨ç»çååï¼ 25 * 26 * The close animation effect after the close button is clicked here uses the built-in animation. If you have your own animation, you can directly pass the name of the animation here! 27 */ 28 constructor(dom, 29 color = {}, 30 closeClickAnimation = 'jokerBox_pop_up_show_display_life_close', 31 cssFormatter = undefined) { 32 33 console.info(`jokerBox_v${JokerBox_popUp.getVersion()} -> popUp set ok!!`) 34 35 // å¤æèæ¯é¢è²æ¯å¦ä¸º 空 36 if (color['background'] === undefined) { 37 color['background'] = '#ccf8bf'; 38 } 39 40 // 夿åä½é¢è²æ¯å¦ä¸ºç©º 41 if (color['color'] === undefined) { 42 color['color'] = JokerBoxUtils.invertColor(color['background']); 43 } 44 45 let div1, div2, div3; 46 47 if (cssFormatter !== undefined) {
48 div1 = document.querySelector(cssFormatter); 49 const s1 = cssFormatter + ' .pop_up_content_text'; 50 const s2 = cssFormatter + ' .pop_up_content_close'; 51 div2 = document.querySelector(s1); 52 div3 = document.querySelector(s2); 53 if (!(div1 && div2 && div3)) { 54 console.error("jokerBox_popUp: subHtml is undefined!!\n" + 55 "You need to ensure that the following two class name elements are included in the format you specify\n" + 56 "\n" + 57 "1. " + s1 + ": Text content display elementï¼There can only be oneï¼\n" + 58 "\n" + 59 "2. " + s2 + ": Close button display elementï¼There can only be oneï¼", { 60 "your pop_up_content_text": div2, 61 "your pop_up_content_close": div3 62 }); 63 return; 64 } 65 } else { 66 div1 = document.createElement("div"); 67 div2 = document.createElement("div"); 68 div3 = document.createElement("a"); 69 div1.classList.add('jokerBox_pop_up_show_div') 70 div2.classList.add('pop_up_content_text'); 71 div3.classList.add('pop_up_content_close'); 72 73 div1.appendChild(div3); 74 div1.appendChild(div2); 75 dom.appendChild(div1); 76 } 77 78 div2.innerText = 'welcome to use jokerBox!!!'; 79 div3.innerText = 'x' 80 div3.title = 'å ³éå¼¹çª' 81 div3.href = '#' 82 div3.onclick = () => { 83 div1.style.animation = closeClickAnimation + ' 1s forwards'; 84 } 85 86 87 this.dom = div1; 88 this.textDom = div2; 89 90 this.dom.style.background = color['background']; 91 this.dom.style.transform = 'scale(0)'; 92 this.dom.style.height = '0'; 93 for (let childNode of this.dom.childNodes) { 94 if (childNode.style === undefined) { 95 continue; 96 } 97 childNode.style.color = color['color']; 98 } 99 100 const invertColor1 = JokerBoxUtils.invertColor(color['color']); 101 div3.onmouseover = function () { 102 this.style.color = invertColor1; 103 this.style.transform = 'scale(150%)'; 104 this.style.textShadow = '20% 20% 20% 20% #fff'; 105 } 106 div3.onmouseout = function () { 107 this.style.color = color['color']; 108 this.style.transform = 'scale(100%)'; 109 } 110 111 this.dom.onanimationend = function () {
112 this.style.animation = 'none'; 113 } 114 } 115 116 /** 117 * å°å¼¹çªåè½è£ è½½å°ä¸ä¸ªå ç´ ä¸ï¼è¿å°ä¼æå¼¹çªç»ä»¶ç声æå¨æä¸å ç´ ççå½å¨æç»å®å¨ä¸èµ· 118 * 119 * Load the pop-up function onto an element, which will bind the declaration cycle of the pop-up component to the lifecycle of the element 120 * @param dom {HTMLElement} éè¦æ¿è½½å¼¹çªçå ç´ 121 * 122 * 123 * @param cssFormatter {string} å¨å¼¹çªä¸æ¾ç¤ºå 容æ¶è¦ä½¿ç¨çé¢å¶æ ¼å¼ï¼æä»¬å è®¸å¹¶æ¯ææ¨ä½¿ç¨èªå·±çæ ¼å¼å为弹çªä¸çå±ç¤ºï¼è¯·æ³¨æï¼è¿å°ä¼è®©æ¨çå ç´ è¢« jokerBox 管çï¼ 124 * We allow and support you to use your own pre made format for displaying content in pop ups. Please note that this will allow your elements to be managed by jokerBox! 125 * 126 * Elements that need to carry pop-ups 127 * @param color {{color: string, background: string}} å嫿¯èæ¯é¢è²ååä½é¢è² 128 * 129 * 130 * They are background color and font color, respectively 131 * @param closeClickAnimation å ³éæé®è¢«ç¹å»ä¹åçå ³éå¨ç»ææ å¨è¿é使ç¨çæ¯å ç½®çå¨ç»ï¼å¦ææ¨æèªå·±çå¨ç»ï¼å¯ä»¥ç´æ¥å¨è¿éä¼ éå¨ç»çååï¼ 132 * 133 * The close animation effect after the close button is clicked here uses the built-in animation. If you have your own animation, you can directly pass the name of the animation here! 134 */ 135 static createByHtml(dom, cssFormatter, 136 color = {}, 137 closeClickAnimation = 'jokerBox_pop_up_show_display_life_close') { 138 return new JokerBox_popUp(dom, color, closeClickAnimation, cssFormatter); 139 } 140 141 /** 142 * å°å¼¹çªåè½è£ è½½å°ä¸ä¸ªå ç´ ä¸ï¼è¿å°ä¼æå¼¹çªç»ä»¶ç声æå¨æä¸å ç´ ççå½å¨æç»å®å¨ä¸èµ· 143 * 144 * Load the pop-up function onto an element, which will bind the declaration cycle of the pop-up component to the lifecycle of the element 145 * @param dom {HTMLElement} éè¦æ¿è½½å¼¹çªçå ç´ 146 * 147 * Elements that need to carry pop-ups 148 * @param color {{color: string, background: string}} å嫿¯èæ¯é¢è²ååä½é¢è² 149 * 150 * They are background color and font color, respectively 151 * @param closeClickAnimation å ³éæé®è¢«ç¹å»ä¹åçå ³éå¨ç»ææ å¨è¿é使ç¨çæ¯å ç½®çå¨ç»ï¼å¦ææ¨æèªå·±çå¨ç»ï¼å¯ä»¥ç´æ¥å¨è¿éä¼ éå¨ç»çååï¼ 152 * 153 * The close animation effect after the close button is clicked here uses the built-in animation. If you have your own animation, you can directly pass the name of the animation here! 154 */ 155 static create(dom, 156 color = {}, 157 closeClickAnimation = 'jokerBox_pop_up_show_display_life_close') { 158 return this.createByHtml(dom, undefined, color, closeClickAnimation) 159 } 160 161 static getVersion() { 162 return '1.0.0'; 163 } 164 165 /** 166 * å¼¹çªæ¾ç¤ºæ¡ 167 * @param msg {string} éè¦å¨å¼¹çªä¸æ¾ç¤ºçå 容 168 * @param timeMs {number} å¼¹çªå¨ç»+æ¾ç¤ºçæ»æ¶é´ æ¯«ç§æ°å¼ 169 */ 170 show(msg, timeMs = 10000) { 171 this.textDom.innerText = msg; 172 this.dom.style.animation = `jokerBox_pop_up_show_display_life ${timeMs}ms forwards`; 173 } 174} 175 176/** 177 * JokerBoxUtils å°ä¸ç å¼¹çªå·¥å ·å 178 * @class JokerBoxUtils 179 * @classdesc JokerBoxUtils 180 */ 181class JokerBoxUtils { 182 183 /** 184 * 计ç®ä¸ä¸ªé¢è²æ°å¼çåè² 185 * @param color éè¦è¢«è®¡ç®çé¢è²æ°å¼ 186 * @return {string} 计ç®ç»æ åè²çé¢è²æ°å¼ 16 è¿å¶ 187 */ 188 static invertColor(color) { 189 // å°é¢è²å¼è½¬æ¢ä¸º RGB æ ¼å¼ 190 const r = parseInt(color.substring(1, 3), 16); 191 const g = parseInt(color.substring(3, 5), 16); 192 const b = parseInt(color.substring(5, 7), 16); 193 194 // 计ç®åè²å¼ 195 const invertedR = 255 - r; 196 const invertedG = 255 - g; 197 const invertedB = 255 - b; 198 199 // å°åè²å¼è½¬æ¢ä¸ºåå è¿å¶æ ¼å¼ï¼å¹¶è¿åç»æ 200 return '#' + invertedR.toString(16).padStart(2, '0') + invertedG.toString(16).padStart(2, '0') + invertedB.toString(16).padStart(2, '0'); 201 } 202 203}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.